Skip to content

Fix auto-version workflow: create releases for version branches#359

Merged
devakesu merged 2 commits intomainfrom
copilot/fix-auto-version-tag-bug
Feb 13, 2026
Merged

Fix auto-version workflow: create releases for version branches#359
devakesu merged 2 commits intomainfrom
copilot/fix-auto-version-tag-bug

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

The auto-version-and-tag job skipped tag creation when version files were already updated in merged PRs (e.g., branch 1.5.6), breaking the "every merge to main creates a release" contract.

Root cause: Version extraction was conditional on git changes. When bump-version.js detected no changes, version output was never set, causing tag creation step to skip.

Changes

Workflow logic (.github/workflows/pipeline.yml)

  • Always extract version before checking git diff (lines 303-305)

    # Always read current version from package.json
    CURRENT_VERSION=$(node -p "require('./package.json').version")
    echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
  • Update tag creation conditional from has_changes == 'true' to version != '' (line 402)

    • Now runs for both scenarios: with PR (version bump needed) and without PR (version already correct)
  • Branch on has_changes flag within tag creation step (lines 410-419)

    • If true: fetch merged PR changes
    • If false: create tag directly from current commit

Documentation (RELEASING.md)

  • Document both scenarios explicitly: version branches (direct tag) vs feature branches (PR → tag)
  • Add troubleshooting entry for the bug with manual workaround

Result

