goose/.github/workflows/build-native-packages.yml

120 lines
3.6 KiB
YAML

name: Build Native Packages
on:
workflow_call:
outputs:
artifact-name:
description: "Name of the artifact containing all native binaries"
value: ${{ jobs.collect.outputs.artifact-name }}
workflow_dispatch:
push:
branches:
- main
paths:
- 'crates/goose-acp/**'
- 'ui/acp/**'
- '.github/workflows/build-native-packages.yml'
pull_request:
paths:
- 'crates/goose-acp/**'
- 'ui/acp/**'
- '.github/workflows/build-native-packages.yml'
jobs:
build-matrix:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- platform: darwin-arm64
os: macos-latest
target: aarch64-apple-darwin
- platform: darwin-x64
os: macos-latest
target: x86_64-apple-darwin
- platform: linux-arm64
os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- platform: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- platform: win32-x64
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
with:
targets: ${{ matrix.target }}
- name: Add Intel target for cross-compilation (macOS ARM64 → x86_64)
if: matrix.platform == 'darwin-x64'
run: rustup target add x86_64-apple-darwin
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.platform == 'linux-arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Setup Rust cache
uses: Swatinem/rust-cache@42dc69e1aa15d09112580998cf2ef0119e2e91ae # v2
with:
key: ${{ matrix.platform }}
- name: Build goose-acp-server
run: cargo build --release --target ${{ matrix.target }} --bin goose-acp-server
- name: Prepare artifact (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p artifact/bin
cp target/${{ matrix.target }}/release/goose-acp-server artifact/bin/
chmod +x artifact/bin/goose-acp-server
- name: Prepare artifact (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p artifact/bin
cp target/${{ matrix.target }}/release/goose-acp-server.exe artifact/bin/
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: goose-acp-server-${{ matrix.platform }}
path: artifact/
if-no-files-found: error
retention-days: 7
collect:
name: Collect all binaries
runs-on: ubuntu-latest
needs: build-matrix
outputs:
artifact-name: native-binaries-all
steps:
- name: Download all artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
path: native-binaries
- name: List downloaded artifacts
run: |
echo "Downloaded artifacts:"
ls -R native-binaries/
- name: Upload combined artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: native-binaries-all
path: native-binaries/
if-no-files-found: error
retention-days: 7