Skip to content

Commit 908e8d7

Browse files
committed
Build on all supported platforms in standard CI run
1 parent 218f79f commit 908e8d7

3 files changed

Lines changed: 127 additions & 39 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build Binaries
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag_name:
7+
description: "Tag name for release builds"
8+
required: false
9+
type: string
10+
is_release:
11+
description: "Whether this is a release build"
12+
required: true
13+
type: boolean
14+
default: false
15+
outputs:
16+
linux_x86_64:
17+
description: "Linux x86_64 binary path"
18+
value: ${{ jobs.build.outputs.linux_x86_64 }}
19+
linux_arm64:
20+
description: "Linux ARM64 binary path"
21+
value: ${{ jobs.build.outputs.linux_arm64 }}
22+
macos_x86_64:
23+
description: "macOS x86_64 binary path"
24+
value: ${{ jobs.build.outputs.macos_x86_64 }}
25+
macos_arm64:
26+
description: "macOS ARM64 binary path"
27+
value: ${{ jobs.build.outputs.macos_arm64 }}
28+
windows_x86_64:
29+
description: "Windows x86_64 binary path"
30+
value: ${{ jobs.build.outputs.windows_x86_64 }}
31+
32+
jobs:
33+
build:
34+
name: Build
35+
runs-on: ${{ matrix.os }}
36+
outputs:
37+
linux_x86_64: ${{ steps.build.outputs.linux_x86_64 }}
38+
linux_arm64: ${{ steps.build.outputs.linux_arm64 }}
39+
macos_x86_64: ${{ steps.build.outputs.macos_x86_64 }}
40+
macos_arm64: ${{ steps.build.outputs.macos_arm64 }}
41+
windows_x86_64: ${{ steps.build.outputs.windows_x86_64 }}
42+
strategy:
43+
matrix:
44+
include:
45+
- name: linux
46+
os: ubuntu-22.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems
47+
path: target/x86_64-unknown-linux-gnu/release/function-runner
48+
asset_name: function-runner-x86_64-linux-${{ inputs.is_release && (inputs.tag_name || github.event.release.tag_name) || 'test' }}
49+
shasum_cmd: sha256sum
50+
target: x86_64-unknown-linux-gnu
51+
output_var: linux_x86_64
52+
- name: linux-arm64
53+
os: ubuntu-22.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems
54+
path: target/aarch64-unknown-linux-gnu/release/function-runner
55+
asset_name: function-runner-arm-linux-${{ inputs.is_release && (inputs.tag_name || github.event.release.tag_name) || 'test' }}
56+
shasum_cmd: sha256sum
57+
target: aarch64-unknown-linux-gnu
58+
output_var: linux_arm64
59+
- name: macos
60+
os: macos-latest
61+
path: target/x86_64-apple-darwin/release/function-runner
62+
asset_name: function-runner-x86_64-macos-${{ inputs.is_release && (inputs.tag_name || github.event.release.tag_name) || 'test' }}
63+
shasum_cmd: shasum -a 256
64+
target: x86_64-apple-darwin
65+
output_var: macos_x86_64
66+
- name: arm64-macos
67+
os: macos-latest
68+
path: target/aarch64-apple-darwin/release/function-runner
69+
asset_name: function-runner-arm-macos-${{ inputs.is_release && (inputs.tag_name || github.event.release.tag_name) || 'test' }}
70+
shasum_cmd: shasum -a 256
71+
target: aarch64-apple-darwin
72+
output_var: macos_arm64
73+
- name: windows
74+
os: windows-latest
75+
path: target\x86_64-pc-windows-msvc\release\function-runner.exe
76+
asset_name: function-runner-x86_64-windows-${{ inputs.is_release && (inputs.tag_name || github.event.release.tag_name) || 'test' }}
77+
shasum_cmd: sha256sum
78+
target: x86_64-pc-windows-msvc
79+
output_var: windows_x86_64
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- name: Install cross compiler
85+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
86+
run: |
87+
sudo apt-get update
88+
sudo apt-get install -y gcc-aarch64-linux-gnu
89+
90+
- name: Set up cross compiler env variables
91+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
92+
run: |
93+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
94+
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
95+
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
96+
97+
# Should no-op except for macos-arm case where that target won't be installed
98+
- name: Install target
99+
run: rustup target add ${{ matrix.target }}
100+
101+
- name: Build ${{ matrix.target }}
102+
id: build
103+
run: |
104+
cargo build --release --target ${{ matrix.target }} --package function-runner
105+
echo "${{ matrix.output_var }}=${{ matrix.path }}" >> $GITHUB_OUTPUT

