Skip to content

Commit e3abea1

Browse files
authored
ci(release): add workflow_dispatch with tag input (#954)
## Summary - Adds a `workflow_dispatch` trigger to `release.yml` with a required `tag` input so maintainers can manually (re)build release artifacts for any tag when the `release: published` run failed to upload assets. - Auto-detects whether to advance the `:latest`, `:<major>`, and `:<major>.<minor>` Docker tags: a pre-goreleaser step asks GitHub for the current Latest release and sets `MOVE_TAGS=true` iff the ref being built equals it. `.goreleaser.yaml` templates each moving tag against `.Env.MOVE_TAGS` and collapses to `{{ .Version }}` (which goreleaser dedupes) when false. v2.5.0 and v2.6.0 currently have no artifacts -- both `release.yml` runs failed because `useblacksmith/setup-docker-builder` dropped an untracked `buildkitd.toml` into the repo root and goreleaser aborted on the dirty state. With this trigger, we can rebuild those tags (or any future misfire) without recutting the release and without corrupting the floating Docker tags, no manual flag required.
1 parent d14769a commit e3abea1

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ name: Release Artifacts
66
on:
77
release:
88
types: [published]
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: "Release tag to (re)build artifacts for (e.g. v2.6.0)"
13+
required: true
14+
type: string
915

1016
concurrency:
1117
group: release-artifacts
@@ -33,7 +39,7 @@ jobs:
3339

3440
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3541
with:
36-
ref: ${{ github.event.release.tag_name }}
42+
ref: ${{ github.event.release.tag_name || inputs.tag }}
3743
fetch-depth: 0
3844
persist-credentials: false
3945

@@ -53,12 +59,33 @@ jobs:
5359
username: ${{ github.actor }}
5460
password: ${{ secrets.GITHUB_TOKEN }}
5561

62+
# Advance :latest / :<major> / :<major>.<minor> only when the ref we
63+
# are building is the repository's current latest release. On a normal
64+
# release:published run, the just-published tag is the latest by
65+
# definition. On a workflow_dispatch backfill we ask GitHub which tag
66+
# it considers "Latest" and compare -- this way a backfill of an older
67+
# tag never drags the moving tags backward.
68+
- name: Determine whether to advance moving Docker tags
69+
id: move-tags
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
BUILD_REF: ${{ github.event.release.tag_name || inputs.tag }}
73+
run: |
74+
set -euo pipefail
75+
latest=$(gh release view --repo "${{ github.repository }}" --json tagName --jq .tagName)
76+
if [ "$BUILD_REF" = "$latest" ]; then
77+
echo "value=true" >> "$GITHUB_OUTPUT"
78+
else
79+
echo "value=false" >> "$GITHUB_OUTPUT"
80+
fi
81+
5682
- uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7.0.0
5783
with:
5884
version: "v2.13.3"
5985
args: release --clean
6086
env:
6187
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
MOVE_TAGS: ${{ steps.move-tags.outputs.value }}
6289

6390
- name: Clean up untagged GHCR images
6491
env:

.goreleaser.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ dockers_v2:
4242
- "ghcr.io/micasa-dev/micasa"
4343
tags:
4444
- "{{ .Version }}"
45-
- "{{ .Major }}.{{ .Minor }}"
46-
- "{{ .Major }}"
47-
- latest
45+
# Moving tags only advance when the workflow resolves MOVE_TAGS=true,
46+
# which happens iff the ref being built is the repository's current
47+
# latest release. For rebuilds of older tags MOVE_TAGS=false, each
48+
# line below collapses to {{ .Version }}, and goreleaser dedupes it
49+
# against the first tag.
50+
- '{{ if eq .Env.MOVE_TAGS "true" }}{{ .Major }}.{{ .Minor }}{{ else }}{{ .Version }}{{ end }}'
51+
- '{{ if eq .Env.MOVE_TAGS "true" }}{{ .Major }}{{ else }}{{ .Version }}{{ end }}'
52+
- '{{ if eq .Env.MOVE_TAGS "true" }}latest{{ else }}{{ .Version }}{{ end }}'
4853
platforms:
4954
- linux/amd64
5055
- linux/arm64

0 commit comments

Comments
 (0)