Skip to content

Publication to NPM.

Publication to NPM. #3

Workflow file for this run

name: Publish to NPM
on:
push:
tags:
# package-major.minor.patch - required
# -beta.build - optional
- '*-*.*.*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- id: get-package
run: |
PACKAGE_NAME=$(echo ${GITHUB_REF#refs/tags/} | cut -d- -f1)
ALLOWED_PACKAGES=("phaser") # Add more package names if needed
if [[ " ${ALLOWED_PACKAGES[@]} " =~ " ${PACKAGE_NAME} " ]]; then
echo "::set-output name=package::${PACKAGE_NAME}"
else
echo "Invalid package name ${PACKAGE_NAME}."
exit 1
fi
shell: bash
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Check version
run: |
TAG_VERSION=$(echo ${GITHUB_REF#refs/tags/${{ steps.get-package.outputs.package }}-})
PACKAGE_VERSION=$(node -p "require('./packages/${{ steps.get-package.outputs.package }}/package.json').version")
if [[ "${TAG_VERSION}" != "${PACKAGE_VERSION}" ]]; then
echo "Tag version ${TAG_VERSION} does not match package version ${PACKAGE_VERSION}."
exit 1
fi
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build --workspace @barinbritva/${{ steps.get-package.outputs.package }}-sdk
- name: Publish
run: cd packages/${{ steps.get-package.outputs.package }} && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}