Skip to content

Merge branch 'main' into release/patch #61

Merge branch 'main' into release/patch

Merge branch 'main' into release/patch #61

Workflow file for this run

name: Prepare release version
on:
push:
branches:
- release/**
workflow_dispatch:
concurrency:
group: bump-version-${{ github.ref }}
cancel-in-progress: false
jobs:
bump:
name: Bump package version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Validate release branch naming
run: |
case "${GITHUB_REF_NAME}" in
release/patch|release/minor|release/major)
echo "Release branch ${GITHUB_REF_NAME} accepted."
;;
*)
echo "Invalid release branch name: ${GITHUB_REF_NAME}"
exit 1
;;
esac
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm test --if-present
- name: Determine bump type
id: bump
run: |
case "${GITHUB_REF_NAME}" in
release/patch) echo "type=patch" >>"$GITHUB_OUTPUT" ;;
release/minor) echo "type=minor" >>"$GITHUB_OUTPUT" ;;
release/major) echo "type=major" >>"$GITHUB_OUTPUT" ;;
esac
- name: Configure git author
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Bump package version
run: |
npm version ${{ steps.bump.outputs.type }} --no-git-tag-version --commit-hooks false
VERSION="$(node -p "require('./package.json').version")"
echo "version=${VERSION}" >>"$GITHUB_OUTPUT"
id: version
- name: Commit version bump
run: |
if git status --porcelain | grep .; then
git add package.json package-lock.json
git commit -m "chore: bump version to v${{ steps.version.outputs.version }}"
else
echo "No changes to commit."
fi
- name: Push changes
if: github.ref_protected != 'true'
run: git push --set-upstream origin "${GITHUB_REF_NAME}"