Skip to content

Update addon package files (#45) #68

Update addon package files (#45)

Update addon package files (#45) #68

Workflow file for this run

name: CI
on:
push:
branches:
- main
paths-ignore:
- '**.md'
env:
BINDING_NAME: highs_addon
NAPI_VERSION: 8
jobs:
test:
name: Test
timeout-minutes: 10
runs-on: ubuntu-latest
outputs:
tagged: ${{ format(steps.check-version.outputs.exists == 'false') }}
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1.2
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Set up Node
uses: actions/setup-node@v3
with:
cache: pnpm
registry-url: https://npm.pkg.github.com
- name: Install
run: pnpm i --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_RO_TOKEN }}
- name: Lint
run: pnpm run lint
- name: Build addon binding
run: |
pnpm -F highs-addon run build \
--CDCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Test
run: pnpm t
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: out/coverage
- name: Extract version
id: extract-version
run: |
version="$(node -p 'require("./package.json").version')"
echo "version=$version" >>"$GITHUB_OUTPUT"
- name: Check if tag exists
uses: mukunku/tag-exists-action@v1.1.0
id: check-version
with:
tag: v${{ steps.extract-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
if: steps.check-version.outputs.exists == 'false'
uses: pkgdeps/git-tag-action@v2
with:
git_commit_sha: ${{ github.sha }}
git_tag_prefix: v
github_repo: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ steps.extract-version.outputs.version }}
prebuild-native:
strategy:
matrix:
include:
- key: linux-x64
os: ubuntu-22.04
- key: darwin-x64
os: macos-12
# TODO: darwin-arm64 (https://github.com/github/roadmap/issues/528)
name: Prebuild ${{ matrix.key }}
timeout-minutes: 25
runs-on: ${{ matrix.os }}
needs: test
if: needs.test.outputs.tagged == 'true'
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Set up Node
uses: actions/setup-node@v3
with:
cache: pnpm
registry-url: https://npm.pkg.github.com
- name: Install
run: pnpm i
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_RO_TOKEN }}
- name: Generate addon prebuild
run: |
pnpm -F highs-addon exec pkg-prebuilds-copy \
--napi_version=$NAPI_VERSION \
--source build/Release/$BINDING_NAME.node \
--name=$BINDING_NAME \
--strip
- name: Upload prebuild
uses: actions/upload-artifact@v3
with:
name: native-${{ matrix.key }}-prebuilds
path: packages/highs-addon/prebuilds
retention-days: 1
prebuild-docker:
strategy:
matrix:
include:
- key: linux-x64-musl
image: node:18-alpine
platform: linux/amd64
libc: musl
- key: linux-arm64
image: node:18
platform: linux/arm64
libc: glibc
- key: linux-arm64-musl
image: node:18-alpine
platform: linux/arm64
libc: musl
name: Prebuild ${{ matrix.key }}
timeout-minutes: 90
runs-on: ubuntu-latest
needs: test
if: needs.test.outputs.tagged == 'true'
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Set up Node
uses: actions/setup-node@v3
with:
cache: pnpm
registry-url: https://npm.pkg.github.com
- name: Install
run: pnpm i --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_RO_TOKEN }}
- name: Generate addon prebuild via Docker
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.image }}
options: >-
--platform=${{ matrix.platform }}
-v ${{ github.workspace }}:/workspace
-e NAPI_VERSION
-e BINDING_NAME
run: |
if command -v apk; then
apk update
apk add clang clang-dev cmake gcc git g++ libc-dev libstdc++ linux-headers make
elif command -v apt-get; then
apt-get update
apt-get -y install cmake
fi
cd workspace/packages/highs-addon
npm run build
npm exec pkg-prebuilds-copy -- \
--napi_version=$NAPI_VERSION \
--source build/Release/$BINDING_NAME.node \
--name=$BINDING_NAME \
--libc=${{ matrix.libc }} \
--strip
- name: Upload prebuild
uses: actions/upload-artifact@v3
with:
name: docker-${{ matrix.key }}-prebuilds
path: packages/highs-addon/prebuilds
retention-days: 1
publish:
name: Publish packages
timeout-minutes: 5
needs:
- prebuild-native
- prebuild-docker
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Set up Node
uses: actions/setup-node@v3
with:
cache: pnpm
registry-url: https://npm.pkg.github.com
- name: Install
run: pnpm i --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_RO_TOKEN }}
- name: Create prebuild directories
run: mkdir -p out/prebuilds packages/highs-addon/prebuilds
- name: Download prebuilds
uses: actions/download-artifact@v3
with:
path: out/prebuilds
- name: Flatten prebuilds
run: |
mv out/prebuilds/*/* packages/highs-addon/prebuilds
ls packages/highs-addon/prebuilds
- name: Point to NPM registry
uses: actions/setup-node@v3
with:
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Publish
run: pnpm -r exec pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}