Publish tdl #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish tdl | |
# This workflow can be executed using a command like this: | |
# gh workflow run publish-tdl.yml --ref develop -f npm-tag=latest | |
on: | |
workflow_dispatch: | |
inputs: | |
npm-tag: | |
description: 'npm tag (e.g. latest, beta), required to publish' | |
type: string | |
required: false | |
jobs: | |
build-and-test: | |
name: Build the node addon on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
cache: npm | |
- name: Install dependencies | |
run: npm install | |
- name: Clean old binaries | |
run: npm run clean -w tdl | |
- name: Prebuildify in docker | |
if: runner.os == 'Linux' | |
run: | | |
# docker run -u root -v $(pwd):/app ghcr.io/prebuild/centos7-devtoolset7:2 \ | |
# npm run make-prebuild -w tdl -- --tag-libc | |
cat > prebuilt-node-addon.sh <<EOF | |
set -e | |
source /hbb_shlib/activate | |
export CFLAGS="-fvisibility=hidden -I/hbb_shlib/include" | |
export CXXFLAGS="$CFLAGS" | |
export LDFLAGS="-L/hbb_shlib/lib" | |
export STATICLIB_CFLAGS="$CFLAGS -fPIC" | |
export STATICLIB_CXXFLAGS="$STATICLIB_CFLAGS" | |
export SHLIB_CFLAGS="$CFLAGS" | |
export SHLIB_CXXFLAGS="$SHLIB_CFLAGS" | |
export SHLIB_LDFLAGS="$LDFLAGS" | |
set -x | |
yum install https://rpm.nodesource.com/pub_16.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y | |
yum install python3 nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1 | |
cd /app | |
npm run make-prebuild -w tdl -- --tag-libc | |
export LIBCHECK_ALLOW='libstdc\+\+' | |
libcheck packages/tdl/prebuilds/*/*.node | |
EOF | |
docker run -v $(pwd):/app ghcr.io/phusion/holy-build-box/hbb-64 \ | |
bash /app/prebuilt-node-addon.sh | |
ldd packages/tdl/prebuilds/*/*.node | |
du -hs packages/tdl/prebuilds/*/*.node | |
- name: Prebuildify | |
if: runner.os != 'Linux' | |
run: npm run make-prebuild -w tdl | |
- name: "Prebuildify: Crosscompile to arm64 Apple Silicon" | |
if: runner.os == 'macOS' | |
run: npm run make-prebuild -w tdl -- --arch arm64 | |
- name: Download prebuilt-tdlib | |
run: | | |
npm pack [email protected] | |
tar -xzvf prebuilt-tdlib-0.1008000.0.tgz | |
rm package/package.json | |
- name: Run tests | |
run: npm run test:all | |
env: | |
USE_PREBUILT: package/index.js | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: tdl-prebuilds | |
path: packages/tdl/prebuilds | |
publish: | |
name: 'Publish to npm' | |
needs: [build-and-test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
cache: npm | |
# registry-url is mandatory here | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: npm install | |
- uses: actions/download-artifact@v3 | |
with: | |
name: tdl-prebuilds | |
path: packages/tdl/prebuilds | |
- run: tree packages/tdl/prebuilds | |
- name: Ensure prebuilts exist | |
run: (( $(ls packages/tdl/prebuilds | wc -l) > 3 )) | |
- name: Tests (excluding integration tests) | |
run: npm test | |
- name: Publish | |
if: "${{ inputs.npm-tag != '' }}" | |
run: npm publish --tag ${{ inputs.npm-tag }} -w tdl | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |