Skip to content

Merge pull request #17 from ryanrozich/fix-github-action-gh-identity #8

Merge pull request #17 from ryanrozich/fix-github-action-gh-identity

Merge pull request #17 from ryanrozich/fix-github-action-gh-identity #8

Workflow file for this run

name: Auto Version Bumping
on:
push:
branches:
- main
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
# This step checks out the repository code
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
# This step sets up the Python environment
- name: Install bumpversion
run: pip install bump2version
# This step installs the bump2version package
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# This step configures Git with a dummy email and name
- name: Get last commit message
id: get-commit-message
run: echo "::set-output name=message::$(git log -1 --pretty=%B)"
# This step retrieves the last commit message and sets it as an output
- name: Determine version bump type
id: version-bump-type
run: |
echo "Commit message: ${{ github.event.head_commit.message }}"
if echo "${{ github.event.head_commit.message }}" | grep -q "\[skip version\]"; then
echo "::set-output name=type::skip" # Skip version bump
elif echo "${{ github.event.head_commit.message }}" | grep -q "MAJOR:"; then
echo "::set-output name=type::major" # Major version bump
elif echo "${{ github.event.head_commit.message }}" | grep -q "MINOR:"; then
echo "::set-output name=type::minor" # Minor version bump
else
echo "::set-output name=type::patch" # Patch version bump
fi
# This step analyzes the commit message to determine the type of version bump
- name: Version Bump and Push
if: steps.version-bump-type.outputs.type != 'skip'
run: |
bump2version ${{ steps.version-bump-type.outputs.type }} --config-file .bumpversion.cfg
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git push --tags
# This step performs the version bump and pushes the changes to the repository
- name: Build and publish
if: steps.version-bump-type.outputs.type != 'skip'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
# This step builds and publishes the package if a version bump is required