update #208
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 push to main | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
bump-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: npm install | |
- name: Bump version | |
id: bump_version | |
run: | | |
current_version=$(jq -r '.version' package.json) | |
IFS='.' read -r -a version_parts <<< "$current_version" | |
major=${version_parts[0]} | |
minor=${version_parts[1]} | |
patch=${version_parts[2]} | |
new_patch=$((patch + 1)) | |
new_version="$major.$minor.$new_patch" | |
jq ".version = \"$new_version\"" package.json > package.tmp.json | |
mv package.tmp.json package.json | |
echo "New version: $new_version" | |
echo "::set-output name=new_version::$new_version" | |
- name: Commit updated version | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
git add package.json | |
git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Trigger Release components package workflow | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
event-type: create-tag-release |