-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check if there is a first commit before this one - fixes fatal error …
…when pushing a merging a branch without a previous commit (#4)
- Loading branch information
1 parent
8598d93
commit 5fc2bad
Showing
1 changed file
with
17 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }}" | ||
|
@@ -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 }} | ||
|