Skip to content

Workflow file for this run

name: Build Binaries
on:
workflow_dispatch:
release:
types: [published]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-x64
- os: ubuntu-24.04-arm
target: linux-arm64
- os: macos-latest
target: darwin-arm64
- os: macos-latest
target: darwin-x64
cross_compile: true # Cross-compile x64 from ARM runner
- os: windows-latest
target: windows-x64
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
# Using --no-frozen-lockfile because optionalDependencies reference
# platform-specific packages that don't exist until we publish them
- run: pnpm install --no-frozen-lockfile
- name: Build binary
run: |
if [ "${{ matrix.cross_compile }}" = "true" ]; then
bun run scripts/build-binary.ts --target=${{ matrix.target }}
else
bun run scripts/build-binary.ts --single
fi
shell: bash
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: heroshot-${{ matrix.target }}
path: dist/binaries/heroshot-${{ matrix.target == 'windows-x64' && 'windows' || matrix.target }}*
retention-days: 30
# Combine all artifacts into a single release asset
release-assets:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release'
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure
run: ls -R artifacts
- name: Rename binaries with platform suffix
run: |
cd artifacts
for dir in heroshot-*/heroshot-*/bin; do
platform=$(echo "$dir" | cut -d'/' -f1 | sed 's/heroshot-//')
for file in "$dir"/*; do
if [ -f "$file" ]; then
filename=$(basename "$file")
if [[ "$filename" == "heroshot.exe" ]]; then
mv "$file" "$dir/heroshot-${platform}.exe"
elif [[ "$filename" == "heroshot" ]]; then
mv "$file" "$dir/heroshot-${platform}"
fi
fi
done
done
ls -R
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/heroshot-*/heroshot-*/bin/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}