Skip to content

Commit a17461e

Browse files
authored
Build on all supported platforms in standard CI run (#478)
* Build on all supported platforms in standard CI run * build is done in parallel with other jobs * fixed formatting, removed unneeded fields from matrix variables
1 parent 2cf0fe5 commit a17461e

File tree

3 files changed

+117
-83
lines changed

3 files changed

+117
-83
lines changed

.github/workflows/build.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag_name:
7+
description: "Tag name"
8+
required: true
9+
type: string
10+
should_upload_artifacts:
11+
description: "Should upload artifacts"
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
jobs:
17+
build:
18+
name: Build
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
include:
23+
- name: x86_64-unknown-linux-gnu
24+
os: ubuntu-22.04
25+
path: target/x86_64-unknown-linux-gnu/release/function-runner
26+
asset_name: function-runner-x86_64-linux-${{ inputs.tag_name }}
27+
shasum_cmd: sha256sum
28+
- name: aarch64-unknown-linux-gnu
29+
os: ubuntu-22.04
30+
path: target/aarch64-unknown-linux-gnu/release/function-runner
31+
asset_name: function-runner-arm-linux-${{ inputs.tag_name }}
32+
shasum_cmd: sha256sum
33+
- name: x86_64-apple-darwin
34+
os: macos-latest
35+
path: target/x86_64-apple-darwin/release/function-runner
36+
asset_name: function-runner-x86_64-macos-${{ inputs.tag_name }}
37+
shasum_cmd: shasum -a 256
38+
- name: aarch64-apple-darwin
39+
os: macos-latest
40+
path: target/aarch64-apple-darwin/release/function-runner
41+
asset_name: function-runner-arm-macos-${{ inputs.tag_name }}
42+
shasum_cmd: shasum -a 256
43+
- name: x86_64-pc-windows-msvc
44+
os: windows-latest
45+
path: target\x86_64-pc-windows-msvc\release\function-runner.exe
46+
asset_name: function-runner-x86_64-windows-${{ inputs.tag_name }}
47+
shasum_cmd: sha256sum
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Install cross compiler
53+
if: ${{ matrix.name == 'aarch64-unknown-linux-gnu' }}
54+
run: |
55+
sudo apt-get update
56+
sudo apt-get install -y gcc-aarch64-linux-gnu
57+
58+
- name: Set up cross compiler env variables
59+
if: ${{ matrix.name == 'aarch64-unknown-linux-gnu' }}
60+
run: |
61+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
62+
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
63+
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
64+
65+
- name: Install target
66+
run: rustup target add ${{ matrix.name }}
67+
68+
- name: Build ${{ matrix.name }}
69+
run: cargo build --release --target ${{ matrix.name }} --package function-runner
70+
71+
- name: Archive assets
72+
if: ${{ inputs.should_upload_artifacts }}
73+
run: gzip -k -f ${{ matrix.path }} && mv ${{ matrix.path }}.gz ${{ matrix.asset_name }}.gz
74+
75+
- name: Upload assets to artifacts
76+
if: ${{ inputs.should_upload_artifacts }}
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ matrix.asset_name }}.gz
80+
path: ${{ matrix.asset_name }}.gz
81+
82+
- name: Generate asset hash
83+
if: ${{ inputs.should_upload_artifacts }}
84+
run: ${{ matrix.shasum_cmd }} ${{ matrix.asset_name }}.gz | awk '{ print $1 }' > ${{ matrix.asset_name }}.gz.sha256
85+
86+
- name: Upload asset hash to artifacts
87+
if: ${{ inputs.should_upload_artifacts }}
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: ${{ matrix.asset_name }}.gz.sha256
91+
path: ${{ matrix.asset_name }}.gz.sha256

.github/workflows/publish.yml

Lines changed: 18 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -12,90 +12,27 @@ on:
1212
type: string
1313

1414
jobs:
15-
compile:
16-
name: Compile
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
matrix:
20-
include:
21-
- 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
24-
asset_name: function-runner-x86_64-linux-${{ inputs.tag_name || github.event.release.tag_name }}
25-
shasum_cmd: sha256sum
26-
target: x86_64-unknown-linux-gnu
27-
- 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
30-
asset_name: function-runner-arm-linux-${{ inputs.tag_name || github.event.release.tag_name }}
31-
shasum_cmd: sha256sum
32-
target: aarch64-unknown-linux-gnu
33-
- name: macos
34-
os: macos-latest
35-
path: target/x86_64-apple-darwin/release/function-runner
36-
asset_name: function-runner-x86_64-macos-${{ inputs.tag_name || github.event.release.tag_name }}
37-
shasum_cmd: shasum -a 256
38-
target: x86_64-apple-darwin
39-
- name: arm64-macos
40-
os: macos-latest
41-
path: target/aarch64-apple-darwin/release/function-runner
42-
asset_name: function-runner-arm-macos-${{ inputs.tag_name || github.event.release.tag_name }}
43-
shasum_cmd: shasum -a 256
44-
target: aarch64-apple-darwin
45-
- name: windows
46-
os: windows-latest
47-
path: target\x86_64-pc-windows-msvc\release\function-runner.exe
48-
asset_name: function-runner-x86_64-windows-${{ inputs.tag_name || github.event.release.tag_name }}
49-
shasum_cmd: sha256sum
50-
target: x86_64-pc-windows-msvc
51-
15+
build:
16+
uses: ./.github/workflows/build.yml
17+
with:
18+
tag_name: ${{ inputs.tag_name || github.event.release.tag_name }}
19+
should_upload_artifacts: true
20+
21+
publish:
22+
name: Publish
23+
needs: build
24+
runs-on: ubuntu-latest
5225
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-
75-
- name: Archive assets
76-
run: gzip -k -f ${{ matrix.path }} && mv ${{ matrix.path }}.gz ${{ matrix.asset_name }}.gz
77-
78-
- name: Upload assets to artifacts
79-
uses: actions/upload-artifact@v4
26+
- name: Download all artifacts
27+
uses: actions/download-artifact@v4
8028
with:
81-
name: ${{ matrix.asset_name }}.gz
82-
path: ${{ matrix.asset_name }}.gz
29+
path: artifacts
8330

8431
- name: Upload assets to release
8532
env:
8633
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87-
run: gh release upload ${{ inputs.tag_name || github.event.release.tag_name }} ${{ matrix.asset_name }}.gz
88-
89-
- name: Generate asset hash
90-
run: ${{ matrix.shasum_cmd }} ${{ matrix.asset_name }}.gz | awk '{ print $1 }' > ${{ matrix.asset_name }}.gz.sha256
91-
92-
- name: Upload asset hash to artifacts
93-
uses: actions/upload-artifact@v4
94-
with:
95-
name: ${{ matrix.asset_name }}.gz.sha256
96-
path: ${{ matrix.asset_name }}.gz.sha256
97-
98-
- name: Upload asset hash to release
99-
env:
100-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101-
run: gh release upload ${{ inputs.tag_name || github.event.release.tag_name }} ${{ matrix.asset_name }}.gz.sha256
34+
run: |
35+
# Upload all files from the build job
36+
for file in artifacts/*; do
37+
gh release upload ${{ inputs.tag_name || github.event.release.tag_name }} $file
38+
done

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
check:
@@ -48,3 +48,9 @@ jobs:
4848
toolchain: stable
4949
components: clippy
5050
- run: cargo clippy -- -D warnings
51+
52+
build:
53+
name: Build
54+
uses: ./.github/workflows/build.yml
55+
with:
56+
tag_name: "ci-build"

0 commit comments

Comments
 (0)