powergrid/.github/workflows/engine-publish.yml
2025-08-09 21:12:39 +00:00

44 lines
1.9 KiB
YAML

name: Engine - Version and Release
on:
workflow_dispatch:
inputs:
newversion:
description: 'Semantic Version Bump Type (major minor patch)'
default: patch
env:
node_version: 14
defaults:
run:
working-directory: engine
jobs:
version_and_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.node_version }}
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: 'https://registry.npmjs.org'
- run: corepack enable
- run: pnpm install
- run: git config --global user.name github-actions
- run: git config --global user.email bot@github.com
# - run: yarn config set version-git-message "Engine v%s"
# - run: yarn version --${{ github.event.inputs.newversion }}
- run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git add .
git commit -m "🔖 powergrid-engine $BUMPED_VERSION"
- run: pnpm publish --access public --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git push --follow-tags