Skip to content

updating the diff statement in the deploy GH action (#9) #4

updating the diff statement in the deploy GH action (#9)

updating the diff statement in the deploy GH action (#9) #4

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')"
# Conditional step based on changes
- name: Version Bump and Push
if: steps.determine_changes.outputs.status == 'code'
run: |
bump2version patch --config-file .bumpversion.cfg
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git push --tags
- 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
if: steps.determine_changes.outputs.status == 'code'
id: version-bump-type
run: |
echo "Commit message: ${{ steps.get-commit-message.outputs.message }}"
if echo "${{ steps.get-commit-message.outputs.message }}" | grep -q "MAJOR:"; then
echo "::set-output name=type::major"
elif echo "${{ steps.get-commit-message.outputs.message }}" | grep -q "MINOR:"; then
echo "::set-output name=type::minor"
else
echo "::set-output name=type::patch"
fi
- name: Bump version
if: steps.determine_changes.outputs.status == 'code'
run: bumpversion ${{ steps.version-bump-type.outputs.type }}
- name: Push changes
if: steps.determine_changes.outputs.status == 'code'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git push && 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/*