release.yaml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - "v[0-9]+.[0-9]+.[0-9]+"
  6. pull_request:
  7. branches:
  8. - master
  9. paths:
  10. - VERSION
  11. - ./github/workflows/release.yaml
  12. env:
  13. DIST: dist-${{ github.ref_name }}
  14. jobs:
  15. build:
  16. name: Build
  17. runs-on: ${{ matrix.os }}
  18. strategy:
  19. matrix:
  20. target:
  21. - aarch64-apple-darwin
  22. - x86_64-unknown-linux-gnu
  23. - x86_64-apple-darwin
  24. - x86_64-pc-windows-msvc
  25. include:
  26. - target: aarch64-apple-darwin
  27. os: macos-latest
  28. - target: x86_64-unknown-linux-gnu
  29. os: ubuntu-latest
  30. - target: x86_64-apple-darwin
  31. os: macos-latest
  32. - target: x86_64-pc-windows-msvc
  33. os: windows-latest
  34. steps:
  35. - uses: actions/checkout@v4
  36. - uses: dtolnay/rust-toolchain@master
  37. with:
  38. toolchain: stable
  39. target: ${{ matrix.target }}
  40. - name: Build release binary
  41. run: cargo build --package anchor-cli --release --locked --target ${{ matrix.target }}
  42. - name: Prepare
  43. if: startsWith(github.ref, 'refs/tags/')
  44. id: prepare
  45. shell: bash
  46. run: |
  47. version=$(echo $GITHUB_REF_NAME | cut -dv -f2)
  48. ext=""
  49. [[ "${{ matrix.os }}" == windows-latest ]] && ext=".exe"
  50. mkdir $DIST
  51. mv "target/${{ matrix.target }}/release/anchor$ext" $DIST/anchor-$version-${{ matrix.target }}$ext
  52. echo "version=$version" >> $GITHUB_OUTPUT
  53. - uses: actions/upload-artifact@v4
  54. if: startsWith(github.ref, 'refs/tags/')
  55. with:
  56. name: anchor-${{ steps.prepare.outputs.version }}-${{ matrix.target }}
  57. path: ${{ env.DIST }}
  58. overwrite: true
  59. retention-days: 1
  60. upload:
  61. name: Upload binaries to release
  62. if: startsWith(github.ref, 'refs/tags/')
  63. needs: [build]
  64. runs-on: ubuntu-latest
  65. steps:
  66. - uses: actions/checkout@v4
  67. - uses: actions/download-artifact@v4
  68. with:
  69. path: ${{ env.DIST }}
  70. - name: Upload
  71. shell: bash
  72. run: GH_TOKEN=${{ secrets.GITHUB_TOKEN }} gh release upload $GITHUB_REF_NAME $DIST/*/* --clobber