name: Release
on:
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
max-parallel: 4
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
- os: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
steps:
- uses: actions/checkout@v4
- name: Install probe-rs system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev pkg-config
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Package (unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
name="rambo-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir "$name"
cp "target/${{ matrix.target }}/release/rambo" "$name/"
cp README.md LICENSE "$name/" 2>/dev/null || true
tar czf "${name}.tar.gz" "$name"
echo "ASSET=${name}.tar.gz" >> "$GITHUB_ENV"
- name: Package (windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$name = "rambo-$env:GITHUB_REF_NAME-${{ matrix.target }}"
New-Item -ItemType Directory -Path $name | Out-Null
Copy-Item "target/${{ matrix.target }}/release/rambo.exe" "$name/"
if (Test-Path README.md) { Copy-Item README.md "$name/" }
if (Test-Path LICENSE) { Copy-Item LICENSE "$name/" }
Compress-Archive -Path $name -DestinationPath "$name.zip"
"ASSET=$name.zip" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: ${{ env.ASSET }}
generate_release_notes: true