release.yaml 2.1 KB

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