|
| 1 | +# GitHub Action for creating simple (pre-)releases of the YIO integrations.library. |
| 2 | +# - Creates a pre-release if pushed on master branch without a version tag. |
| 3 | +# - Creates a release if pushed on master branch with a version tag. |
| 4 | +--- |
| 5 | + name: "Release" |
| 6 | + |
| 7 | + on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - master |
| 11 | + tags: |
| 12 | + - v[0-9]+.[0-9]+.[0-9]+ |
| 13 | + |
| 14 | + env: |
| 15 | + PROJECT_NAME: integrations.library |
| 16 | + |
| 17 | + jobs: |
| 18 | + release: |
| 19 | + name: Create Release |
| 20 | + if: github.ref == 'refs/heads/master' || contains(github.ref, 'tags/v') |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout ${{ env.PROJECT_NAME}} |
| 25 | + uses: actions/checkout@v2 |
| 26 | + with: |
| 27 | + # History of 500 should be more than enough to calculate commit count since last release tag. |
| 28 | + fetch-depth: 500 |
| 29 | + path: ${{ env.PROJECT_NAME}} |
| 30 | + |
| 31 | + - name: Fetch all tags to determine version |
| 32 | + run: | |
| 33 | + cd ${{ env.PROJECT_NAME}} |
| 34 | + git fetch origin +refs/tags/*:refs/tags/* |
| 35 | + git describe --match "v[0-9]*" --tags HEAD --always |
| 36 | + |
| 37 | + - name: Get artifact version |
| 38 | + run: | |
| 39 | + cd ${{ env.PROJECT_NAME}} |
| 40 | + APP_VERSION=$(git describe --match "v[0-9]*" --tags HEAD --always) |
| 41 | + echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV |
| 42 | + echo "TIMESTAMP=$(date +"%Y%m%d_%H%M%S")" >> $GITHUB_ENV |
| 43 | +
|
| 44 | + - name: Create Pre-Release ${{ env.APP_VERSION }} |
| 45 | + uses: "marvinpinto/action-automatic-releases@latest" |
| 46 | + if: "!contains(github.ref, 'tags/v')" |
| 47 | + with: |
| 48 | + repo_token: "${{ secrets.GITHUB_TOKEN }}" |
| 49 | + automatic_release_tag: "latest" |
| 50 | + prerelease: true |
| 51 | + title: "Development Build ${{ env.APP_VERSION }}" |
| 52 | + # No files yet, added manually for now |
| 53 | + #files: | |
| 54 | + # *.tar |
| 55 | + |
| 56 | + - name: Create Release ${{ env.APP_VERSION }} |
| 57 | + uses: "marvinpinto/action-automatic-releases@latest" |
| 58 | + if: "contains(github.ref, 'tags/v')" |
| 59 | + with: |
| 60 | + repo_token: "${{ secrets.GITHUB_TOKEN }}" |
| 61 | + prerelease: false |
| 62 | + # No files yet, added manually for now |
| 63 | + #files: | |
| 64 | + # *.tar |
0 commit comments