|
| 1 | +name: 'Build and Release' |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*' |
| 6 | + - 'beta-v*' |
| 7 | + - 'v*-beta' |
| 8 | + |
| 9 | +jobs: |
| 10 | + changelog: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: "Generate release changelog" |
| 14 | + uses: heinrichreimer/github-changelog-generator-action@v2.3 |
| 15 | + with: |
| 16 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 17 | + |
| 18 | + create_release: |
| 19 | + name: Create Release |
| 20 | + runs-on: ubuntu-latest |
| 21 | + needs: changelog |
| 22 | + outputs: |
| 23 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 24 | + steps: |
| 25 | + - name: Create Release For Tag |
| 26 | + id: create_release |
| 27 | + uses: actions/create-release@v1 |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + with: |
| 31 | + tag_name: ${{ github.ref }} |
| 32 | + release_name: Release ${{ github.ref }} |
| 33 | + body: ${{ needs.changelog.outputs.changelog }} |
| 34 | + draft: false |
| 35 | + prerelease: ${{ contains(github.ref, 'beta') }} |
| 36 | + |
| 37 | + build: |
| 38 | + name: Build Executables |
| 39 | + runs-on: ${{ matrix.os }} |
| 40 | + needs: create_release |
| 41 | + strategy: |
| 42 | + fail-fast: true |
| 43 | + matrix: |
| 44 | + include: |
| 45 | + - os: ubuntu-latest |
| 46 | + OUT_FILE_NAME: vaf |
| 47 | + ASSET_MIME: application/octet-stream |
| 48 | + - os: windows-latest |
| 49 | + OUT_FILE_NAME: vaf.exe |
| 50 | + ASSET_MIME: application/vnd.microsoft.portable-executable |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v3 |
| 53 | + - name: Setup nim |
| 54 | + uses: iffy/install-nim@v4.1.1 |
| 55 | + - name: Build with nimble for ${{ runner.os }} |
| 56 | + run: nimble build -y |
| 57 | + - name: Upload release assets |
| 58 | + uses: actions/upload-release-asset@v1 |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + with: |
| 62 | + upload_url: ${{ needs.create_release.outputs.upload_url }} |
| 63 | + asset_path: './${{ matrix.OUT_FILE_NAME }}' |
| 64 | + asset_name: '${{runner.os}}-${{ matrix.OUT_FILE_NAME }}' |
| 65 | + asset_content_type: '${{ matrix.ASSET_MIME }}' |
| 66 | + |
| 67 | + purge_release_if_failed: |
| 68 | + name: Delete release if build failed |
| 69 | + needs: build |
| 70 | + runs-on: ubuntu-latest |
| 71 | + if: ${{ failure() || cancelled() }} |
| 72 | + steps: |
| 73 | + - uses: dev-drprasad/delete-tag-and-release@v0.2.0 |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + with: |
| 77 | + delete_release: true |
| 78 | + tag_name: ${{ github.ref_name }} |
0 commit comments