Engine - Version and Release #109
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Engine - Version and Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| newversion: | |
| description: 'Semantic Version Bump Type' | |
| type: choice | |
| required: true | |
| default: patch | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| env: | |
| node_version: 24 | |
| defaults: | |
| run: | |
| working-directory: engine | |
| jobs: | |
| version_and_release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ env.node_version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.node_version }} | |
| # registry-url is required so npm publish targets the public npm registry | |
| 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: | | |
| 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" | |
| # pnpm 10.16+ supports OIDC trusted publishing; use it directly to avoid bumping the | |
| # repo-wide packageManager (currently pnpm 7) which would force a lockfile rewrite. | |
| - run: npx -y pnpm@latest publish --access public --no-git-checks | |
| - run: git push --follow-tags |