mirror of
https://github.com/signalapp/libsignal.git
synced 2024-09-20 03:52:17 +02:00
152 lines
3.8 KiB
YAML
152 lines
3.8 KiB
YAML
name: Publish to NPM
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
npm_tag:
|
|
description: 'NPM tag'
|
|
required: true
|
|
default: 'latest'
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
matrix:
|
|
os: [windows-latest, macos-11]
|
|
include:
|
|
- os: macos-11
|
|
arm64-rust-target: aarch64-apple-darwin
|
|
- os: windows-latest
|
|
arm64-rust-target: aarch64-pc-windows-msvc
|
|
# This can be removed when we update to a Node version that officially supports win-arm64.
|
|
custom-arm64-dist-url: https://unofficial-builds.nodejs.org/download/release
|
|
# Ubuntu binaries are built using Docker, below
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- run: rustup toolchain install $(cat rust-toolchain) --profile minimal --target ${{ matrix.arm64-rust-target }}
|
|
|
|
# install nasm compiler for boring
|
|
- name: (Windows) Install nasm
|
|
if: startsWith(matrix.os, 'windows')
|
|
run: choco install nasm
|
|
shell: cmd
|
|
|
|
- run: choco install protoc
|
|
if: startsWith(matrix.os, 'windows')
|
|
|
|
- run: brew install protobuf
|
|
if: startsWith(matrix.os, 'macos')
|
|
|
|
- name: Get Node version from .nvmrc
|
|
id: get-nvm-version
|
|
shell: bash
|
|
run: echo "node-version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
|
|
- run: npx yarn install --ignore-scripts --frozen-lockfile
|
|
working-directory: node
|
|
|
|
- name: Build for arm64
|
|
run: npx prebuildify --napi -t ${{ steps.get-nvm-version.outputs.node-version }} --arch arm64
|
|
working-directory: node
|
|
env:
|
|
npm_config_dist_url: ${{ matrix.custom-arm64-dist-url }}
|
|
|
|
- name: Build for the host (should be x64)
|
|
run: npx prebuildify --napi -t ${{ steps.get-nvm-version.outputs.node-version }}
|
|
working-directory: node
|
|
|
|
- name: Upload library
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: libsignal_client (${{matrix.os}})
|
|
path: node/prebuilds/*
|
|
|
|
build-docker:
|
|
name: Build (Ubuntu via Docker)
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- run: node/docker-prebuildify.sh
|
|
|
|
- name: Upload library
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: libsignal_client (ubuntu-docker)
|
|
path: node/prebuilds/*
|
|
|
|
verify-rust:
|
|
name: Verify Node bindings
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- run: rustup toolchain install $(cat rust-toolchain) --profile minimal
|
|
|
|
- run: sudo apt-get update && sudo apt-get install protobuf-compiler
|
|
|
|
- name: Verify that the Node bindings are up to date
|
|
run: rust/bridge/node/bin/gen_ts_decl.py --verify
|
|
|
|
publish:
|
|
name: Publish
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [build, build-docker, verify-rust]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
registry-url: 'https://registry.npmjs.org/'
|
|
|
|
- name: Download built libraries
|
|
id: download
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Copy libraries
|
|
run: mkdir node/prebuilds && mv ${{ steps.download.outputs.download-path }}/*/* node/prebuilds && find node/prebuilds
|
|
|
|
- run: yarn install --frozen-lockfile
|
|
working-directory: node
|
|
|
|
- run: yarn tsc
|
|
working-directory: node
|
|
|
|
- run: yarn lint
|
|
working-directory: node
|
|
|
|
- run: yarn format -c
|
|
working-directory: node
|
|
|
|
- run: yarn test
|
|
working-directory: node
|
|
env:
|
|
PREBUILDS_ONLY: 1
|
|
|
|
- run: npm publish --tag ${{ github.event.inputs.npm_tag }} --access public
|
|
working-directory: node
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|