Skip to content

Merge pull request #11 from ryanrozich/update-gh-action-skip-version-… #5

Merge pull request #11 from ryanrozich/update-gh-action-skip-version-…

Merge pull request #11 from ryanrozich/update-gh-action-skip-version-… #5

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
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install bumpversion
run: pip install bump2version
# Determine changes
- name: Determine changed files
id: determine_changes
run: |
git diff main HEAD~1 --name-only > changes.txt
echo "::set-output name=status::$(grep -qvE '^docs/|^README.md|^\.env\.sample$|^config\.json\.sample$|^\.github/workflows/|\.bumpversion\.cfg$' changes.txt && echo 'code' || echo 'docs')"
- name: Get last commit message
id: get-commit-message
run: echo "::set-output name=message::$(git log -1 --pretty=%B)"
- 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"
elif echo "${{ github.event.head_commit.message }}" | grep -q "MAJOR:"; then
echo "::set-output name=type::major"
elif echo "${{ github.event.head_commit.message }}" | grep -q "MINOR:"; then
echo "::set-output name=type::minor"
else
echo "::set-output name=type::patch"
fi
- 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
- name: Build and publish
if: steps.determine_changes.outputs.status == 'code'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*