Skip to content

Commit 083f687

Browse files
its-mashclaude
andauthored
chore(ci): add manual re-publish for existing draft releases (#107)
Signed-off-by: Claude <noreply@anthropic.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0329342 commit 083f687

1 file changed

Lines changed: 38 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
push:
55
branches: [main]
66
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Re-publish an existing draft release (e.g. v0.1.1). Leave empty for normal release-please flow.'
10+
required: false
11+
type: string
712

813
concurrency:
914
group: ${{ github.workflow }}-${{ github.ref }}
@@ -184,19 +189,39 @@ jobs:
184189
# ─────────────────────────────────────────────────────────────
185190
publish-release:
186191
needs: [release-please, build-release]
187-
if: needs.release-please.outputs.release_created == 'true'
192+
# Run after a successful build OR when manually re-publishing an existing release
193+
if: >-
194+
always() &&
195+
(
196+
needs.build-release.result == 'success' ||
197+
(github.event_name == 'workflow_dispatch' && inputs.tag != '')
198+
)
188199
runs-on: ubuntu-latest
189200
permissions:
190201
contents: write
191202
steps:
203+
- name: Validate existing release has assets
204+
if: inputs.tag != ''
205+
env:
206+
GH_TOKEN: ${{ github.token }}
207+
run: |
208+
ASSET_COUNT=$(gh release view "${{ inputs.tag }}" \
209+
--repo "${{ github.repository }}" \
210+
--json assets --jq '.assets | length')
211+
echo "Release ${{ inputs.tag }} has $ASSET_COUNT asset(s)"
212+
if [ "$ASSET_COUNT" -eq 0 ]; then
213+
echo "::error::Release ${{ inputs.tag }} has no assets to sign"
214+
exit 1
215+
fi
216+
192217
- name: Import GPG signing key
193218
run: echo "${{ secrets.APT_GPG_PRIVATE_KEY }}" | gpg --batch --import
194219

195220
- name: Sign release artifacts
196221
env:
197222
GH_TOKEN: ${{ github.token }}
198223
run: |
199-
TAG="${{ needs.release-please.outputs.tag_name }}"
224+
TAG="${{ inputs.tag || needs.release-please.outputs.tag_name }}"
200225
REPO="${{ github.repository }}"
201226
mkdir -p artifacts sigs
202227
@@ -221,7 +246,7 @@ jobs:
221246
env:
222247
GH_TOKEN: ${{ github.token }}
223248
run: |
224-
gh release edit "${{ needs.release-please.outputs.tag_name }}" \
249+
gh release edit "${{ inputs.tag || needs.release-please.outputs.tag_name }}" \
225250
--draft=false \
226251
--repo "${{ github.repository }}"
227252
@@ -230,7 +255,9 @@ jobs:
230255
# ─────────────────────────────────────────────────────────────
231256
update-homebrew:
232257
needs: [release-please, publish-release]
233-
if: needs.release-please.outputs.release_created == 'true'
258+
if: >-
259+
always() &&
260+
needs.publish-release.result == 'success'
234261
runs-on: ubuntu-latest
235262
permissions:
236263
contents: read
@@ -239,7 +266,8 @@ jobs:
239266
env:
240267
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
241268
run: |
242-
VERSION="${{ needs.release-please.outputs.version }}"
269+
TAG="${{ inputs.tag || needs.release-please.outputs.tag_name }}"
270+
VERSION="${TAG#v}"
243271
BASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}"
244272
245273
# Download DMGs and compute SHA256
@@ -308,7 +336,9 @@ jobs:
308336
# ─────────────────────────────────────────────────────────────
309337
update-apt-repo:
310338
needs: [release-please, publish-release]
311-
if: needs.release-please.outputs.release_created == 'true'
339+
if: >-
340+
always() &&
341+
needs.publish-release.result == 'success'
312342
runs-on: ubuntu-latest
313343
permissions:
314344
contents: read
@@ -333,10 +363,10 @@ jobs:
333363
env:
334364
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
335365
run: |
336-
VERSION="${{ needs.release-please.outputs.version }}"
366+
TAG="${{ inputs.tag || needs.release-please.outputs.tag_name }}"
337367
mkdir -p artifacts
338368
# Download all .deb files from the release
339-
gh release download "v${VERSION}" --pattern "*.deb" --dir artifacts
369+
gh release download "$TAG" --pattern "*.deb" --dir artifacts
340370
341371
- name: Sync existing APT repo from R2
342372
run: |

0 commit comments

Comments
 (0)