Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build

on:
pull_request:
push:
branches:
- master
- backport/*
workflow_call:
inputs:
upload-artifacts:
description: Upload prebuilds for a release. Pull request runs only compile.
type: boolean
default: false

jobs:
build:
name: build
strategy:
matrix:
node: [22, 24, 26]
os:
# https://github.com/actions/runner-images#available-images
- name: darwin
host: macos-26 #arm64

# macos-15-intel is the last intel image and will go out of service
# in fall 2027
- name: mac-x64
host: macos-15-intel

# ubuntu-22.04 is x86
- name: linux
host: ubuntu-22.04

- name: linux-arm
host: ubuntu-22.04-arm
env:
CC: clang
CXX: clang++
npm_config_clang: 1
GYP_DEFINES: use_obsolete_asm=true
runs-on: ${{ matrix.os.host }}
steps:
- uses: actions/checkout@v5
with:
submodules: true
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Prebuildify
run: |
if [[ $(uname -o) == *Linux ]]; then
sudo apt-get update
sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev lsb-release gnupg
# Node 24+ headers use C++20 std::source_location, which needs
# clang >= 16; ubuntu 22.04 ships clang 14. Stay on 22.04 (rather
# than a newer runner) to keep the glibc 2.35 prebuild baseline.
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
export CC=clang-18
export CXX=clang++-18
fi

npm ci
JOBS=2 npx prebuildify --strip --napi=false --tag-libc -t "$(node --version | tr -d 'v')"
- uses: actions/upload-artifact@v4
if: ${{ inputs.upload-artifacts }}
with:
name: prebuild-${{ runner.os }}-${{ runner.arch }}-node${{ matrix.node }}
path: ./prebuilds
retention-days: 14

# musl build still needs QEMU since there are no native Alpine/musl runners
cross-compile-musl-amd64:
name: "cross compile linux/amd64-musl"
runs-on: ubuntu-22.04
strategy:
matrix:
node: [22, 24, 26]
steps:
- uses: actions/checkout@v5
- uses: docker/setup-qemu-action@v3
- name: build linux musl amd64
run: |
docker build --platform=linux/amd64 --build-arg NODE_VERSION=${{ matrix.node }} --tag nodegit-linux-musl-amd64-node${{ matrix.node }} -f scripts/Dockerfile.alpine .
docker create --platform=linux/amd64 --name nodegit-linux-musl-amd64-node${{ matrix.node }} nodegit-linux-musl-amd64-node${{ matrix.node }}
docker cp "nodegit-linux-musl-amd64-node${{ matrix.node }}:/app/prebuilds" .
- name: "list the generated files"
run: find prebuilds
- uses: actions/upload-artifact@v4
if: ${{ inputs.upload-artifacts }}
with:
name: prebuild-linux-musl-amd64-node${{ matrix.node }}
path: ./prebuilds
retention-days: 14

cross-compile-musl-arm64:
name: "build linux/arm64-musl"
runs-on: ubuntu-22.04-arm
strategy:
matrix:
node: [22, 24, 26]
steps:
- uses: actions/checkout@v5
- name: build linux musl arm64
run: |
docker build --platform=linux/arm64 --build-arg NODE_VERSION=${{ matrix.node }} --tag nodegit-linux-musl-arm64-node${{ matrix.node }} -f scripts/Dockerfile.alpine .
docker create --platform=linux/arm64 --name nodegit-linux-musl-arm64-node${{ matrix.node }} nodegit-linux-musl-arm64-node${{ matrix.node }}
docker cp "nodegit-linux-musl-arm64-node${{ matrix.node }}:/app/prebuilds" .
- name: "list the generated files"
run: find prebuilds
- uses: actions/upload-artifact@v4
if: ${{ inputs.upload-artifacts }}
with:
name: prebuild-linux-musl-arm64-node${{ matrix.node }}
path: ./prebuilds
retention-days: 14
110 changes: 7 additions & 103 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Publish

on:
push:
tags:
Expand All @@ -6,113 +8,15 @@ on:

jobs:
build:
# TODO: should we run the tests, or can we assume that a v* tag ought to
# get published?
name: build
strategy:
matrix:
node: [22, 24, 26]
os:
# https://github.com/actions/runner-images#available-images
- name: darwin
host: macos-26 #arm64

# macos-15-intel is the last intel image and will go out of service
# in fall 2027
- name: mac-x64
host: macos-15-intel

# ubuntu-22.04 is x86
- name: linux
host: ubuntu-22.04

- name: linux-arm
host: ubuntu-22.04-arm
env:
CC: clang
CXX: clang++
npm_config_clang: 1
GYP_DEFINES: use_obsolete_asm=true
runs-on: ${{ matrix.os.host }}
steps:
- uses: actions/checkout@v5
with:
submodules: true
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Prebuildify
run: |
if [[ $(uname -o) == *Linux ]]; then
sudo apt-get update
sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 zlib1g-dev lsb-release gnupg
# Node 24+ headers use C++20 std::source_location, which needs
# clang >= 16; ubuntu 22.04 ships clang 14. Stay on 22.04 (rather
# than a newer runner) to keep the glibc 2.35 prebuild baseline.
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
export CC=clang-18
export CXX=clang++-18
fi

npm ci
JOBS=2 npx prebuildify --strip --napi=false --tag-libc -t "$(node --version | tr -d 'v')"
- uses: actions/upload-artifact@v4
with:
name: prebuild-${{ runner.os }}-${{ runner.arch }}-node${{ matrix.node }}
path: ./prebuilds
retention-days: 14

# musl build still needs QEMU since there are no native Alpine/musl runners
cross-compile-musl-amd64:
name: "cross compile linux/amd64-musl"
runs-on: ubuntu-22.04
strategy:
matrix:
node: [22, 24, 26]
steps:
- uses: actions/checkout@v5
- uses: docker/setup-qemu-action@v3
- name: build linux musl amd64
run: |
docker build --platform=linux/amd64 --build-arg NODE_VERSION=${{ matrix.node }} --tag nodegit-linux-musl-amd64-node${{ matrix.node }} -f scripts/Dockerfile.alpine .
docker create --platform=linux/amd64 --name nodegit-linux-musl-amd64-node${{ matrix.node }} nodegit-linux-musl-amd64-node${{ matrix.node }}
docker cp "nodegit-linux-musl-amd64-node${{ matrix.node }}:/app/prebuilds" .
- name: "list the generated files"
run: find prebuilds
- uses: actions/upload-artifact@v4
with:
name: prebuild-linux-musl-amd64-node${{ matrix.node }}
path: ./prebuilds
retention-days: 14

cross-compile-musl-arm64:
name: "build linux/arm64-musl"
runs-on: ubuntu-22.04-arm
strategy:
matrix:
node: [22, 24, 26]
steps:
- uses: actions/checkout@v5
- name: build linux musl arm64
run: |
docker build --platform=linux/arm64 --build-arg NODE_VERSION=${{ matrix.node }} --tag nodegit-linux-musl-arm64-node${{ matrix.node }} -f scripts/Dockerfile.alpine .
docker create --platform=linux/arm64 --name nodegit-linux-musl-arm64-node${{ matrix.node }} nodegit-linux-musl-arm64-node${{ matrix.node }}
docker cp "nodegit-linux-musl-arm64-node${{ matrix.node }}:/app/prebuilds" .
- name: "list the generated files"
run: find prebuilds
- uses: actions/upload-artifact@v4
with:
name: prebuild-linux-musl-arm64-node${{ matrix.node }}
path: ./prebuilds
retention-days: 14
uses: ./.github/workflows/build.yml
with:
upload-artifacts: true

# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
publish:
name: publish
runs-on: ubuntu-latest
needs: [build, cross-compile-musl-amd64, cross-compile-musl-arm64]
needs: build
permissions:
id-token: write
contents: read
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Tests

on:
push:
branches:
Expand Down
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ Tests are located in:
## CI/CD

GitHub Actions workflows:
- **tests.yml**: Runs tests on Ubuntu 22.04 and macOS-26 across Node 22, 24, and 26
- **publish.yml**: Handles package publishing
- **build.yml** (Build): Compiles native prebuilds for Node 22, 24, and 26 on every pull request and on pushes to `master` and `backport/*`. Those runs do not upload artifacts.
- **tests.yml** (Tests): Runs tests on Ubuntu 22.04 and macOS-26 across Node 22, 24, and 26
- **publish.yml** (Publish): Calls the Build workflow with artifact upload enabled, then publishes the package for `v*` tags

## Architecture

Expand Down
Loading