Skip to content

Release

Release #20

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release type (one of): patch, minor, major'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: 20.x
scope: '@hexancore'
cache: 'yarn'
always-auth: true
- name: Install dependencies
run: yarn install --immutable
- name: Bump package version
run: |
echo "OLD_VERSION=$(jq -r '.version' < package.json)" >> $GITHUB_ENV
yarn version $RELEASE_TYPE
echo "NEW_VERSION=$(jq -r '.version' < package.json)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ inputs.releaseType }}
- name: Update CHANGELOG.md
uses: 'zen8sol/[email protected]'
with:
newVersion: '${{ env.newVersion }}'
- name: Commit CHANGELOG.md and package.json changes and create tag
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git add "package.json"
git add "CHANGELOG.md"
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
- name: Publish
run: |
echo "npmAuthToken: ${{ env.NPM_AUTH_TOKEN }}" >> ./yarnrc.yml
yarn npm publish --access public --tag ${{ env.RELEASE_TAG }}
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Push changes to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag -m 'new version' '${{ inputs.newVersion }}' && git push --follow-tags