Skip to content

Commit

Permalink
check if there is a first commit before this one - fixes fatal error …
Browse files Browse the repository at this point in the history
…when pushing a merging a branch without a previous commit (#4)
  • Loading branch information
ryanrozich authored May 5, 2024
1 parent 8598d93 commit 5fc2bad
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,28 @@ jobs:
- name: Install bumpversion
run: pip install bump2version

- name: List changes
id: list-changes
# Determine changes
- name: Determine changed files
id: determine_changes
run: |
git diff --name-only HEAD^ HEAD > changes.txt
git diff main@{1} main > 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.list-changes.outputs.status == 'code'
if: steps.determine_changes.outputs.status == 'code'
id: version-bump-type
run: |
echo "Commit message: ${{ steps.get-commit-message.outputs.message }}"
Expand All @@ -44,17 +54,18 @@ jobs:
fi
- name: Bump version
if: steps.list-changes.outputs.status == 'code'
if: steps.determine_changes.outputs.status == 'code'
run: bumpversion ${{ steps.version-bump-type.outputs.type }}

- name: Push changes
if: steps.list-changes.outputs.status == 'code'
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 }}
Expand Down

0 comments on commit 5fc2bad

Please sign in to comment.