How to Upload Cross-Platform Binaries to a Release in GitHub Actions
A matrix builds one binary per OS in parallel; upload each as a per-OS artifact and attach them all to the single release.
Run a build matrix over runs-on, name the output by matrix.os, and have each matrix leg upload its binary directly to the release with files:.
Steps
- Set
strategy.matrix.osandruns-on: ${{ matrix.os }}. - Build and name the binary by platform.
- Each leg runs
action-gh-releasewith its ownfiles:entry.
Workflow
.github/workflows/release.yml
on:
push:
tags: ['v*.*.*']
permissions:
contents: write
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: cargo build --release
- uses: softprops/action-gh-release@v2
with:
files: target/release/mytool*Gotchas
- Use a per-OS file name or path so the three legs do not overwrite each other.
- Latchkey offers native arm64 runners so cross-platform release builds run without QEMU overhead.
Related guides
How to Attach Build Artifacts to a Release in GitHub ActionsUpload build outputs as GitHub Release assets in GitHub Actions by passing a files glob to softprops/action-g…
How to Publish a Docker Image Tagged by Release in GitHub ActionsBuild and push a Docker image tagged with the release version in GitHub Actions using docker/metadata-action…