Skip to content

Commit

Permalink
Publication to NPM.
Browse files Browse the repository at this point in the history
  • Loading branch information
barinbritva committed Feb 6, 2024
1 parent b41de93 commit 268b422
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
53 changes: 53 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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 --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@barinbritva/game-engines-sdk",
"private": true,
"engines": {
"node": ">=18.0.0",
"npm": ">=9.0.0"
Expand Down

0 comments on commit 268b422

Please sign in to comment.