Skip to content

Commit 68971ba

Browse files
authored
ci: resolve the RC tag automatically on manual dispatch (#78)
The Release workflow_dispatch no longer takes a tag input. Like the nightly flow, it numbers the next release candidate itself (v<major>-rc1, rc2, ...), tags current main, runs CI against it, and publishes the pre-release. Publishing an RC deletes all nightly pre-releases, since the RC supersedes the nightly line.
1 parent 1719a45 commit 68971ba

2 files changed

Lines changed: 75 additions & 25 deletions

File tree

.github/workflows/release.yml

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,76 @@ on:
66
- 'v[0-9]*'
77
- '!v[0-9]*-rc*'
88
workflow_dispatch:
9-
inputs:
10-
tag:
11-
description: Release candidate tag to publish (e.g. v49.0-rc1)
12-
required: true
13-
type: string
149

1510
permissions:
1611
contents: write
1712
packages: write
1813

19-
env:
20-
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
21-
2214
jobs:
15+
state:
16+
name: Resolve release target
17+
runs-on: ubuntu-latest
18+
outputs:
19+
tag_name: ${{ steps.state.outputs.tag_name }}
20+
head_sha: ${{ steps.state.outputs.head_sha }}
21+
steps:
22+
- uses: actions/checkout@v7
23+
with:
24+
fetch-depth: 0
25+
ref: main
26+
27+
# Stable releases come from a pushed tag. Release candidates are
28+
# dispatched manually and numbered automatically (rc1, rc2, ...),
29+
# tagging current main, exactly like the nightly flow does.
30+
- name: Resolve release target
31+
id: state
32+
run: |
33+
set -euo pipefail
34+
35+
event_name="${{ github.event_name }}"
36+
if [[ "$event_name" == "push" ]]; then
37+
echo "tag_name=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
38+
echo "head_sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
39+
exit 0
40+
fi
41+
42+
VERSION_NAME="$(node -e 'const fs = require("fs"); const metadata = JSON.parse(fs.readFileSync("metadata.json", "utf8")); process.stdout.write(metadata["version-name"]);')"
43+
TAG_PREFIX="v${VERSION_NAME}-rc"
44+
LAST_RC="$(
45+
git tag --list "${TAG_PREFIX}*" |
46+
awk -v prefix="$TAG_PREFIX" '
47+
index($0, prefix) == 1 {
48+
number = substr($0, length(prefix) + 1)
49+
if (number ~ /^[0-9]+$/) print number
50+
}
51+
' |
52+
sort -n |
53+
tail -n 1
54+
)"
55+
NEXT_RC=$(( ${LAST_RC:-0} + 1 ))
56+
TAG_NAME="${TAG_PREFIX}${NEXT_RC}"
57+
HEAD_SHA="$(git rev-parse HEAD)"
58+
59+
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
60+
echo "head_sha=${HEAD_SHA}" >> "$GITHUB_OUTPUT"
61+
echo "Release candidate ${TAG_NAME} will be built from ${HEAD_SHA}." >> "$GITHUB_STEP_SUMMARY"
62+
2363
ci:
2464
if: ${{ github.event_name == 'workflow_dispatch' || !contains(github.ref_name, '-') }}
65+
needs: [state]
2566
uses: ./.github/workflows/ci.yml
2667
with:
27-
checkout_ref: ${{ inputs.tag || '' }}
68+
checkout_ref: ${{ needs.state.outputs.head_sha }}
2869

2970
release:
3071
name: Create GitHub Release
3172
if: ${{ github.event_name == 'workflow_dispatch' || !contains(github.ref_name, '-') }}
3273
runs-on: ubuntu-latest
33-
needs: [ci]
74+
needs: [state, ci]
3475
steps:
35-
- name: Validate release candidate tag
36-
if: ${{ github.event_name == 'workflow_dispatch' }}
37-
run: |
38-
set -euo pipefail
39-
tag="${{ inputs.tag }}"
40-
if [[ "$tag" != *-rc* ]]; then
41-
echo "Tag '$tag' is not a release candidate (expected to contain '-rc')." >&2
42-
exit 1
43-
fi
44-
4576
- uses: actions/checkout@v7
4677
with:
47-
ref: ${{ inputs.tag || '' }}
78+
ref: ${{ needs.state.outputs.head_sha }}
4879

4980
- name: Download extension zip
5081
uses: actions/download-artifact@v8
@@ -55,16 +86,35 @@ jobs:
5586
- name: Create GitHub Release
5687
uses: softprops/action-gh-release@v3
5788
with:
58-
tag_name: ${{ env.RELEASE_TAG }}
59-
name: ${{ env.RELEASE_TAG }}
89+
tag_name: ${{ needs.state.outputs.tag_name }}
90+
target_commitish: ${{ needs.state.outputs.head_sha }}
91+
name: ${{ needs.state.outputs.tag_name }}
6092
files: dist/target/aurora-shell@luminusos.github.io.shell-extension.zip
6193
generate_release_notes: true
6294
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
6395

96+
# An RC supersedes the nightly line: once a release candidate is out,
97+
# the nightly pre-releases are removed like superseded nightlies are.
98+
- name: Delete superseded nightly pre-releases
99+
if: ${{ github.event_name == 'workflow_dispatch' }}
100+
env:
101+
GH_TOKEN: ${{ github.token }}
102+
run: |
103+
set -euo pipefail
104+
105+
gh release list \
106+
--limit 1000 \
107+
--json tagName,isPrerelease \
108+
--jq '.[] | select(.isPrerelease and (.tagName | test("-nightly[0-9]+$"))) | .tagName' |
109+
while IFS= read -r nightly_tag; do
110+
gh release delete "$nightly_tag" --cleanup-tag --yes
111+
echo "Deleted superseded nightly ${nightly_tag}." >> "$GITHUB_STEP_SUMMARY"
112+
done
113+
64114
- name: Create maintenance branch
65115
if: ${{ github.event_name == 'push' }}
66116
run: |
67-
MAJOR=$(echo "${{ env.RELEASE_TAG }}" | sed 's/^v//' | grep -oP '^\d+')
117+
MAJOR=$(echo "${{ needs.state.outputs.tag_name }}" | sed 's/^v//' | grep -oP '^\d+')
68118
BRANCH="release/v${MAJOR}.x"
69119
if git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null 2>&1; then
70120
echo "Branch $BRANCH already exists, skipping."

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ and adds a final version bump commit. For example, if `metadata.json` on `releas
103103

104104
Release candidates are published alongside GNOME Shell RCs. Tags follow the pattern `v50-rc1`, `v50-rc2`, etc. RC releases are marked as **pre-releases** on GitHub.
105105

106-
Pushing an RC tag does **not** publish anything. After pushing the tag, trigger the `Release` workflow manually (`workflow_dispatch`) and pass the tag name in the `tag` input. The workflow validates that the tag contains `-rc`, runs CI against it, and publishes the pre-release.
106+
To publish an RC, trigger the `Release` workflow manually (`workflow_dispatch`) — no input is needed. Like the nightly flow, the workflow numbers the next candidate automatically (`v50-rc1`, then `v50-rc2`, ...), tags current `main`, runs CI against it, and publishes the pre-release. An RC supersedes the nightly line, so publishing one deletes all nightly pre-releases.
107107

108108
### Stable releases
109109

0 commit comments

Comments
 (0)