Bump Version #2
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: Bump Version | |
on: | |
workflow_dispatch: # Manual trigger | |
jobs: | |
bump-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Bump version in package.json | |
id: bump_version | |
run: | | |
# Get the current version | |
CURRENT_VERSION=$(jq -r '.version' package.json) | |
echo "Current version: $CURRENT_VERSION" | |
# Increment the patch version | |
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION" | |
NEW_VERSION="$major.$minor.$((patch + 1))" | |
echo "New version: $NEW_VERSION" | |
# Update the version fields in package.json | |
jq ".version = \"$NEW_VERSION\" | .consolePlugin.version = \"$NEW_VERSION\"" package.json > package.json.tmp | |
mv package.json.tmp package.json | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add package.json | |
git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}" | |
git push origin main |