Both paths now create releases:

  • Version branch (1.5.6) → tag created immediately
  • Feature branch (copilot/*) → PR created → merged → tag created
Original prompt

Fix Auto-Version-and-Tag Workflow Logic Bug

Problem

The auto-version-and-tag job fails to create releases when version files are already updated in the merged PR. This breaks the intended workflow where every merge to main should create a release.

Current Behavior

When a PR with branch name x.x.x (e.g., 1.5.6) is merged:

  1. ✅ Version files are already updated in the PR to 1.5.6
  2. ✅ PR merges to main
  3. auto-version-and-tag job runs
  4. bump-version.js script runs successfully
  5. ❌ Script detects no git changes (version already correct)
  6. ❌ Workflow sets has_changes=false
  7. All subsequent steps are skipped (no PR, no tag, no release)
  8. Release is never created

Expected Behavior

According to the project's release logic:

Case 1: Branch name = x.x.x format

  • Version files are already updated in the PR
  • After merge: Create tag vx.x.x immediately
  • Tag triggers release workflow → Creates signed release

Case 2: Branch name ≠ x.x.x format (e.g., copilot/*, feature/*)

  • Version files need updating
  • After merge: Create PR with version bump → Wait for merge → Create tag
  • Tag triggers release workflow → Creates signed release

Result: Every merge to main creates a release (either immediately or after version bump PR merges)

Root Cause

In .github/workflows/pipeline.yml lines 288-304, the workflow checks for git changes:

- name: Check for version changes
  id: check
  run: |
    if git diff --quiet && git diff --cached --quiet; then
      echo "has_changes=false" >> $GITHUB_OUTPUT
      echo "No version changes to commit"
    else
      echo "has_changes=true" >> $GITHUB_OUTPUT
      CURRENT_VERSION=$(node -p "require('./package.json').version")
      echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT

Problem: When has_changes=false, the version output is never set, and all subsequent steps are skipped via if: steps.check.outputs.has_changes == 'true'.

Required Fix

1. Update "Check for version changes" step (line 288-304)

Always extract version (even when no changes):

- name: Check for version changes
  id: check
  run: |
    set -euo pipefail
    
    # Always read current version from package.json
    CURRENT_VERSION=$(node -p "require('./package.json').version")
    echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
    
    # Check if there are changes to commit
    if git diff --quiet && git diff --cached --quiet; then
      echo "has_changes=false" >> $GITHUB_OUTPUT
      echo "No version changes to commit - version already correct at ${CURRENT_VERSION}"
      echo "Will skip PR creation and create tag directly"
    else
      echo "has_changes=true" >> $GITHUB_OUTPUT
      echo "Version will be: ${CURRENT_VERSION}"
    fi

2. Update conditional steps

PR creation steps (lines 306-341): Keep existing condition

if: steps.check.outputs.has_changes == 'true'

Tag creation step (lines 390-435): Change to run when version is set

- name: Fetch latest changes and create release tag
  if: steps.check.outputs.version != ''
  env:
    GH_TOKEN: ${{ steps.app-token.outputs.token }}
  run: |
    set -euo pipefail
    
    VERSION_TAG="v${{ steps.check.outputs.version }}"
    
    # If changes were made, we need to fetch the merged PR
    if [ "${{ steps.check.outputs.has_changes }}" = "true" ]; then
      echo "Fetching latest changes from merged PR"
      git fetch origin main
      git checkout main
      git pull origin main
    else
      echo "No PR was created - version already correct"
      echo "Creating tag directly from current commit"
    fi
    
    echo "Checking if tag ${VERSION_TAG} needs to be created"
    
    # Check if tag already exists (skip if it does)
    if git ls-remote --tags origin | grep -q "refs/tags/${VERSION_TAG}$"; then
      echo "Tag ${VERSION_TAG} already exists, skipping tag creation"
      exit 0
    fi
    
    echo "Creating and pushing signed tag ${VERSION_TAG}"
    
    # Create annotated signed tag
    if ! git tag -a "${VERSION_TAG}" -m "Release ${VERSION_TAG}"; then
      echo "ERROR: Failed to create tag ${VERSION_TAG}"
      exit 1
    fi
    
    # Push tag (triggers release workflow)
    if ! git push origin "${VERSION_TAG}"; then
      echo "WARN: Failed to push tag ${VERSION_TAG} on first attempt"
      echo "Checking if tag now exists on remote (possible race condition)..."
      
      if git ls-remote --tags origin | grep -q "refs/tags/${VERSION_TAG}$"; then
        echo "Tag ${VERSION_TAG} now exists on remote; assuming it was created by concurrent workflow."
        echo "Treating this as success."
        exit 0
      fi
      
      echo "ERROR: Failed to push tag ${VERSION_TAG}"
      exit 1
    fi
    
    echo "✓ Release tag ${VERSION_TAG} created and pushed"
    echo "The release workflow will be triggered automatically by the tag push"

3. Update GPG import and GitHub App token steps

...

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix auto-version-and-tag workflow logic bug Fix auto-version workflow: create releases for version branches Feb 13, 2026
Copilot AI requested a review from devakesu February 13, 2026 18:38
@devakesu devakesu marked this pull request as ready for review February 13, 2026 18:45
Copilot AI review requested due to automatic review settings February 13, 2026 18:45
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the auto-version workflow where releases were not created when version files were already updated in merged PRs (e.g., from version branches like 1.5.6). The fix ensures that every merge to main creates a release, either immediately or after a version bump PR merges.

Changes:

  • Always extract version from package.json before checking git diff, ensuring version output is set in both scenarios
  • Update tag creation conditional from has_changes == 'true' to version != '' to enable tag creation for both workflow paths
  • Add branching logic in tag creation step to handle direct tagging (no PR) vs. PR-based tagging scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
.github/workflows/pipeline.yml Updated auto-version workflow logic to always extract version and conditionally create tags for both scenarios (version already updated vs. needs updating)
RELEASING.md Documented both workflow scenarios clearly and added troubleshooting entry for the fixed bug with manual workaround instructions

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

Copilot AI and others added 2 commits February 14, 2026 00:28
…ches

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
@devakesu devakesu force-pushed the copilot/fix-auto-version-tag-bug branch from eb32059 to 7ee0348 Compare February 13, 2026 18:58
@devakesu devakesu enabled auto-merge (squash) February 13, 2026 18:59
@devakesu devakesu merged commit e16e169 into main Feb 13, 2026
9 checks passed
devakesu added a commit that referenced this pull request Feb 13, 2026
* Initial plan

* Fix auto-version-and-tag workflow to create releases for version branches

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
devakesu added a commit that referenced this pull request Feb 13, 2026
…multi-arch (#360)

* Fix auto-version workflow: create releases for version branches (#359)

* Initial plan

* Fix auto-version-and-tag workflow to create releases for version branches

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Initial plan

* Fix incomplete Docker pull command by using IMAGE_NAME secret

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Add Docker layer caching and conditional ARM64 builds for performance

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Update docs/BUILD_PERFORMANCE.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Devanarayanan <fusion@devakesu.com>

* Update .github/workflows/release.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Devanarayanan <fusion@devakesu.com>

* Make platform messaging dynamic based on actual build platforms

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Improve sed command robustness for platform formatting

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Fix gh release create: add GH_TOKEN and remove conflicting --generate-notes

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Apply consistent platform formatting in VERIFY.md

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Signed-off-by: Devanarayanan <fusion@devakesu.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Co-authored-by: Devanarayanan <fusion@devakesu.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants