From 8db505b4f7a18a4255875455569e66a21cdbe45b Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 16 Apr 2021 15:24:35 -0700 Subject: [PATCH] GitHub: add a workflow to publish a tag to NPM And remove the old copy_repo.sh used to generate libsignal-client-node. --- .github/workflows/npm.yml | 104 ++++++++++++++++++++++++++++++++++++++ node/scripts/copy_repo.sh | 41 --------------- 2 files changed, 104 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/npm.yml delete mode 100755 node/scripts/copy_repo.sh diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml new file mode 100644 index 00000000..502ac636 --- /dev/null +++ b/.github/workflows/npm.yml @@ -0,0 +1,104 @@ +name: Publish to NPM + +on: + workflow_dispatch: + inputs: + tag: + description: 'Tag' + required: true + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.tag }} + + - name: Install nightly rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + + - name: Get Node version from .nvmrc + id: get-nvm-version + shell: bash + run: echo "::set-output name=node-version::$(cat .nvmrc)" + + - uses: actions/setup-node@v2 + with: + node-version: ${{ steps.get-nvm-version.outputs.node-version }} + + - name: Verify that the Node bindings are up to date + run: rust/bridge/node/bin/gen_ts_decl.py --verify + if: matrix.os == 'ubuntu-latest' + + - run: yarn install --ignore-scripts --frozen-lockfile + + - run: npx prebuildify --napi + + - name: Upload library + uses: actions/upload-artifact@v2 + with: + name: libsignal_client (${{matrix.os}}) + path: prebuilds/* + + publish: + name: Publish + + runs-on: ubuntu-latest + + needs: build + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.tag }} + + - name: Get Node version from .nvmrc + id: get-nvm-version + shell: bash + run: echo "::set-output name=node-version::$(cat .nvmrc)" + + - uses: actions/setup-node@v2 + with: + node-version: ${{ steps.get-nvm-version.outputs.node-version }} + + - name: Download built libraries + id: download + uses: actions/download-artifact@v2 + with: + path: artifacts + + - name: Copy libraries + run: mkdir prebuilds && mv ${{ steps.download.outputs.download-path }}/*/* prebuilds && find prebuilds + + - run: yarn install --frozen-lockfile + + - run: yarn tsc + + - run: yarn lint + + - run: yarn format -c + + - name: Run yarn test + uses: GabrielBB/xvfb-action@v1.4 + with: + # The tests use an Electron-based runner, so we need to set up a dummy display for them. + run: yarn test + + - name: Publish to NPM + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} + access: "public" diff --git a/node/scripts/copy_repo.sh b/node/scripts/copy_repo.sh deleted file mode 100755 index ce19bd2a..00000000 --- a/node/scripts/copy_repo.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# -# Copyright 2021 Signal Messenger, LLC. -# SPDX-License-Identifier: AGPL-3.0-only -# - -set -euo pipefail - -SCRIPT_DIR=$(dirname "$0") -cd "${SCRIPT_DIR}"/../.. -. bin/build_helpers.sh - -# -# copy_repo.sh -# -# Copy the given node directory to the artifact repository. -# -# Example: -# libsignal-client$ node/scripts/copy_repo.sh ../libsignal-client-node -# - -mkdir -p $1 - -cp -vf package.json $1 -cp -vf node/index.ts $1 -cp -vf node/libsignal_client.d.ts $1 - -mkdir -p $1/dist -cp -vf node/dist/index.d.ts $1/dist -cp -vf node/dist/index.js $1/dist -cp -vf node/libsignal_client.d.ts $1/dist - -mkdir -p $1/build -cp -vf build/Release/libsignal_client_*.node $1/build - -# Ensure that the LICENSE file is up to date. -cp -vf ./LICENSE $1 - -# Ensure that the README.md file is up to date. -cp -vf ./README.md $1