From 4722bfce5a83be68b862e5348a6be162583d5dd5 Mon Sep 17 00:00:00 2001 From: Bill Mill Date: Wed, 5 Jun 2024 12:22:46 -0400 Subject: [PATCH] Add linux-x64-musl, linux-arm-libc, linux-arm-musl builds (#7) 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) --- .dockerignore | 2 ++ .github/workflows/publish.yml | 45 +++++++++++++++++++++++++++++++---- package-lock.json | 4 ++-- package.json | 2 +- scripts/Dockerfile.alpine | 9 +++++++ scripts/Dockerfile.debian | 14 +++++++++++ 6 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100644 scripts/Dockerfile.alpine create mode 100644 scripts/Dockerfile.debian diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..f05b1f265 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c8b796ca9..abc887ffe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: @@ -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 }} diff --git a/package-lock.json b/package-lock.json index 6a625d4ff..527a37025 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@readme/nodegit", - "version": "1.0.0", + "version": "1.1.0-alpha.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@readme/nodegit", - "version": "1.0.0", + "version": "1.1.0-alpha.7", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 2372a5bbc..c7ca1a5a6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/Dockerfile.alpine b/scripts/Dockerfile.alpine new file mode 100644 index 000000000..d0147a376 --- /dev/null +++ b/scripts/Dockerfile.alpine @@ -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')" diff --git a/scripts/Dockerfile.debian b/scripts/Dockerfile.debian new file mode 100644 index 000000000..b87f5df94 --- /dev/null +++ b/scripts/Dockerfile.debian @@ -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')"