Skip to content

Conversation

Copy link

Copilot AI commented Dec 15, 2025

Plan for Fixing Release Workflow to Work with Protected Main Branch

  • 1. Review current release workflow structure and understand the issue
  • 2. Add necessary permissions for pull request creation to the workflow
  • 3. Create a release branch after checkout instead of working on main directly
  • 4. Update all git push operations to push to the release branch instead of main
  • 5. Keep Maven Central deployment before git operations (existing fail-fast behavior)
  • 6. Update tag creation to work on the release branch
  • 7. Add step to create a pull request from the release branch to main after all commits
  • 8. Keep GitHub Release creation step as-is
  • 9. Validate the workflow file syntax
  • 10. Review final changes to ensure minimal modifications
Original prompt

Problem

The current release workflow in .github/workflows/release.yml fails because it attempts to commit directly to the protected main branch. The error shows:

remote: error: GH006: Protected branch update failed for refs/heads/main.        
remote: - Changes must be made through a pull request.        
remote: - 2 of 2 required status checks are expected.

Solution Required

Modify the release workflow to:

  1. Create a release branch instead of committing directly to main
  2. Push all changes (release version, tag, and next snapshot version) to this release branch
  3. Create a pull request from the release branch to main
  4. Keep the Maven Central deployment before any git operations (fail-fast behavior)
  5. Keep the tag creation on the release branch
  6. Keep the GitHub Release creation

Implementation Details

Changes needed in .github/workflows/release.yml:

  1. After checkout, create a new release branch (e.g., release-v{version})
  2. Perform all version updates and commits on this release branch
  3. Push the release branch and tag to GitHub
  4. Create a pull request from the release branch to main
  5. The PR should include both commits:
    • Release version commit
    • Next snapshot version commit

Key Requirements:

  • Maven Central deployment must happen BEFORE any git operations (existing fail-fast behavior)
  • Use secrets.GITHUB_TOKEN for authentication
  • The PR should be auto-created with a descriptive title and body
  • Tag should be created on the release branch
  • GitHub Release should reference the tag
  • All existing functionality should be preserved

Suggested approach:

  • Use a dedicated release branch name like release-v${{ github.event.inputs.release_version }}
  • Use GitHub CLI (gh pr create) or peter-evans/create-pull-request action to create the PR
  • Ensure proper permissions are set for the workflow

This pull request was created as a result of the following prompt from Copilot chat.

Problem

The current release workflow in .github/workflows/release.yml fails because it attempts to commit directly to the protected main branch. The error shows:

remote: error: GH006: Protected branch update failed for refs/heads/main.        
remote: - Changes must be made through a pull request.        
remote: - 2 of 2 required status checks are expected.

Solution Required

Modify the release workflow to:

  1. Create a release branch instead of committing directly to main
  2. Push all changes (release version, tag, and next snapshot version) to this release branch
  3. Create a pull request from the release branch to main
  4. Keep the Maven Central deployment before any git operations (fail-fast behavior)
  5. Keep the tag creation on the release branch
  6. Keep the GitHub Release creation

Implementation Details

Changes needed in .github/workflows/release.yml:

  1. After checkout, create a new release branch (e.g., release-v{version})
  2. Perform all version updates and commits on this release branch
  3. Push the release branch and tag to GitHub
  4. Create a pull request from the release branch to main
  5. The PR should include both commits:
    • Release version commit
    • Next snapshot version commit

Key Requirements:

  • Maven Central deployment must happen BEFORE any git operations (existing fail-fast behavior)
  • Use secrets.GITHUB_TOKEN for authentication
  • The PR should be auto-created with a descriptive title and body
  • Tag should be created on the release branch
  • GitHub Release should reference the tag
  • All existing functionality should be preserved

Suggested approach:

  • Use a dedicated release branch name like release-v${{ github.event.inputs.release_version }}
  • Use GitHub CLI (gh pr create) or peter-evans/create-pull-request action to create the PR
  • Ensure proper permissions are set for the workflow

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

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.

2 participants