GitHub Action to increment the project's version using bump2version, commit, tag, and push the change. This operation can be fine-tuned in .bumpversion.cfg, see bumpversion --help for the details.
You need to obtain a Personal Access Token
to push to your repository and save it in your Secrets as BOT_TOKEN.
Suppose that your GitHub account is @your-bot-login "Your Company Bot" <bot@your-company.com>.
Suppose that your version lies in file version.md like this:
# version 1.0.0
Create a new workflow (or append to an existing one) .github/workflows/bump-version.yml:
name: Bump version workflowon:
push:
branches:
- mainjobs:
bump-version:
name: Bump package versionif: "!contains(github.event.head_commit.message, 'Bump version')"runs-on: ubuntu-20.04steps:
- name: actions/checkoutuses: actions/checkout@v2with:
persist-credentials: false
- name: current_versionrun: echo "current_version=$(grep '# version' version.md | cut -d ' ' -f3)" >> $GITHUB_ENV
- name: FragileTech/bump-versionuses: FragileTech/bump-version@mainwith:
current_version: "${{ env.current_version }}"files: version.mdcommit_name: Your Company Botcommit_email: bot@your-company.comlogin: your-bot-logintoken: "${{ secrets.BOT_TOKEN }}"Now every time you merge something to main branch, you'll receive an additional direct commit to main that increments the version in version.md.
MIT, see LICENSE.