Release #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., 0.2.0)' | |
| required: true | |
| type: string | |
| env: | |
| CARGO_TERM_COLOR: always | |
| BINARY_NAME: sentinel-api-deprecation-agent | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| artifact: linux-x86_64 | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| artifact: linux-aarch64 | |
| cross: true | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| artifact: darwin-aarch64 | |
| steps: | |
| - name: Checkout agent | |
| uses: actions/checkout@v4 | |
| with: | |
| path: agent | |
| - name: Checkout SDK | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: raskell-io/sentinel-agent-rust-sdk | |
| path: sentinel-agent-rust-sdk | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools | |
| if: matrix.cross | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| - name: Cache cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| agent/target/ | |
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('agent/**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.target }}-cargo- | |
| - name: Build release binary | |
| working-directory: agent | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Strip binary (Linux native) | |
| if: matrix.target == 'x86_64-unknown-linux-gnu' | |
| run: strip agent/target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} | |
| - name: Strip binary (Linux cross) | |
| if: matrix.cross | |
| run: aarch64-linux-gnu-strip agent/target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} | |
| - name: Strip binary (macOS) | |
| if: contains(matrix.target, 'darwin') | |
| run: strip agent/target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Package binary | |
| run: | | |
| mkdir -p dist | |
| cp agent/target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} dist/ | |
| cd dist | |
| tar -czvf ${{ env.BINARY_NAME }}-${{ steps.version.outputs.version }}-${{ matrix.artifact }}.tar.gz ${{ env.BINARY_NAME }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: dist/*.tar.gz | |
| retention-days: 1 | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | |
| echo "tag=v${{ inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: List artifacts | |
| run: find artifacts -type f | |
| - name: Collect release files | |
| run: | | |
| mkdir -p release | |
| find artifacts -name '*.tar.gz' -exec mv {} release/ \; | |
| ls -la release/ | |
| - name: Delete existing release if exists | |
| run: gh release delete "${{ steps.version.outputs.tag }}" --yes || true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: v${{ steps.version.outputs.version }} | |
| files: release/* | |
| fail_on_unmatched_files: true | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |