Skip to content

Merge pull request #35 from iamriajul/fix/npm-latest-release-tag #17

Merge pull request #35 from iamriajul/fix/npm-latest-release-tag

Merge pull request #35 from iamriajul/fix/npm-latest-release-tag #17

Workflow file for this run

name: Publish NPM Package
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
git_ref:
description: "Existing release tag or ref to publish from (for example v1.2.3-20260408120000)"
required: true
type: string
npm_tag:
description: "npm dist-tag to publish under"
required: false
default: "latest"
type: string
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
R2_ENDPOINT: ${{ vars.R2_ENDPOINT }}
R2_BUCKET: ${{ vars.R2_BUCKET }}
R2_PUBLIC_URL: ${{ vars.R2_PUBLIC_URL }}
VITE_PUBLIC_REACT_VIRTUOSO_LICENSE_KEY: ${{ secrets.VITE_PUBLIC_REACT_VIRTUOSO_LICENSE_KEY }}
NODE_OPTIONS: --max-old-space-size=6144
SKIP_SYSTEM_DEPS: "1"
LIBSQLITE3_SYS_USE_PKG_CONFIG: "1"
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.git_ref || github.ref }}
submodules: recursive
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
clang \
cmake \
curl \
git \
libclang-dev \
libsqlite3-dev \
libssl-dev \
pkg-config \
python3 \
unzip \
zip
case "$(uname -m)" in
x86_64) awscli_arch="x86_64" ;;
aarch64|arm64) awscli_arch="aarch64" ;;
*) echo "Unsupported architecture for AWS CLI: $(uname -m)" && exit 1 ;;
esac
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${awscli_arch}.zip" -o awscliv2.zip
unzip -q awscliv2.zip
sudo ./aws/install --update
aws --version
- name: Determine release version and npm tag
id: version
shell: bash
run: |
set -euo pipefail
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
raw_ref="${{ inputs.git_ref }}"
npm_tag="${{ inputs.npm_tag }}"
else
raw_ref="${GITHUB_REF_NAME}"
fi
ref_name="${raw_ref#refs/tags/}"
ref_name="${ref_name#refs/heads/}"
if [[ ! "$ref_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-.].*)?$ ]]; then
echo "Expected an npm release tag like v1.2.3 or v1.2.3-20260408120000, got: $raw_ref"
exit 1
fi
version="${ref_name#v}"
if [ "${GITHUB_EVENT_NAME}" != "workflow_dispatch" ]; then
npm_tag="latest"
fi
if [ -z "$version" ]; then
echo "Release version is empty"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "npm_tag=$npm_tag" >> "$GITHUB_OUTPUT"
- name: Publish package
shell: bash
env:
NPM_VERSION: ${{ steps.version.outputs.version }}
NPM_TAG: ${{ steps.version.outputs.npm_tag }}
run: |
set -euo pipefail
case "$(uname -m)" in
x86_64) export OPENSSL_LIB_DIR="/usr/lib/x86_64-linux-gnu" ;;
aarch64|arm64) export OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" ;;
*) echo "Unsupported architecture: $(uname -m)" && exit 1 ;;
esac
export OPENSSL_DIR="/usr"
export OPENSSL_INCLUDE_DIR="/usr/include"
export PKG_CONFIG_PATH="${OPENSSL_LIB_DIR}/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig"
export LIBCLANG_PATH="$(dirname "$(find /usr/lib -name 'libclang.so*' -print -quit)")"
./scripts/publish-npm.sh