Skip to content

Commit

Permalink
Add linux-x64-musl, linux-arm-libc, linux-arm-musl builds (#7)
Browse files Browse the repository at this point in the history
Add three new supported build targets:

- linux-x64-musl
- linux-arm-libc
- linux-arm-musl

To support the alternate libcs, I've added `--tag-libc` to all prebuildify invocations. [docs here](https://www.npmjs.com/package/prebuildify#options)
  • Loading branch information
llimllib authored Jun 5, 2024
1 parent 3ad4e84 commit 4722bfc
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
test
45 changes: 40 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,46 @@ jobs:
sudo apt-get update && \
sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3
npm ci
npx prebuildify --napi --strip -t "$(node --version | tr -d 'v')"
npx prebuildify --napi --strip --tag-libc -t "$(node --version | tr -d 'v')"
- uses: actions/upload-artifact@v4
with:
name: prebuild-${{ runner.os }}-${{ runner.arch }}
path: prebuilds
path: ./prebuilds
retention-days: 14

cross-compile:
name: "cross compile linux/arm"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- name: build linux glibc arm
run: |
docker build --platform=linux/arm64 --tag nodegit-linux-glibc-arm64 -f scripts/Dockerfile.debian .
docker create --platform=linux/arm64 --name nodegit-linux-glibc-arm64 nodegit-linux-glibc-arm64
docker cp "nodegit-linux-glibc-arm64:/app/prebuilds" .
- name: build linux musl x64
run: |
docker build --platform=linux/amd64 --tag nodegit-linux-musl-amd64 -f scripts/Dockerfile.alpine .
docker create --platform=linux/amd64 --name nodegit-linux-musl-amd64 nodegit-linux-musl-amd64
docker cp "nodegit-linux-musl-amd64:/app/prebuilds" .
- name: build linux musl arm
run: |
docker build --platform=linux/arm64 --tag nodegit-linux-musl-arm64 -f scripts/Dockerfile.alpine .
docker create --platform=linux/arm64 --name nodegit-linux-musl-arm64 nodegit-linux-musl-arm64
docker cp "nodegit-linux-musl-arm64:/app/prebuilds" .
- name: "list the generated files"
run: find prebuilds
- uses: actions/upload-artifact@v4
with:
name: prebuild-linux-arm64
path: ./prebuilds
retention-days: 14

# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
publish:
runs-on: ubuntu-latest
needs: [build]
needs: [build, cross-compile]
permissions:
id-token: write
steps:
Expand All @@ -71,13 +100,19 @@ jobs:
- name: copy libs
run: |
set -x
mkdir -p prebuilds/linux-arm64
mkdir -p prebuilds/linux-x64
mkdir -p prebuilds/darwin-arm64
find ${{ steps.download.outputs.download-path }}
mv ${{ steps.download.outputs.download-path }}/*/* ./prebuilds
mv ${{ steps.download.outputs.download-path}}/prebuild-Linux-X64/linux-x64/* ./prebuilds/linux-x64/
mv ${{ steps.download.outputs.download-path}}/prebuild-linux-arm64/linux-arm64/* ./prebuilds/linux-arm64/
mv ${{ steps.download.outputs.download-path}}/prebuild-linux-arm64/linux-x64/* ./prebuilds/linux-x64/
mv ${{ steps.download.outputs.download-path}}/prebuild-macOS-ARM64/darwin-arm64/* ./prebuilds/darwin-arm64/
find ./prebuilds
- name: npm install
run: npm ci
- name: publish
run: |
(cat "$NPM_CONFIG_USERCONFIG" || true) && echo "token: ${NODE_AUTH_TOKEN:0:10}" && npm publish --provenance --access public
(cat "$NPM_CONFIG_USERCONFIG" || true) && npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@readme/nodegit",
"description": "Node.js libgit2 asynchronous native bindings",
"version": "1.0.0",
"version": "1.1.0-alpha.7",
"homepage": "http://nodegit.org",
"keywords": [
"libgit2",
Expand Down
9 changes: 9 additions & 0 deletions scripts/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:20.11.1-alpine3.19

RUN apk add build-base git krb5-dev libgit2-dev libssh-dev pkgconfig python3 tzdata

ADD . /app
WORKDIR /app

RUN npm ci && \
npx prebuildify --napi --strip --tag-libc -t "$(node --version | tr -d 'v')"
14 changes: 14 additions & 0 deletions scripts/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20.11.1-bullseye

ENV DEBIAN_FRONTEND noninteractive
ENV LC_ALL en_US.UTF-8
ENV LANG ${LC_ALL}

RUN apt-get update -y && \
apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3

ADD . /app
WORKDIR /app

RUN npm ci && \
npx prebuildify --napi --strip --tag-libc -t "$(node --version | tr -d 'v')"

0 comments on commit 4722bfc

Please sign in to comment.