Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release only if changes exist #2

Merged
merged 6 commits into from
Feb 7, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ jobs:
# Requires "Read and Write access to code" permission
token: ${{ secrets.RELEASE_ACTION_ACCESS_TOKEN }}

- name: Check for changes since last tag
id: check_changes
run: |
LATEST_TAG=$(git tag --sort=-authordate --merged=main | head --lines 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs to sort by commit date in case we merge a commit that was authored before some other commit but only merged afterwards.
Probably an edge case that might never arise but this seems safer regardless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on pull_request. Switched to committerdate sorting.

CHANGES=$(git log $LATEST_TAG..HEAD --oneline)
if [[ -z "$CHANGES" ]]; then
echo "No changes since the last tag."
else
echo "Changes detected since the last tag."
echo "has_changes=true" >> $GITHUB_OUTPUT
fi

- name: Create Tag
if: ${{ steps.check_changes.outputs.has_changes }}
id: tag_version
run: |
# Extracts the latest version tag, bumps the minor version
Expand All @@ -35,6 +48,7 @@ jobs:
git push origin --tags

- name: "Create release"
if: ${{ steps.check_changes.outputs.has_changes }}
uses: "actions/github-script@v6"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
Loading