Skip to content

ci: make release publish jobs idempotent on re-run#7895

Merged
jingjingjia-ms merged 1 commit into
mainfrom
ci/idempotent-release
Jul 3, 2026
Merged

ci: make release publish jobs idempotent on re-run#7895
jingjingjia-ms merged 1 commit into
mainfrom
ci/idempotent-release

Conversation

@jingjingjia-ms

Copy link
Copy Markdown
Contributor

Why

Re-triggering the release pipeline for a tag that was already (partially) published previously failed hard, making it impossible to recover from a partial release without manual surgery:

  • GitHubRelease@1 returns 422 when the tag/release already exists
  • 1ES.PublishNuget@1 returns 409 on a duplicate NuGet version
  • EsrpRelease@12 (npm) and vsce publish fail on an already-published version

This blocked recovery scenarios such as a run where every stage succeeded except the npm ESRP publish — a plain "Rerun failed jobs" still re-hit the 422/409 walls on the other publish steps.

What

Each publish job now checks whether its artifact version is already published and skips that publish step if so, otherwise publishes exactly as before:

Job Idempotency check Skip when already published
github_release anonymous GitHub API lookup of the release by tag → releaseExists both GitHubRelease@1 tasks gated ne(releaseExists,'true')
deploy_kiota / deploy_builder query nuget.org flat container for the version parsed from the .nupkg filename → nugetAlreadyPublished 1ES.PublishNuget@1 gated on it
deploy_npm add UseNode@1; npm view @microsoft/kiota@<version> (version from microsoft-kiota-<version>.tgz) → npmAlreadyPublished EsrpRelease@12 gated on it
vs_marketplace capture vsce publish output; non-zero exit whose output contains already exists treated as an idempotent skip

PushDockerImage is already idempotent (tag overwrite) and is unchanged.

Notes

  • The registry lookups are anonymous/read-only against the public NuGet, npm, and GitHub APIs (microsoft/kiota is a public repo), so no additional credentials/service connections are required.
  • The VS Marketplace uses build-derived version numbers (decoupled from the release tag), so vs_marketplace relies on vsce's own duplicate detection rather than a tag-version compare: a re-run of the same build republishes an identical vsix version (skipped), while a new build produces a new version (published).

Validation

  • Pipeline YAML parses cleanly (yaml.safe_load).
  • Verified the checks against the live registries for v1.32.5: NuGet Microsoft.OpenApi.Kiota / .Builder both already at 1.32.5 → would skip; npm @microsoft/kiota is only at 1.32.4 (1.32.5 returns 404) → would publish. This matches the real partial-release state.

Re-triggering the release pipeline for a tag that was already (partially)
published previously failed hard: GitHubRelease@1 returns 422 on an existing
tag, NuGet push returns 409 on a duplicate version, npm/ESRP re-publish and
vsce publish fail on an existing version. This blocked recovering from a
partial release (e.g. when only the npm ESRP step failed) without manual
surgery.

Each publish job now checks whether its artifact version is already published
and skips the publish step if so, otherwise publishes as before:

- github_release: anonymous GitHub API lookup of the release by tag sets
  releaseExists; both GitHubRelease@1 tasks are gated to skip when it exists.
- deploy_kiota / deploy_builder: query the nuget.org flat container for the
  version parsed from the .nupkg filename; 1ES.PublishNuget@1 is gated on the
  result.
- deploy_npm: add UseNode@1 and run 'npm view @microsoft/kiota@<version>'
  (version parsed from the microsoft-kiota-<version>.tgz filename); EsrpRelease@12
  is gated on the result.
- vs_marketplace: capture vsce publish output and treat a non-zero exit whose
  output contains 'already exists' as an idempotent skip.

PushDockerImage is already idempotent (tag overwrite) and is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jingjingjia-ms jingjingjia-ms requested a review from a team as a code owner July 3, 2026 22:09
@msgraph-bot msgraph-bot Bot added this to Kiota Jul 3, 2026
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the branch is 72%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 3aa5dd7 +/-
/home/runner/wo...guageRefiner.cs 98%
/home/runner/wo...criptRefiner.cs 98%
/home/runner/wo...MethodWriter.cs 97%
/home/runner/wo...MethodWriter.cs 96%
/home/runner/wo...MethodWriter.cs 96%
/home/runner/wo...MethodWriter.cs 95%
/home/runner/wo...rs/GoRefiner.cs 93%
/home/runner/wo...KiotaBuilder.cs 90%
/home/runner/wo...ationService.cs 89%
/home/runner/wo...xGenerator.g.cs 75%

Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Jul 3, 2026
@jingjingjia-ms jingjingjia-ms merged commit 38ba79b into main Jul 3, 2026
317 checks passed
@jingjingjia-ms jingjingjia-ms deleted the ci/idempotent-release branch July 3, 2026 22:48
@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

2 participants