From 4932a5e979a28ff4fb6ebdd5719ce59be84c3e57 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Sun, 20 Apr 2025 16:23:28 +0100 Subject: [PATCH 1/2] chore: typo --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 364934486..5e1625f1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - # fetch submodules recusively, to get zig-js-runtime submodules also. + # fetch submodules recursively, to get zig-js-runtime submodules also. submodules: recursive - uses: ./.github/actions/install @@ -54,7 +54,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - # fetch submodules recusively, to get zig-js-runtime submodules also. + # fetch submodules recursively, to get zig-js-runtime submodules also. submodules: recursive - uses: ./.github/actions/install @@ -86,7 +86,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - # fetch submodules recusively, to get zig-js-runtime submodules also. + # fetch submodules recursively, to get zig-js-runtime submodules also. submodules: recursive - uses: ./.github/actions/install @@ -118,7 +118,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - # fetch submodules recusively, to get zig-js-runtime submodules also. + # fetch submodules recursively, to get zig-js-runtime submodules also. submodules: recursive - uses: ./.github/actions/install From 60156898f947cb3f1df81c68e4f48cab7a4367cb Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Sun, 20 Apr 2025 16:39:41 +0100 Subject: [PATCH 2/2] 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. --- .github/workflows/build.yml | 148 ++++++++++++------------------------ 1 file changed, 48 insertions(+), 100 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e1625f1b..9587e50ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,44 +11,28 @@ permissions: contents: write jobs: - build-linux-x86_64: + build: + strategy: + matrix: + include: + - os: linux + arch: x86_64 + runner: ubuntu-22.04 + - os: linux + arch: aarch64 + runner: ubuntu-latest # Use a runner that supports ARM64, like ubuntu-latest or a self-hosted one + - os: macos + arch: aarch64 + runner: macos-latest # macos-latest is typically ARM64 + - os: macos + arch: x86_64 + runner: macos-13 # Specify an x86_64 runner if needed + + runs-on: ${{ matrix.runner }} env: - ARCH: x86_64 - OS: linux - - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # fetch submodules recursively, to get zig-js-runtime submodules also. - submodules: recursive - - - uses: ./.github/actions/install - with: - os: ${{env.OS}} - arch: ${{env.ARCH}} - - - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - - - name: Rename binary - run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} - - - name: Upload the build - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} - tag: nightly - - build-linux-aarch64: - env: - ARCH: aarch64 - OS: linux - - runs-on: ubuntu-24.04-arm + ARCH: ${{ matrix.arch }} + OS: ${{ matrix.os }} + ARTIFACT_NAME: lightpanda-${{ matrix.arch }}-${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -59,82 +43,46 @@ jobs: - uses: ./.github/actions/install with: - os: ${{env.OS}} - arch: ${{env.ARCH}} - - - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - - - name: Rename binary - run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} - - - name: Upload the build - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} - tag: nightly - - build-macos-aarch64: - env: - ARCH: aarch64 - OS: macos + os: ${{ env.OS }} + arch: ${{ env.ARCH }} - runs-on: macos-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # fetch submodules recursively, to get zig-js-runtime submodules also. - submodules: recursive - - - uses: ./.github/actions/install - with: - os: ${{env.OS}} - arch: ${{env.ARCH}} + - name: Set Git SHA Short Env Var + id: vars + run: echo "GIT_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=${{ env.GIT_SHA_SHORT }} - name: Rename binary - run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} + run: mv zig-out/bin/lightpanda ${{ env.ARTIFACT_NAME }} - - name: Upload the build - uses: ncipollo/release-action@v1 + - name: Upload build artifact + uses: actions/upload-artifact@v4 with: - allowUpdates: true - artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} - tag: nightly - - build-macos-x86_64: - env: - ARCH: x86_64 - OS: macos - - runs-on: macos-13 + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_NAME }} + release: + needs: build + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Download all artifacts + uses: actions/download-artifact@v4 with: - fetch-depth: 0 - # fetch submodules recursively, to get zig-js-runtime submodules also. - submodules: recursive - - - uses: ./.github/actions/install - with: - os: ${{env.OS}} - arch: ${{env.ARCH}} + path: artifacts # Downloads all artifacts into the 'artifacts' directory - - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - - - name: Rename binary - run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} + - name: Generate checksums + working-directory: artifacts + # Find all artifact directories (one per build job) and checksum the file inside each + run: find . -mindepth 2 -type f -exec sha256sum {} + | tee checksums.txt - - name: Upload the build + - name: Upload binaries and checksums to release uses: ncipollo/release-action@v1 with: allowUpdates: true - artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} + # List all expected artifact files plus the checksum file + artifacts: artifacts/*/lightpanda-*, artifacts/checksums.txt + # If download-artifact@v4 downloads directly without subfolders: + # artifacts: artifacts/lightpanda-*, artifacts/checksums.txt tag: nightly + token: ${{ secrets.GITHUB_TOKEN }} # Explicitly pass token