Skip to content

Commit dae30d2

Browse files
authored
ci: split release profile CI into two tiers (a2aproject#972)
Tier 1 (all PRs, no secrets): runs mvn install -Prelease with GPG and publishing skipped to catch compilation/javadoc issues early. Tier 2 (allow-listed actors + protected branch pushes, with secrets): adds actor allow-list, allow-unsafe-pr-checkout, and Sonatype credential validation. Fixes actions/checkout@v7 fork-checkout block.
1 parent 5b0c155 commit dae30d2

3 files changed

Lines changed: 63 additions & 13 deletions

File tree

‎.github/workflows/build-with-release-profile-run.yml‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ jobs:
1717
build:
1818
# Only run for successful trigger workflow from main repository
1919
if: >
20-
${{ github.event.workflow_run.conclusion == 'success' &&
21-
github.event.workflow_run.repository.full_name == 'a2aproject/a2a-java' }}
20+
github.event.workflow_run.conclusion == 'success' &&
21+
github.event.workflow_run.repository.full_name == 'a2aproject/a2a-java' &&
22+
(
23+
(github.event.workflow_run.event == 'push' &&
24+
contains(fromJSON('["main", "0.3.x"]'), github.event.workflow_run.head_branch)) ||
25+
github.event.workflow_run.event == 'workflow_dispatch' ||
26+
contains(fromJSON('["kkhan", "jmesnil", "ehsavoie", "maeste"]'), github.event.workflow_run.actor.login)
27+
)
2228
runs-on: ubuntu-latest
2329
permissions:
2430
contents: read
@@ -70,9 +76,11 @@ jobs:
7076
- name: Checkout PR code
7177
uses: actions/checkout@v7
7278
with:
73-
# Checkout the exact commit from the PR (or push)
74-
# This is safe because the workflow code (this file) is always from main
7579
ref: ${{ steps.pr_info.outputs.pr_sha }}
80+
# Safe: the job-level if condition restricts this to allow-listed actors
81+
# and protected branch pushes. This file is always loaded from the default
82+
# branch, so fork PRs cannot modify the allow-list.
83+
allow-unsafe-pr-checkout: true
7684

7785
- name: Set up JDK 17
7886
uses: actions/setup-java@v5
@@ -95,6 +103,19 @@ jobs:
95103
mkdir -p ~/.m2
96104
echo "<settings><servers><server><id>central-a2asdk-temp</id><username>${{ secrets.CENTRAL_TOKEN_USERNAME }}</username><password>${{ secrets.CENTRAL_TOKEN_PASSWORD }}</password></server></servers></settings>" > ~/.m2/settings.xml
97105
106+
- name: Validate Maven Central credentials
107+
run: |
108+
TOKEN=$(printf "%s:%s" "${{ secrets.CENTRAL_TOKEN_USERNAME }}" "${{ secrets.CENTRAL_TOKEN_PASSWORD }}" | base64)
109+
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
110+
-H "Authorization: Bearer $TOKEN" \
111+
-X POST \
112+
"https://central.sonatype.com/api/v1/publisher/status?id=nonexistent")
113+
if [ "$HTTP_STATUS" != "404" ]; then
114+
echo "::error::Maven Central credentials validation failed (HTTP $HTTP_STATUS, expected 404)"
115+
exit 1
116+
fi
117+
echo "Maven Central credentials are valid"
118+
98119
# Build with the same settings as the deploy job
99120
# -s uses the settings file we created.
100121
- name: Build with same arguments as deploy job

‎.github/workflows/build-with-release-profile.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ jobs:
2828
contents: read
2929

3030
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v7
33+
34+
- name: Set up JDK 17
35+
uses: actions/setup-java@v5
36+
with:
37+
java-version: '17'
38+
distribution: 'temurin'
39+
cache: maven
40+
41+
- name: Build with release profile (no secrets)
42+
run: >
43+
mvn -B install
44+
-Prelease
45+
-DskipTests
46+
-Dgpg.skip=true
47+
-Drelease.auto.publish=false
48+
3149
- name: Prepare PR info
3250
run: |
3351
mkdir -p pr_info

‎RELEASE.md‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,20 @@ Open PR on GitHub with title: `chore: release 0.4.0.Alpha1`
7979

8080
### 4. CI Verification
8181

82-
The `build-with-release-profile.yml` workflow automatically verifies:
83-
- ✅ Build succeeds with `-Prelease` profile
82+
The release profile CI runs in two tiers:
83+
84+
**Tier 1** (all PRs, no secrets):
85+
- ✅ Build succeeds with `-Prelease` profile (`-DskipTests -Dgpg.skip=true -Drelease.auto.publish=false`)
8486
- ✅ All JavaDoc generation succeeds
85-
- ✅ GPG signing works correctly
8687
- ✅ JBang version validation passes
87-
- ✅ No compilation or test failures
88+
- ✅ No compilation failures
8889

89-
**Important**: This workflow tests the actual PR branch (not main) to catch issues before merge.
90+
**Tier 2** (allow-listed maintainers and pushes to `main`/`0.3.x`, with secrets):
91+
- ✅ GPG signing works correctly
92+
- ✅ Maven Central credentials are valid
93+
- ✅ Full release profile build succeeds
94+
95+
**Important**: Tier 2 only runs for allow-listed actors (see `build-with-release-profile-run.yml`). Fork PRs from other contributors get Tier 1 only.
9096

9197
Wait for all CI checks to pass before proceeding.
9298

@@ -249,10 +255,15 @@ Follow semantic versioning with qualifiers:
249255

250256
## Workflows Reference
251257

252-
### build-with-release-profile.yml
253-
- **Triggers**: All PRs, all pushes
254-
- **Purpose**: Verify builds with `-Prelease` profile
255-
- **Special**: Tests actual PR branch (not main) using `pull_request_target` with explicit checkout
258+
### build-with-release-profile.yml (Tier 1 — Trigger)
259+
- **Triggers**: All PRs, all pushes, manual dispatch
260+
- **Purpose**: Build with `-Prelease` profile without secrets; upload PR info for Tier 2
261+
- **Catches**: Compilation, javadoc, plugin configuration issues
262+
263+
### build-with-release-profile-run.yml (Tier 2 — Secrets)
264+
- **Triggers**: `workflow_run` on Tier 1 completion
265+
- **Purpose**: Full release profile build with GPG signing and Maven Central credential validation
266+
- **Access**: Allow-listed maintainers, pushes to `main`/`0.3.x`, manual dispatch
256267
- **Requires**: GPG and Maven Central secrets
257268

258269
### release-to-maven-central.yml

0 commit comments

Comments
 (0)