Update package version #18
This file contains 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: Update package version | |
on: | |
workflow_dispatch: | |
inputs: | |
version-increment-type: | |
description: "What would you like to increment? Major, minor or patch?" | |
required: true | |
default: "patch" | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
increment-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.14.0 | |
cache: "yarn" | |
- name: Configure git | |
run: | | |
git config user.name 'GHA Workflow' | |
git config user.email '-' | |
- name: Increment package version | |
run: | | |
git log | |
NEW_VERSION=`npm version --git-tag-version=false ${{ github.event.inputs.version-increment-type }}` | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV # Save to environment | |
- name: Rebuild dist | |
run: | | |
rm -Rf dist | |
yarn install --frozen-lockfile | |
yarn build | |
- name: Commit & Push | |
run: | | |
git add -f package.json dist | |
git commit -m "New build + update package version to $NEW_VERSION" | |
git log | |
git checkout -b package-version-update | |
git push --force origin package-version-update | |
git tag $NEW_VERSION | |
git push --force origin $NEW_VERSION | |
- name: Create Pull Request | |
run: | | |
gh pr create --base main --head package-version-update --title "Update package version to $NEW_VERSION" --body "This PR was created automatically." | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} |