Skip to content

fix: release workflow to detect version change#1026

Merged
edwinjosechittilappilly merged 5 commits into
mainfrom
fix-release-trigger
Feb 26, 2026
Merged

fix: release workflow to detect version change#1026
edwinjosechittilappilly merged 5 commits into
mainfrom
fix-release-trigger

Conversation

@edwinjosechittilappilly

Copy link
Copy Markdown
Collaborator

This pull request updates the release workflow to prevent unnecessary releases when the version line in pyproject.toml hasn't changed. The workflow now checks for changes to the version and skips the release process if no update is detected.

Release workflow improvements:

  • Added logic to compare the version line in pyproject.toml between the previous and current commit, and set a version_changed output accordingly to determine if a release should proceed.
  • If the version line is unchanged, the workflow sets skip_release and is_prerelease outputs to true and exits early, preventing an unnecessary release.

@edwinjosechittilappilly edwinjosechittilappilly requested review from Copilot and phact and removed request for Copilot February 25, 2026 17:01
@github-actions github-actions Bot added ci ⬛ CI/CD, build, and infrastructure issues bug 🔴 Something isn't working. labels Feb 25, 2026
Copilot AI review requested due to automatic review settings February 25, 2026 17:40
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Feb 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the GitHub Actions release workflow to avoid running the multi-arch build/release pipeline when pyproject.toml changes but the version = "..." line does not, reducing unnecessary releases.

Changes:

  • Adds a git diff-based check to detect whether the version line changed between the previous and current commit on push.
  • Sets skip_release=true (and exits early) when no version-line change is detected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +43
if git diff --unified=0 "$BEFORE_SHA" "${{ github.sha }}" -- pyproject.toml | grep -E '^[+-]version = "' >/dev/null; then
VERSION_CHANGED="true"
else
VERSION_CHANGED="false"

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

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

The VERSION_CHANGED detection currently checks whether the diff contains any added/removed version = "..." line, but it doesn’t verify that the version value actually changed (e.g., whitespace-only edits to the version line would still trigger a release). To match the goal of skipping releases when the version hasn’t changed, consider extracting the previous version from $BEFORE_SHA:pyproject.toml and comparing it to the current VERSION.

Suggested change
if git diff --unified=0 "$BEFORE_SHA" "${{ github.sha }}" -- pyproject.toml | grep -E '^[+-]version = "' >/dev/null; then
VERSION_CHANGED="true"
else
VERSION_CHANGED="false"
PREVIOUS_VERSION=$(git show "$BEFORE_SHA:pyproject.toml" 2>/dev/null | grep '^version = ' | cut -d '"' -f 2 || true)
if [[ -n "$PREVIOUS_VERSION" && "$PREVIOUS_VERSION" == "$VERSION" ]]; then
VERSION_CHANGED="false"
else
VERSION_CHANGED="true"

Copilot uses AI. Check for mistakes.
fi
fi
fi
echo "version_changed=$VERSION_CHANGED" >> $GITHUB_OUTPUT

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

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

version_changed is written to $GITHUB_OUTPUT but it isn’t exposed via the job’s outputs: and doesn’t appear to be consumed elsewhere in this workflow. Consider either adding it to jobs.check-version.outputs (if you want it for downstream jobs) or removing it to avoid a misleading/unused output.

Suggested change
echo "version_changed=$VERSION_CHANGED" >> $GITHUB_OUTPUT

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +41
if [[ "${{ github.event_name }}" == "push" ]]; then
BEFORE_SHA="${{ github.event.before }}"
if [[ -n "$BEFORE_SHA" && "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]]; then
if git diff --unified=0 "$BEFORE_SHA" "${{ github.sha }}" -- pyproject.toml | grep -E '^[+-]version = "' >/dev/null; then
VERSION_CHANGED="true"

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

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

git diff "$BEFORE_SHA" ${{ github.sha }} relies on the runner having the previous commit available locally. With actions/checkout@v4 defaults (shallow clone), BEFORE_SHA (and tags used by the later git rev-parse "v$VERSION") may not be present, causing this step to fail or to incorrectly conclude the version didn’t change. Consider setting actions/checkout to fetch enough history (e.g., fetch-depth: 2 or 0) and ensure tags are fetched so both the diff and tag-existence checks work reliably.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(a) [Critical] The git diff call will silently fail on every run because a shallow clone is performed by default

  • The Copilot feedback is legit
  • Problem: The git diff "$BEFORE_SHA" "${{ github.sha }}" call will silently fail on every run because actions/checkout@v4 performs a shallow clone (fetch-depth: 1) by default.
    • BEFORE_SHA (from github.event.before) is not present in the shallow-cloned history, so git outputs a fatal error to stderr with no stdout.
    • The pipe to grep receives empty input, exits non-zero, and the else branch always runs — setting VERSION_CHANGED="false" even when the version did change.
    • The result: every push that bumps the version in pyproject.toml will be detected as "version unchanged" and the release will be silently skipped.
  • Recommendation: Fix by adding fetch-depth: 0 (or at minimum fetch-depth: 2) to the check-version job's checkout step

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚀

@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Feb 26, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Feb 26, 2026

@mpawlow mpawlow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@edwinjosechittilappilly

Code Review 1

  • See PR comment (a)

Comment on lines +37 to +41
if [[ "${{ github.event_name }}" == "push" ]]; then
BEFORE_SHA="${{ github.event.before }}"
if [[ -n "$BEFORE_SHA" && "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]]; then
if git diff --unified=0 "$BEFORE_SHA" "${{ github.sha }}" -- pyproject.toml | grep -E '^[+-]version = "' >/dev/null; then
VERSION_CHANGED="true"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(a) [Critical] The git diff call will silently fail on every run because a shallow clone is performed by default

  • The Copilot feedback is legit
  • Problem: The git diff "$BEFORE_SHA" "${{ github.sha }}" call will silently fail on every run because actions/checkout@v4 performs a shallow clone (fetch-depth: 1) by default.
    • BEFORE_SHA (from github.event.before) is not present in the shallow-cloned history, so git outputs a fatal error to stderr with no stdout.
    • The pipe to grep receives empty input, exits non-zero, and the else branch always runs — setting VERSION_CHANGED="false" even when the version did change.
    • The result: every push that bumps the version in pyproject.toml will be detected as "version unchanged" and the release will be silently skipped.
  • Recommendation: Fix by adding fetch-depth: 0 (or at minimum fetch-depth: 2) to the check-version job's checkout step

@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Feb 26, 2026
@edwinjosechittilappilly

Copy link
Copy Markdown
Collaborator Author

resetted to 0 from 2 in depth

@mpawlow mpawlow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@edwinjosechittilappilly

Code Review 2

  • LGTM / Approved 👍

Comment on lines +37 to +41
if [[ "${{ github.event_name }}" == "push" ]]; then
BEFORE_SHA="${{ github.event.before }}"
if [[ -n "$BEFORE_SHA" && "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]]; then
if git diff --unified=0 "$BEFORE_SHA" "${{ github.sha }}" -- pyproject.toml | grep -E '^[+-]version = "' >/dev/null; then
VERSION_CHANGED="true"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚀

@github-actions github-actions Bot added the lgtm label Feb 26, 2026
@edwinjosechittilappilly edwinjosechittilappilly merged commit b8201e1 into main Feb 26, 2026
8 checks passed
@github-actions github-actions Bot deleted the fix-release-trigger branch February 26, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔴 Something isn't working. ci ⬛ CI/CD, build, and infrastructure issues lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants