Skip to content

chore: update repository url #91

chore: update repository url

chore: update repository url #91

Workflow file for this run

name: Build and publish
on:
push:
tags:
- v*
branches-ignore:
- "release-please-*"
pull_request:
paths-ignore:
# ingore release-please prs
- CHANGELOG.md
- package.json
- .release-please-manifest.json
env:
NAPI_VERSION: 7
BINDING_NAME: jpeg-turbo
MACOSX_DEPLOYMENT_TARGET: "10.13"
jobs:
build-and-test:
name: Build ${{ matrix.docker-arch || matrix.arch }} on ${{ matrix.docker-image || matrix.container || matrix.os }} ${{ matrix.libc }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# windows
- os: windows-2022
arch: x64
is-native: true
- os: windows-2022
arch: ia32
is-native: false
- os: windows-2022
arch: arm64
is-native: false
# macos
- os: macos-latest
arch: arm64
is-native: false
- os: macos-latest
arch: x64
is-native: true
# linux
- os: ubuntu-latest
arch: x64
is-native: true
docker-arch: linux/amd64
docker-image: node:18-buster
extra-copy-args: --extraFiles libturbojpeg.so.0
# linux-libc
- os: ubuntu-latest
arch: arm64
is-native: false
docker-arch: linux/arm64
docker-image: node:18-buster
extra-copy-args: --extraFiles libturbojpeg.so.0
- os: ubuntu-latest
arch: arm
is-native: false
docker-arch: linux/arm/v7
docker-image: node:18-buster
extra-copy-args: --extraFiles libturbojpeg.so.0
# linux-musl
- os: ubuntu-latest
arch: x64
is-native: false
docker-arch: linux/amd64
docker-image: node:18-alpine
libc: musl
extra-copy-args: --extraFiles libturbojpeg.so.0
steps:
- uses: actions/checkout@v4
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y yasm
- name: Install Windows dependencies
if: runner.os == 'Windows'
shell: bash
run: |
curl -o nasm.zip "https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-win64.zip"
unzip nasm.zip
echo "$PWD/nasm-2.16.03/nasm.exe" >> $GITHUB_PATH
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install nasm
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: rebuild
if: ${{ !matrix.docker-arch }}
shell: bash
run: |
corepack enable
yarn
if [ -n "${{ matrix.is-native }}" ]; then
yarn test
fi
yarn run rebuild --arch=${{ matrix.arch }}
yarn pkg-prebuilds-copy ${{ matrix.extra-copy-args }} \
--baseDir build/Release \
--source $BINDING_NAME.node \
--name=$BINDING_NAME \
--strip \
--napi_version=$NAPI_VERSION \
--arch=${{ matrix.arch }}
env:
CI: true
npm_config_build_from_source: true
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ matrix.docker-arch && env.dockerhub_username != '' }}
env:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: matrix.docker-arch
- name: Pre-fetch image
if: matrix.docker-arch
run: docker pull ${{ matrix.docker-image }} --platform=${{ matrix.docker-arch }}
- name: rebuild (in docker)
uses: addnab/docker-run-action@v3
if: matrix.docker-arch
with:
image: ${{ matrix.docker-image }}
# shell: bash
options: --platform=${{ matrix.docker-arch }} -v ${{ github.workspace }}:/work -e CI=1 -e npm_config_build_from_source=1 -e NAPI_VERSION -e BINDING_NAME
run: |
if command -v apt-get &> /dev/null
then
echo "deb http://archive.debian.org/debian buster-backports main contrib non-free" | tee -a /etc/apt/sources.list.d/backports.list
apt update
apt install -y cmake/buster-backports yasm
elif command -v apk &> /dev/null
then
apk update
apk add cmake make g++ gcc yasm
fi
cd /work
corepack enable
yarn
yarn test
yarn pkg-prebuilds-copy ${{ matrix.extra-copy-args }} \
--baseDir build/Release \
--source $BINDING_NAME.node \
--name=$BINDING_NAME \
--strip \
--napi_version=$NAPI_VERSION \
--arch=${{ matrix.arch }} \
--libc=${{ matrix.libc }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.libc }}-prebuilds
path: prebuilds
retention-days: 1
bundle:
name: Bundle prebuilds
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: tmp
- name: Display structure of downloaded files
run: |
mkdir prebuilds
mv tmp/*/* prebuilds/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: all-prebuilds
path: prebuilds
retention-days: 7
publish:
name: Publish to npm
needs: bundle
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
# only run for tags
if: contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Check release is desired
id: do-publish
run: |
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
echo "No Token"
else
corepack enable
PUBLISHED_VERSION=$(yarn npm info --json . | jq -c '.version' -r)
THIS_VERSION=$(node -p "require('./package.json').version")
# Simple bash helper to comapre version numbers
verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
verlt() {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
if verlt $PUBLISHED_VERSION $THIS_VERSION
then
echo "Publishing latest"
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "Publishing hotfix"
echo "tag=hotfix" >> $GITHUB_OUTPUT
fi
fi
- name: Install Linux dependencies
if: ${{ steps.do-publish.outputs.tag }}
run: |
sudo apt-get update
sudo apt-get install -y yasm
- name: Prepare build
if: ${{ steps.do-publish.outputs.tag }}
run: |
corepack enable
yarn install
env:
CI: true
- uses: actions/download-artifact@v4
with:
name: all-prebuilds
path: prebuilds
- name: Publish to NPM
if: ${{ steps.do-publish.outputs.tag }}
run: |
npm set "//registry.npmjs.org/:_authToken" "$NPM_AUTH_TOKEN"
npm publish --access=public --tag ${{ steps.do-publish.outputs.tag }} --provenance
NEW_VERSION=$(node -p "require('./package.json').version")
echo "**Published:** $NEW_VERSION" >> $GITHUB_STEP_SUMMARY
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
CI: true