name: Release Binaries
on:
push:
tags:
- "v*"
permissions:
contents: read
env:
BINARY_NAME: synpad
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive_name: linux-x86_64
archive_ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive_name: windows-x86_64
archive_ext: zip
- os: macos-13
target: x86_64-apple-darwin
archive_name: macos-x86_64
archive_ext: tar.gz
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Linux desktop dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
libsoup-3.0-dev \
libxdo-dev \
patchelf
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: .
- name: Build release binary
run: cargo build --locked --release --target ${{ matrix.target }} --bin ${{ env.BINARY_NAME }}
- name: Package archive (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -euxo pipefail
archive="${BINARY_NAME}-${GITHUB_REF_NAME}-${{ matrix.archive_name }}.${{ matrix.archive_ext }}"
binary_dir="target/${{ matrix.target }}/release"
staging="${BINARY_NAME}-${GITHUB_REF_NAME}-${{ matrix.archive_name }}"
rm -rf "${staging}"
mkdir -p "${staging}"
cp "${binary_dir}/${BINARY_NAME}" "${staging}/"
cp README.md "${staging}/"
if [ -d assets ]; then
cp -R assets "${staging}/assets"
fi
tar -czf "${archive}" "${staging}"
shasum -a 256 "${archive}" > "${archive}.sha256"
- name: Package archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$archive = "${env:BINARY_NAME}-${env:GITHUB_REF_NAME}-${{ matrix.archive_name }}.${{ matrix.archive_ext }}"
$staging = "${env:BINARY_NAME}-${env:GITHUB_REF_NAME}-${{ matrix.archive_name }}"
New-Item -ItemType Directory -Path $staging -Force | Out-Null
Copy-Item "target/${{ matrix.target }}/release/${env:BINARY_NAME}.exe" "$staging/"
Copy-Item "README.md" "$staging/"
if (Test-Path "assets") {
Copy-Item "assets" "$staging/assets" -Recurse
}
Compress-Archive -Path $staging -DestinationPath $archive -Force
$hash = (Get-FileHash -Algorithm SHA256 $archive).Hash.ToLower()
"$hash $archive" | Out-File -FilePath "$archive.sha256" -Encoding ascii
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive_name }}
if-no-files-found: error
path: |
${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.archive_name }}.${{ matrix.archive_ext }}
${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.archive_name }}.${{ matrix.archive_ext }}.sha256
release:
name: Publish GitHub release assets
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: Upload assets to release
uses: softprops/action-gh-release@v2
with:
files: release-assets/*
generate_release_notes: true