Increment Version #12
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: Increment Version | |
on: | |
workflow_dispatch: | |
inputs: | |
version_increment: | |
description: 'Version number to increment' | |
required: true | |
default: 'patch' | |
type: 'choice' | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
increment-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Configure Git | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
echo "Configured Git as user: ${{ github.actor }}" | |
- name: Increment version | |
id: version | |
run: | | |
# Get current version | |
CURRENT_VERSION=$(node -p "require('./package.json').version") | |
echo "Current version: $CURRENT_VERSION" | |
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
# Increment version based on input | |
npm version ${{ github.event.inputs.version_increment }} --no-git-tag-version | |
# Get new version | |
NEW_VERSION=$(node -p "require('./package.json').version") | |
echo "New version: $NEW_VERSION" | |
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
# Create branch name | |
BRANCH_NAME="version-bump-$NEW_VERSION" | |
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: 'chore: bump ${{ github.event.inputs.version_increment }} (`${{ steps.version.outputs.current_version }}` -> `${{ steps.version.outputs.new_version }}`)' | |
title: 'chore: bump ${{ github.event.inputs.version_increment }} (`${{ steps.version.outputs.current_version }}` -> `${{ steps.version.outputs.new_version }}`)' | |
body: | | |
This PR bumps the version from `${{ steps.version.outputs.current_version }}` to `${{ steps.version.outputs.new_version }}`. | |
Automated version increment via GitHub Actions. | |
branch: ${{ steps.version.outputs.branch_name }} | |
base: main | |
delete-branch: true |