Skip to content

Commit 6015689

Browse files
committed
refactor(ci): consolidate build jobs using matrix & upload checksum
Refactor the GitHub Actions workflow to use a build matrix, consolidating the separate build jobs for different OS and architecture combinations (linux/x86_64, linux/aarch64, macos/aarch64, macos/x86_64). This simplifies the workflow structure and makes it easier to manage and extend build targets. Introduced a separate `release` job that depends on the matrix builds. This job downloads all build artifacts using `actions/download-artifact`, generates SHA256 checksums for them, and then uploads both the binaries and the checksum file to the 'nightly' release tag using `ncipollo/release-action`. Build artifacts are now uploaded individually per matrix job using `actions/upload-artifact` instead of directly to the release within each build job.
1 parent 4932a5e commit 6015689

File tree

1 file changed

+48
-100
lines changed

1 file changed

+48
-100
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,28 @@ permissions:
1111
contents: write
1212

1313
jobs:
14-
build-linux-x86_64:
14+
build:
15+
strategy:
16+
matrix:
17+
include:
18+
- os: linux
19+
arch: x86_64
20+
runner: ubuntu-22.04
21+
- os: linux
22+
arch: aarch64
23+
runner: ubuntu-latest # Use a runner that supports ARM64, like ubuntu-latest or a self-hosted one
24+
- os: macos
25+
arch: aarch64
26+
runner: macos-latest # macos-latest is typically ARM64
27+
- os: macos
28+
arch: x86_64
29+
runner: macos-13 # Specify an x86_64 runner if needed
30+
31+
runs-on: ${{ matrix.runner }}
1532
env:
16-
ARCH: x86_64
17-
OS: linux
18-
19-
runs-on: ubuntu-22.04
20-
21-
steps:
22-
- uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
25-
# fetch submodules recursively, to get zig-js-runtime submodules also.
26-
submodules: recursive
27-
28-
- uses: ./.github/actions/install
29-
with:
30-
os: ${{env.OS}}
31-
arch: ${{env.ARCH}}
32-
33-
- name: zig build
34-
run: zig build --release=safe -Doptimize=ReleaseSafe -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
35-
36-
- name: Rename binary
37-
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
38-
39-
- name: Upload the build
40-
uses: ncipollo/release-action@v1
41-
with:
42-
allowUpdates: true
43-
artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }}
44-
tag: nightly
45-
46-
build-linux-aarch64:
47-
env:
48-
ARCH: aarch64
49-
OS: linux
50-
51-
runs-on: ubuntu-24.04-arm
33+
ARCH: ${{ matrix.arch }}
34+
OS: ${{ matrix.os }}
35+
ARTIFACT_NAME: lightpanda-${{ matrix.arch }}-${{ matrix.os }}
5236

5337
steps:
5438
- uses: actions/checkout@v4
@@ -59,82 +43,46 @@ jobs:
5943

6044
- uses: ./.github/actions/install
6145
with:
62-
os: ${{env.OS}}
63-
arch: ${{env.ARCH}}
64-
65-
- name: zig build
66-
run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
67-
68-
- name: Rename binary
69-
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
70-
71-
- name: Upload the build
72-
uses: ncipollo/release-action@v1
73-
with:
74-
allowUpdates: true
75-
artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }}
76-
tag: nightly
77-
78-
build-macos-aarch64:
79-
env:
80-
ARCH: aarch64
81-
OS: macos
46+
os: ${{ env.OS }}
47+
arch: ${{ env.ARCH }}
8248

83-
runs-on: macos-latest
84-
85-
steps:
86-
- uses: actions/checkout@v4
87-
with:
88-
fetch-depth: 0
89-
# fetch submodules recursively, to get zig-js-runtime submodules also.
90-
submodules: recursive
91-
92-
- uses: ./.github/actions/install
93-
with:
94-
os: ${{env.OS}}
95-
arch: ${{env.ARCH}}
49+
- name: Set Git SHA Short Env Var
50+
id: vars
51+
run: echo "GIT_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
9652

9753
- name: zig build
98-
run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
54+
run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=${{ env.GIT_SHA_SHORT }}
9955

10056
- name: Rename binary
101-
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
57+
run: mv zig-out/bin/lightpanda ${{ env.ARTIFACT_NAME }}
10258

103-
- name: Upload the build
104-
uses: ncipollo/release-action@v1
59+
- name: Upload build artifact
60+
uses: actions/upload-artifact@v4
10561
with:
106-
allowUpdates: true
107-
artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }}
108-
tag: nightly
109-
110-
build-macos-x86_64:
111-
env:
112-
ARCH: x86_64
113-
OS: macos
114-
115-
runs-on: macos-13
62+
name: ${{ env.ARTIFACT_NAME }}
63+
path: ${{ env.ARTIFACT_NAME }}
11664

65+
release:
66+
needs: build
67+
runs-on: ubuntu-latest
11768
steps:
118-
- uses: actions/checkout@v4
69+
- name: Download all artifacts
70+
uses: actions/download-artifact@v4
11971
with:
120-
fetch-depth: 0
121-
# fetch submodules recursively, to get zig-js-runtime submodules also.
122-
submodules: recursive
123-
124-
- uses: ./.github/actions/install
125-
with:
126-
os: ${{env.OS}}
127-
arch: ${{env.ARCH}}
72+
path: artifacts # Downloads all artifacts into the 'artifacts' directory
12873

129-
- name: zig build
130-
run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
131-
132-
- name: Rename binary
133-
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
74+
- name: Generate checksums
75+
working-directory: artifacts
76+
# Find all artifact directories (one per build job) and checksum the file inside each
77+
run: find . -mindepth 2 -type f -exec sha256sum {} + | tee checksums.txt
13478

135-
- name: Upload the build
79+
- name: Upload binaries and checksums to release
13680
uses: ncipollo/release-action@v1
13781
with:
13882
allowUpdates: true
139-
artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }}
83+
# List all expected artifact files plus the checksum file
84+
artifacts: artifacts/*/lightpanda-*, artifacts/checksums.txt
85+
# If download-artifact@v4 downloads directly without subfolders:
86+
# artifacts: artifacts/lightpanda-*, artifacts/checksums.txt
14087
tag: nightly
88+
token: ${{ secrets.GITHUB_TOKEN }} # Explicitly pass token

0 commit comments

Comments
 (0)