|
| 1 | +name: cd / release artifacts |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "acp-nats-stdio@v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + attestations: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build (${{ matrix.target }}) |
| 19 | + runs-on: ${{ matrix.runner }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - target: x86_64-unknown-linux-gnu |
| 25 | + runner: ubuntu-latest |
| 26 | + use-cross: false |
| 27 | + - target: aarch64-unknown-linux-gnu |
| 28 | + runner: ubuntu-latest |
| 29 | + use-cross: true |
| 30 | + - target: x86_64-apple-darwin |
| 31 | + runner: macos-13 |
| 32 | + use-cross: false |
| 33 | + - target: aarch64-apple-darwin |
| 34 | + runner: macos-latest |
| 35 | + use-cross: false |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v6.0.2 |
| 40 | + |
| 41 | + - name: Extract version from tag |
| 42 | + id: version |
| 43 | + shell: bash |
| 44 | + run: echo "version=${GITHUB_REF_NAME#acp-nats-stdio@v}" >> "$GITHUB_OUTPUT" |
| 45 | + |
| 46 | + - uses: jdx/mise-action@v4.0.1 |
| 47 | + |
| 48 | + - name: Add Rust target |
| 49 | + if: ${{ !matrix.use-cross }} |
| 50 | + run: rustup target add ${{ matrix.target }} |
| 51 | + |
| 52 | + - name: Install cross |
| 53 | + if: ${{ matrix.use-cross }} |
| 54 | + uses: taiki-e/install-action@cross |
| 55 | + |
| 56 | + - name: Cache dependencies |
| 57 | + uses: Swatinem/rust-cache@v2.9.1 |
| 58 | + with: |
| 59 | + workspaces: rsworkspace -> target |
| 60 | + key: ${{ matrix.target }} |
| 61 | + |
| 62 | + - name: Build |
| 63 | + working-directory: rsworkspace |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + if [ "${{ matrix.use-cross }}" = "true" ]; then |
| 67 | + cross build --release --target ${{ matrix.target }} -p acp-nats-stdio |
| 68 | + else |
| 69 | + cargo build --release --target ${{ matrix.target }} -p acp-nats-stdio |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Package |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + staging="acp-nats-stdio-${{ steps.version.outputs.version }}-${{ matrix.target }}" |
| 76 | + mkdir -p "$staging" |
| 77 | + cp "rsworkspace/target/${{ matrix.target }}/release/acp-nats-stdio" "$staging/" |
| 78 | + tar czf "$staging.tar.gz" "$staging" |
| 79 | + echo "ASSET=$staging.tar.gz" >> "$GITHUB_ENV" |
| 80 | +
|
| 81 | + - name: Attest build provenance |
| 82 | + uses: actions/attest-build-provenance@v2 |
| 83 | + with: |
| 84 | + subject-path: ${{ env.ASSET }} |
| 85 | + |
| 86 | + - name: Upload artifact |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + with: |
| 89 | + name: ${{ matrix.target }} |
| 90 | + path: ${{ env.ASSET }} |
| 91 | + |
| 92 | + upload: |
| 93 | + name: Upload to release |
| 94 | + needs: build |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - name: Checkout |
| 98 | + uses: actions/checkout@v6.0.2 |
| 99 | + |
| 100 | + - name: Download all artifacts |
| 101 | + uses: actions/download-artifact@v4 |
| 102 | + with: |
| 103 | + path: artifacts |
| 104 | + merge-multiple: true |
| 105 | + |
| 106 | + - name: Generate checksums |
| 107 | + working-directory: artifacts |
| 108 | + run: sha256sum acp-nats-stdio-* > sha256sums.txt |
| 109 | + |
| 110 | + - name: Upload to GitHub Release |
| 111 | + env: |
| 112 | + GH_TOKEN: ${{ github.token }} |
| 113 | + run: gh release upload "$GITHUB_REF_NAME" artifacts/* --clobber |
0 commit comments