Skip to content

Publish to NPM

Publish to NPM #7

Workflow file for this run

name: Publish to NPM
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
Publish:
name: Publish to NPM
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: ./v1/typescript-definitions
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
# Ensure npm 11.5.1 or later is installed:
# - name: Update npm
# run: npm install -g npm@latest
- name: Prepare Environment
# Install from package-lock.json:
run: npm ci
env:
CI: true
- name: Determine type of release
id: release-tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "Publish latest"
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "Publish nightly"
echo "tag=nightly" >> $GITHUB_OUTPUT
fi
- name: Bump version to prerelease
if: github.ref != 'refs/heads/main'
run: |
COMMIT_TIMESTAMP=$(git log -1 --pretty=format:%ct HEAD)
COMMIT_DATE=$(date -d @$COMMIT_TIMESTAMP +%Y%m%d-%H%M%S)
GIT_HASH=$(git rev-parse --short HEAD)
PRERELEASE_TAG=nightly-$(echo "${{ github.ref_name }}" | sed -r 's/[^a-z0-9]+/-/gi')
npm version prerelease --preid $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH
- name: Generate types
run: npm run generate-types
env:
CI: true
- name: Generate server types
run: npm run generate-server-types
env:
CI: true
- name: Build
run: npm run build
env:
CI: true
- name: Publish to NPM
run: npm publish --tag ${{ steps.release-tag.outputs.tag }}
env:
CI: true