Skip to content

Add idempotent tag creation with SHA validation to release workflow#42

Merged
AButler merged 4 commits intotag-firstfrom
copilot/sub-pr-41
Feb 3, 2026
Merged

Add idempotent tag creation with SHA validation to release workflow#42
AButler merged 4 commits intotag-firstfrom
copilot/sub-pr-41

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Addresses feedback on #41: tag creation step lacked error handling for re-runs and existing tags with mismatched SHAs.

Changes

  • Check tag existence before creation: Query GitHub API to determine if tag already exists
  • Idempotent behavior: Skip tag creation if tag exists at same SHA, log and succeed
  • Fail-fast on conflicts: Throw error if tag exists at different SHA, preventing silent overwrites
# Before
github.rest.git.createRef({
  ref: `refs/tags/${tag}`,
  sha: context.sha
})

# After
let existingTag = await github.rest.git.getRef({ ref: `tags/${tag}` });
if (existingTag) {
  if (existingTag.data.object.sha === context.sha) {
    console.log('Tag exists at same SHA. Skipping.');
    return;
  }
  throw new Error(`Tag exists at different SHA: ${existingTag.data.object.sha}`);
}
// ... create tag

Workflow can now be safely re-run without failures from duplicate tags at the same commit.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 3, 2026 11:19
Co-authored-by: AButler <1628649+AButler@users.noreply.github.com>
Co-authored-by: AButler <1628649+AButler@users.noreply.github.com>
Co-authored-by: AButler <1628649+AButler@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tagging logic for release draft creation Add idempotent tag creation with SHA validation to release workflow Feb 3, 2026
Copilot AI requested a review from AButler February 3, 2026 11:23
@AButler AButler marked this pull request as ready for review February 3, 2026 11:33
@AButler AButler merged commit 438b1b1 into tag-first Feb 3, 2026
@AButler AButler deleted the copilot/sub-pr-41 branch February 3, 2026 11:33
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