From a3ee44f7a1747d556bf1a3c4d16b873fd2800dfc Mon Sep 17 00:00:00 2001 From: DerTolleEmil <10513218+DerTolleEmil@users.noreply.github.com> Date: Tue, 1 Sep 2026 20:59:50 +0200 Subject: [PATCH] Make package publication retryable --- .github/workflows/release.yml | 45 ++++++++++++++++++++++++++++------- BUILDING.md | 5 ++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ed0c5b9..5489457 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,12 @@ on: release: types: - published + workflow_dispatch: + inputs: + release_tag: + description: Published release tag to retry + required: true + type: string permissions: contents: read @@ -27,14 +33,29 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 - ref: ${{ github.event.release.tag_name }} + ref: ${{ inputs.release_tag || github.event.release.tag_name }} - name: Download release assets shell: pwsh env: GH_TOKEN: ${{ github.token }} - RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_TAG: ${{ inputs.release_tag || github.event.release.tag_name }} + REPOSITORY: ${{ github.repository }} run: | + $release = gh release view $env:RELEASE_TAG ` + --repo $env:REPOSITORY ` + --json isDraft,isPrerelease,tagName | + ConvertFrom-Json + if ($LASTEXITCODE -ne 0) { + throw "Failed to resolve release '$env:RELEASE_TAG'." + } + if ($release.tagName -cne $env:RELEASE_TAG -or $release.isDraft) { + throw "Release '$env:RELEASE_TAG' must be published before its packages can be published." + } + if ($release.isPrerelease) { + throw 'GitHub prereleases cannot publish ACMP packages.' + } + $null = New-Item ` -ItemType Directory ` -Path .\artifacts\release ` @@ -50,8 +71,8 @@ jobs: shell: pwsh env: EVENT_COMMIT: ${{ github.sha }} - IS_PRERELEASE: ${{ github.event.release.prerelease }} - RELEASE_TAG: ${{ github.event.release.tag_name }} + EVENT_NAME: ${{ github.event_name }} + RELEASE_TAG: ${{ inputs.release_tag || github.event.release.tag_name }} REPOSITORY: ${{ github.repository }} run: | $stableVersionPattern = '(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)' @@ -71,16 +92,13 @@ jobs: if ($manifest.primaryTag -cne $env:RELEASE_TAG) { throw "Release tag '$env:RELEASE_TAG' does not match manifest tag '$($manifest.primaryTag)'." } - if ($env:IS_PRERELEASE -eq 'true') { - throw 'GitHub prereleases cannot publish ACMP packages.' - } - $headCommit = git rev-parse HEAD if ($LASTEXITCODE -ne 0) { throw 'Failed to resolve the checked-out release commit.' } if ($manifest.commit -cne $headCommit -or - $env:EVENT_COMMIT -cne $headCommit) { + ($env:EVENT_NAME -ceq 'release' -and + $env:EVENT_COMMIT -cne $headCommit)) { throw "Release assets were prepared for '$($manifest.commit)', but the release points to '$headCommit'." } @@ -275,6 +293,15 @@ jobs: PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} VERSION: ${{ needs.validate.outputs.powershell_version }} run: | + $gallery = Get-PSRepository ` + -Name PSGallery ` + -ErrorAction SilentlyContinue + if ($null -eq $gallery) { + Register-PSRepository ` + -Default ` + -ErrorAction Stop + } + $existing = Find-Module ` -Name ACMP ` -RequiredVersion $env:VERSION ` diff --git a/BUILDING.md b/BUILDING.md index c5d8e5f..38ebf86 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -161,6 +161,11 @@ It does not rebuild the packages. It: - pushes the prepared `.nupkg` to NuGet; and - extracts and publishes the prepared PowerShell module archive. +If publication fails after the release has been published, fix the workflow on +`main`, then run `Publish Release` manually with the existing primary release +tag. The retry downloads and validates the published assets again, skips +packages that already exist, and publishes any missing package. + The `.nupkg`, `ACMP.dll`, and `ACMP.PowerShell.dll` published by this process are the files produced by the preparation build.