Skip to content

Generate a Release

Generate a Release #12

---
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#######################################
# Start the job on all push to master #
#######################################
name: Generate a Release
on:
workflow_dispatch:
###############
# Set the Job #
###############
jobs:
# Deploy to NPM
deploy_to_npm:
name: Generate a Release Version and Commit to Repo
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PATX }}
# Setup .npmrc file to publish to npm
- uses: actions/[email protected]
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
scope: rubenhalman
- name: Generate New Release Number
id: generate-release-number
run: |
npm install -g semver
export OLD_VER=$(semver --coerce $(cat package.json | jq .version))
export NEW_VER=$(semver --coerce $(cat package.json | jq .version) --increment minor)
sed -i -e "s/$(echo $OLD_VER)/$(echo $NEW_VER)/" package.json
echo "NEW_VER=$(echo $NEW_VER)" >> "$GITHUB_OUTPUT"
- name: Install dependencies
run: |
npm install
echo "install done"
git config --global user.name ${{ vars.USER_NAME }}
echo "user name"
git config --global user.email ${{ vars.USER_EMAIL }}
echo "user email"
git add .
echo "add done"
git commit -m "chore(release): ${{ steps.generate-release-number.outputs.NEW_VER }} [skip ci]" --no-verify
echo "commit done"
git push origin master
echo "push done"
git tag v${{ steps.generate-release-number.outputs.NEW_VER }}
echo "tag done"
git push --tags
echo "tag push done"
- run: |
cd out
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKENX }}