Skip to content

Commit 1493515

Browse files
committed
ci: close release packaging review gaps
1 parent a33c4da commit 1493515

7 files changed

Lines changed: 63 additions & 19 deletions

File tree

‎.github/scripts/prepare-release-candidate.py‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,22 @@ def main() -> None:
116116
distributions = {}
117117
for kind, pattern in ARCHIVE_PATTERNS.items():
118118
if kind == "source":
119-
archive_pattern = f"*{args.version}-src.zip"
119+
archive_patterns = [f"*{args.version}-src.zip"]
120120
else:
121-
archive_pattern = f"apache-shenyu-{args.version}-{kind}-bin.tar.gz"
122-
candidates = sorted(staging_repository.rglob(archive_pattern))
121+
# Maven assembly installations may retain the module artifactId in
122+
# the repository filename, while the SVN package uses the Apache
123+
# canonical name. Accept both input forms and rename below.
124+
archive_patterns = [
125+
f"apache-shenyu-{args.version}-{kind}-bin.tar.gz",
126+
f"shenyu-{kind}-dist-{args.version}-{kind}-bin.tar.gz",
127+
]
128+
candidates = sorted({
129+
candidate
130+
for archive_pattern in archive_patterns
131+
for candidate in staging_repository.rglob(archive_pattern)
132+
})
123133
if len(candidates) != 1:
124-
raise SystemExit(f"Expected one {kind} distribution matching {pattern}, found {len(candidates)}")
134+
raise SystemExit(f"Expected one {kind} distribution matching {archive_patterns}, found {len(candidates)}")
125135
target = copy_distribution(candidates[0], args.svn_dir, args.version, kind)
126136
sign(target, args.key_id, args.passphrase_file)
127137
checksum(target, "sha512", ".sha512")

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@
1515

1616
name: ci
1717

18+
run-name: >-
19+
${{ github.event_name == 'workflow_dispatch' && inputs.release_candidate
20+
&& format('Release candidate {0}', inputs.release_dispatch_id)
21+
|| github.workflow }}
22+
1823
on:
1924
workflow_dispatch:
2025
inputs:
2126
release_candidate:
2227
description: Build unsigned release artifacts with Javadocs and legal resources
2328
type: boolean
2429
default: false
30+
release_dispatch_id:
31+
description: Unique release workflow correlation identifier
32+
type: string
33+
required: false
34+
default: ''
2535
# Required checks must report a result even for documentation-only PRs.
2636
pull_request:
2737
push:
@@ -237,7 +247,7 @@ jobs:
237247
bash .github/scripts/maven-with-retry.sh ./mvnw -B -ntp \
238248
-pl shenyu-admin,shenyu-bootstrap,shenyu-dist/shenyu-admin-dist,shenyu-dist/shenyu-bootstrap-dist \
239249
dependency:list -DincludeScope=runtime -DoutputFile=target/release-runtime-dependencies.txt
240-
python3 .github/scripts/collect-release-licenses.py
250+
python3 .github/scripts/collect-release-licenses.py --check
241251
- name: Check out the pinned ShenYu license verifier
242252
if: github.event_name == 'workflow_dispatch' && inputs.release_candidate
243253
uses: actions/checkout@v4

‎.github/workflows/release-candidate.yml‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,21 @@ jobs:
105105
echo "release_ref must resolve to an existing remote branch" >&2
106106
exit 1
107107
}
108+
branch_protected="$(gh api "repos/${GITHUB_REPOSITORY}/branches/${RELEASE_REF}" --jq .protected)"
109+
[[ "$branch_protected" == "true" ]] || {
110+
echo "release_ref must be a GitHub-protected branch" >&2
111+
exit 1
112+
}
108113
branch_sha="$(gh api "repos/${GITHUB_REPOSITORY}/branches/${RELEASE_REF}" --jq .commit.sha)"
109114
remote_sha="$(git ls-remote origin "refs/heads/${RELEASE_REF}" | awk '{print $1}')"
110115
[[ -n "$remote_sha" && "$remote_sha" == "$branch_sha" && "$remote_sha" == "$(git rev-parse HEAD)" ]] || {
111116
echo "Checked out release ref does not match the explicit refs/heads/${RELEASE_REF} branch" >&2
112117
exit 1
113118
}
114119
environment_rules="$(gh api "repos/${GITHUB_REPOSITORY}/environments/apache-release-candidate" \
115-
--jq '[.protection_rules[] | select(.type == "required_reviewers")] | length' 2>/dev/null || true)"
120+
--jq '[.protection_rules[] | select(.type == "required_reviewers" and (.reviewers | length > 0))] | length' 2>/dev/null || true)"
116121
[[ "$environment_rules" =~ ^[1-9][0-9]*$ ]] || {
117-
echo "Configure at least one required_reviewers protection rule for the apache-release-candidate environment before staging" >&2
122+
echo "Configure at least one required_reviewers rule with reviewers for the apache-release-candidate environment before staging" >&2
118123
exit 1
119124
}
120125
version="$(python3 - <<'PYTHON'
@@ -151,13 +156,16 @@ jobs:
151156
run: |
152157
set -euo pipefail
153158
started_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
154-
gh workflow run ci.yml --ref "$RELEASE_REF" -f release_candidate=true
159+
dispatch_id="$(uuidgen | tr '[:upper:]' '[:lower:]')"
160+
echo "dispatch_id=$dispatch_id" >> "$GITHUB_OUTPUT"
161+
gh workflow run ci.yml --ref "$RELEASE_REF" \
162+
-f release_candidate=true -f release_dispatch_id="$dispatch_id"
155163
run_id=""
156164
for attempt in {1..60}; do
157165
run_id="$(gh run list --workflow ci.yml --event workflow_dispatch --limit 20 \
158-
--json databaseId,headSha,createdAt | \
159-
python3 -c 'import json, sys; sha, started = sys.argv[1:]; runs = json.load(sys.stdin); matches = [r for r in runs if r.get("headSha") == sha and r.get("createdAt", "") >= started]; print(matches[0]["databaseId"] if matches else "")' \
160-
"$release_sha" "$started_at")"
166+
--json databaseId,headSha,createdAt,displayTitle | \
167+
python3 -c 'import json, sys; sha, started, dispatch = sys.argv[1:]; runs = json.load(sys.stdin); title = f"Release candidate {dispatch}"; matches = [r for r in runs if r.get("headSha") == sha and r.get("createdAt", "") >= started and r.get("displayTitle") == title]; print(matches[0]["databaseId"] if matches else "")' \
168+
"$release_sha" "$started_at" "$dispatch_id")"
161169
[[ -n "$run_id" ]] && break
162170
sleep 10
163171
done

‎docs/release-ci.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Configure these secrets in the Apache `apache/shenyu` repository. They are consu
1717

1818
The signing key fingerprint and Sonatype staging profile are workflow inputs, so the workflow summary records exactly which public key and profile were used. The private key and passphrase are never written to artifacts or the step summary.
1919

20-
Create the `apache-release-candidate` GitHub Environment in the Apache repository and configure at least one required reviewer. The staging job is bound to this environment and refuses to continue when the environment has no protection rule. This approval is the trusted gate for the release branch before LDAP and GPG secrets are made available. The workflow also resolves `release_ref` as an existing branch, rejects SNAPSHOT POMs, and rejects an already-existing candidate tag or SVN directory.
20+
Protect each `<version>-release` branch in the Apache repository and create the `apache-release-candidate` GitHub Environment with at least one required reviewer. The staging job verifies both the branch protection flag and a nonempty reviewer rule before LDAP and GPG secrets are made available. The workflow also resolves `release_ref` as an existing branch, rejects SNAPSHOT POMs, rejects an already-existing candidate tag or SVN directory, and correlates the dispatched CI run with a unique identifier before downloading artifacts.
2121

2222
## Run a candidate
2323

‎script/source-release.xml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,5 @@
7171
<exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?release\.properties]</exclude>
7272
</excludes>
7373
</fileSet>
74-
<!-- license, readme, etc. calculated at build time -->
75-
<fileSet>
76-
<directory>${project.build.directory}/maven-shared-archive-resources/META-INF</directory>
77-
<outputDirectory></outputDirectory>
78-
</fileSet>
7974
</fileSets>
8075
</assembly>

‎shenyu-admin/pom.xml‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,29 @@
440440
<encoding>${project.build.sourceEncoding}</encoding>
441441
<useDefaultDelimiters>true</useDefaultDelimiters>
442442
</configuration>
443+
<executions>
444+
<execution>
445+
<id>dashboard-release-legal-materials</id>
446+
<phase>generate-resources</phase>
447+
<goals>
448+
<goal>copy-resources</goal>
449+
</goals>
450+
<configuration>
451+
<!-- The standalone main and sources JARs also distribute the dashboard bundle. -->
452+
<outputDirectory>${project.build.directory}/maven-shared-archive-resources/META-INF/licenses</outputDirectory>
453+
<resources>
454+
<resource>
455+
<directory>${maven.multiModuleProjectDirectory}/shenyu-dist/shenyu-admin-dist/src/main/release-docs/licenses</directory>
456+
<filtering>false</filtering>
457+
<includes>
458+
<include>LICENSE-dashboard.txt</include>
459+
<include>NOTICE-dashboard.txt</include>
460+
</includes>
461+
</resource>
462+
</resources>
463+
</configuration>
464+
</execution>
465+
</executions>
443466
</plugin>
444467
</plugins>
445468

‎shenyu-dist/shenyu-src-dist/src/main/assembly/source.xml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282
<exclude>shenyu-integrated-test/**</exclude>
8383
<exclude>shenyu-examples/**</exclude>
8484
<exclude>shenyu-dashboard/**</exclude>
85-
<exclude>shenyu-admin/src/main/resources/static/*.css</exclude>
86-
<exclude>shenyu-admin/src/main/resources/static/*.js</exclude>
8785
<exclude>shenyu-e2e</exclude>
8886
</excludes>
8987
</fileSet>

0 commit comments

Comments
 (0)