name: Release binaries
on:
release:
types: [published]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
- os: macos-latest
target: universal2-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-11-arm
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- name: Build
shell: bash
run: |
set -euo pipefail
if [ "${{ matrix.target }}" = universal2-apple-darwin ]; then
# Build both arches on this Apple Silicon runner and merge with lipo.
rustup target add aarch64-apple-darwin x86_64-apple-darwin
cargo build --release --bin xdms-rs --target aarch64-apple-darwin
cargo build --release --bin xdms-rs --target x86_64-apple-darwin
mkdir -p "target/${{ matrix.target }}/release"
lipo -create -output "target/${{ matrix.target }}/release/xdms-rs" \
target/aarch64-apple-darwin/release/xdms-rs \
target/x86_64-apple-darwin/release/xdms-rs
lipo -info "target/${{ matrix.target }}/release/xdms-rs"
else
rustup target add "${{ matrix.target }}"
cargo build --release --bin xdms-rs --target "${{ matrix.target }}"
fi
- name: Package
shell: bash
run: |
set -euo pipefail
staging="xdms-rs-${{ matrix.target }}"
mkdir "$staging"
if [ "${{ runner.os }}" = "Windows" ]; then
cp "target/${{ matrix.target }}/release/xdms-rs.exe" "$staging/"
else
cp "target/${{ matrix.target }}/release/xdms-rs" "$staging/"
fi
cp README.md LICENSE-MIT LICENSE-APACHE "$staging/"
if [ "${{ runner.os }}" = "Windows" ]; then
7z a "$staging.zip" "$staging" >/dev/null
echo "ASSET=$staging.zip" >> "$GITHUB_ENV"
else
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> "$GITHUB_ENV"
fi
- name: Attach to release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.event.release.tag_name }}" "$ASSET" --clobber