-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (88 loc) · 3.63 KB
/
Copy path_build-matrix.yml
File metadata and controls
99 lines (88 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Build matrix (reusable)
# Reusable workflow: compiles the release binary for every supported platform
# and uploads each as a `bin-<os>-<cpu>` artifact. Called by release.yml (to
# produce the binaries attached to the GitHub Release) and build-check.yml (to
# verify builds on PR/push), so the platform matrix lives in exactly one place.
# publish-npm.yml does NOT call this workflow; it downloads the binaries already
# attached to the GitHub Release.
on:
workflow_call:
inputs:
ref:
description: 'Git ref (tag/branch/sha) to build. Blank uses the caller ref.'
required: false
type: string
default: ''
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.os }}-${{ matrix.cpu }}
timeout-minutes: 30
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Both macOS arches build on the arm64 runner; the macOS toolchain
# cross-compiles x86_64 natively, so no (retired) Intel runner is needed.
- { os: darwin, cpu: arm64, runner: macos-14, target: aarch64-apple-darwin }
- { os: darwin, cpu: x64, runner: macos-14, target: x86_64-apple-darwin }
- { os: linux, cpu: x64, runner: ubuntu-latest, target: x86_64-unknown-linux-musl }
- { os: linux, cpu: arm64, runner: ubuntu-24.04-arm, target: aarch64-unknown-linux-musl }
- { os: win32, cpu: x64, runner: windows-latest, target: x86_64-pc-windows-msvc }
- { os: win32, cpu: arm64, runner: windows-11-arm, target: aarch64-pc-windows-msvc }
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@1.95.0
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
# The atlas viewer (viz/dist/index.html) is embedded into the binary by
# crates/cli/build.rs for `coregraph viz`. Build it before cargo so
# release binaries ship the real viewer, not the placeholder page.
- name: Set up Node for the atlas viewer
uses: actions/setup-node@v4
with:
node-version: 22
- name: Build atlas viewer
shell: bash
working-directory: viz
run: |
npm ci
npm run build
- name: Install musl toolchain
if: contains(matrix.target, 'musl')
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
# Point the cc crate (tree-sitter C sources) and the Rust linker at
# musl-gcc for this target so the binary links statically.
T="${{ matrix.target }}"
echo "CC_${T//-/_}=musl-gcc" >> "$GITHUB_ENV"
LINK_KEY="CARGO_TARGET_$(echo "$T" | tr 'a-z-' 'A-Z_')_LINKER"
echo "${LINK_KEY}=musl-gcc" >> "$GITHUB_ENV"
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} -p coregraph
- name: Stage binary
shell: bash
run: |
mkdir -p artifact
if [[ "${{ matrix.os }}" == "win32" ]]; then
cp "target/${{ matrix.target }}/release/coregraph.exe" "artifact/coregraph.exe"
else
cp "target/${{ matrix.target }}/release/coregraph" "artifact/coregraph"
fi
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: bin-${{ matrix.os }}-${{ matrix.cpu }}
path: artifact/
if-no-files-found: error