|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + checks: read |
| 11 | + actions: read |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + |
| 16 | +jobs: |
| 17 | + # Wait for CI to pass before building release artifacts |
| 18 | + check-ci: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Wait for CI to succeed |
| 22 | + uses: lewagon/wait-on-check-action@v1.3.4 |
| 23 | + with: |
| 24 | + ref: ${{ github.ref }} |
| 25 | + check-name: "test" |
| 26 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + build: |
| 29 | + needs: check-ci |
| 30 | + runs-on: ${{ matrix.os }} |
| 31 | + strategy: |
| 32 | + matrix: |
| 33 | + include: |
| 34 | + - os: ubuntu-latest |
| 35 | + target: x86_64-unknown-linux-gnu |
| 36 | + artifact: peas |
| 37 | + - os: macos-latest |
| 38 | + target: x86_64-apple-darwin |
| 39 | + artifact: peas |
| 40 | + - os: macos-latest |
| 41 | + target: aarch64-apple-darwin |
| 42 | + artifact: peas |
| 43 | + - os: windows-latest |
| 44 | + target: x86_64-pc-windows-msvc |
| 45 | + artifact: peas.exe |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Install Rust |
| 51 | + uses: dtolnay/rust-toolchain@stable |
| 52 | + with: |
| 53 | + targets: ${{ matrix.target }} |
| 54 | + |
| 55 | + - name: Cache cargo |
| 56 | + uses: actions/cache@v4 |
| 57 | + with: |
| 58 | + path: | |
| 59 | + ~/.cargo/registry/index/ |
| 60 | + ~/.cargo/registry/cache/ |
| 61 | + ~/.cargo/git/db/ |
| 62 | + target/ |
| 63 | + key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} |
| 64 | + restore-keys: | |
| 65 | + ${{ runner.os }}-${{ matrix.target }}-cargo-release- |
| 66 | + ${{ runner.os }}-${{ matrix.target }}-cargo- |
| 67 | +
|
| 68 | + - name: Build release |
| 69 | + run: cargo build --release --target ${{ matrix.target }} --verbose |
| 70 | + |
| 71 | + - name: Package (Unix) |
| 72 | + if: matrix.os != 'windows-latest' |
| 73 | + run: | |
| 74 | + cd target/${{ matrix.target }}/release |
| 75 | + tar czf ../../../peas-${{ matrix.target }}.tar.gz ${{ matrix.artifact }} |
| 76 | + cd ../../.. |
| 77 | + shasum -a 256 peas-${{ matrix.target }}.tar.gz > peas-${{ matrix.target }}.tar.gz.sha256 |
| 78 | +
|
| 79 | + - name: Package (Windows) |
| 80 | + if: matrix.os == 'windows-latest' |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + cd target/${{ matrix.target }}/release |
| 84 | + 7z a ../../../peas-${{ matrix.target }}.zip ${{ matrix.artifact }} |
| 85 | + cd ../../.. |
| 86 | + sha256sum peas-${{ matrix.target }}.zip > peas-${{ matrix.target }}.zip.sha256 |
| 87 | +
|
| 88 | + - name: Upload artifact |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: peas-${{ matrix.target }} |
| 92 | + path: | |
| 93 | + peas-${{ matrix.target }}.* |
| 94 | +
|
| 95 | + release: |
| 96 | + needs: build |
| 97 | + runs-on: ubuntu-latest |
| 98 | + steps: |
| 99 | + - name: Download all artifacts |
| 100 | + uses: actions/download-artifact@v4 |
| 101 | + with: |
| 102 | + path: artifacts |
| 103 | + |
| 104 | + - name: Create Release |
| 105 | + uses: softprops/action-gh-release@v1 |
| 106 | + with: |
| 107 | + files: artifacts/**/* |
| 108 | + draft: false |
| 109 | + prerelease: false |
| 110 | + generate_release_notes: true |
| 111 | + env: |
| 112 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments