name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
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
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
cross: true
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --locked
- name: Build (native)
if: "!matrix.cross"
run: cargo build --release --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Package (unix)
if: matrix.archive == 'tar.gz'
run: |
BINARY=target/${{ matrix.target }}/release/agentshield
ARCHIVE=agentshield-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
tar czf "$ARCHIVE" -C "$(dirname $BINARY)" "$(basename $BINARY)"
shasum -a 256 "$ARCHIVE" > "$ARCHIVE.sha256"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- name: Package (windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$BINARY = "target/${{ matrix.target }}/release/agentshield.exe"
$ARCHIVE = "agentshield-${{ github.ref_name }}-${{ matrix.target }}.zip"
Compress-Archive -Path $BINARY -DestinationPath $ARCHIVE
$HASH = (Get-FileHash -Algorithm SHA256 $ARCHIVE).Hash.ToLower()
"$HASH $ARCHIVE" | Out-File -Encoding ascii "$ARCHIVE.sha256"
"ARCHIVE=$ARCHIVE" | Out-File -Append -Encoding ascii $env:GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: agentshield-${{ matrix.target }}
path: |
agentshield-*.tar.gz
agentshield-*.zip
agentshield-*.sha256
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/agentshield-*.tar.gz
artifacts/agentshield-*.zip
artifacts/agentshield-*.sha256