.github/workflows/publish.yml

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,66 +12,42 @@ on:
1212
type: string
1313

1414
jobs:
15-
compile:
16-
name: Compile
15+
build:
16+
name: Build
17+
uses: ./.github/workflows/build-binaries.yml
18+
with:
19+
tag_name: ${{ inputs.tag_name || github.event.release.tag_name }}
20+
is_release: true
21+
22+
publish:
23+
name: Publish
24+
needs: build
1725
runs-on: ${{ matrix.os }}
1826
strategy:
1927
matrix:
2028
include:
2129
- name: linux
22-
os: ubuntu-22.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems
23-
path: target/x86_64-unknown-linux-gnu/release/function-runner
30+
path: ${{ needs.build.outputs.linux_x86_64 }}
2431
asset_name: function-runner-x86_64-linux-${{ inputs.tag_name || github.event.release.tag_name }}
2532
shasum_cmd: sha256sum
26-
target: x86_64-unknown-linux-gnu
2733
- name: linux-arm64
28-
os: ubuntu-22.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems
29-
path: target/aarch64-unknown-linux-gnu/release/function-runner
34+
path: ${{ needs.build.outputs.linux_arm64 }}
3035
asset_name: function-runner-arm-linux-${{ inputs.tag_name || github.event.release.tag_name }}
3136
shasum_cmd: sha256sum
32-
target: aarch64-unknown-linux-gnu
3337
- name: macos
34-
os: macos-latest
35-
path: target/x86_64-apple-darwin/release/function-runner
38+
path: ${{ needs.build.outputs.macos_x86_64 }}
3639
asset_name: function-runner-x86_64-macos-${{ inputs.tag_name || github.event.release.tag_name }}
3740
shasum_cmd: shasum -a 256
38-
target: x86_64-apple-darwin
3941
- name: arm64-macos
40-
os: macos-latest
41-
path: target/aarch64-apple-darwin/release/function-runner
42+
path: ${{ needs.build.outputs.macos_arm64 }}
4243
asset_name: function-runner-arm-macos-${{ inputs.tag_name || github.event.release.tag_name }}
4344
shasum_cmd: shasum -a 256
44-
target: aarch64-apple-darwin
4545
- name: windows
46-
os: windows-latest
47-
path: target\x86_64-pc-windows-msvc\release\function-runner.exe
46+
path: ${{ needs.build.outputs.windows_x86_64 }}
4847
asset_name: function-runner-x86_64-windows-${{ inputs.tag_name || github.event.release.tag_name }}
4948
shasum_cmd: sha256sum
50-
target: x86_64-pc-windows-msvc
5149

5250
steps:
53-
- uses: actions/checkout@v4
54-
55-
- name: Install cross compiler
56-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
57-
run: |
58-
sudo apt-get update
59-
sudo apt-get install -y gcc-aarch64-linux-gnu
60-
61-
- name: Set up cross compiler env variables
62-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
63-
run: |
64-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
65-
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
66-
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
67-
68-
# Should no-op except for macos-arm case where that target won't be installed
69-
- name: Install target
70-
run: rustup target add ${{ matrix.target }}
71-
72-
- name: Build ${{ matrix.target }}
73-
run: cargo build --release --target ${{ matrix.target }} --package function-runner
74-
7551
- name: Archive assets
7652
run: gzip -k -f ${{ matrix.path }} && mv ${{ matrix.path }}.gz ${{ matrix.asset_name }}.gz
7753

.github/workflows/script-runner.rust.default.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,10 @@ jobs:
4848
toolchain: stable
4949
components: clippy
5050
- run: cargo clippy -- -D warnings
51+
52+
build:
53+
name: Build
54+
needs: [check, test, fmt, clippy]
55+
uses: ./.github/workflows/build-binaries.yml
56+
with:
57+
is_release: false

0 commit comments

Comments
 (0)