Skip to content

Commit 11fab32

Browse files
committed
Sync release automation to main
1 parent 4830dfb commit 11fab32

3 files changed

Lines changed: 106 additions & 1 deletion

File tree

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,55 @@ jobs:
8989
done
9090
echo "::error::Could not sync $RELEASE_TAG back to scalar-next after 3 attempts."
9191
exit 1
92+
publish:
93+
needs: release-please
94+
# `!cancelled()` keeps publishing even when the back-sync to the integration branch
95+
# failed: a raced integration branch must not block the release from reaching its
96+
# registry.
97+
if: ${{ !cancelled() && needs.release-please.outputs.release_created == 'true' }}
98+
runs-on: ubuntu-latest
99+
# Job-level permissions replace the workflow's release-cutting grants with the publish
100+
# floor. OIDC trusted publishing verifies this run's claims, which name this workflow
101+
# file — register release-please.yml as the trusted publisher on the registry.
102+
permissions:
103+
contents: read
104+
id-token: write
105+
packages: write
106+
env:
107+
VERSIONING_POLICY: manual
108+
steps:
109+
# Publishing runs inline — a top-level job of this same run — rather than dispatching
110+
# sdk-release.yml: workflow_dispatch resolves the target workflow on the repository's
111+
# default branch only, so a dispatch would 404 whenever the release line is any other
112+
# branch, while OIDC trusted publishing accepts this job because it stays top-level
113+
# (never a reusable-workflow call). The release-please job cut the tag earlier in this
114+
# run; checking it out publishes exactly the released commit, not the branch head that
115+
# triggered the workflow.
116+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
117+
with:
118+
ref: ${{ needs.release-please.outputs.tag_name }}
119+
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
120+
with:
121+
distribution: temurin
122+
java-version: "21"
123+
# `enhanced` (the default) is proprietary — free for public repos, a free preview for
124+
# private. `basic` is MIT `actions/cache` but keeps no restore keys: a dependency change
125+
# rebuilds the cache cold.
126+
- uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
127+
with:
128+
cache-provider: basic
129+
- run: ./gradlew build
130+
- name: Publish to Maven Central
131+
run: |
132+
GROUP_PATH="$(echo 'com.scalar' | tr '.' '/')"
133+
VERSION="$(sed -n 's/^[[:space:]]*version = "\(.*\)"$/\1/p' build.gradle.kts | head -n1)"
134+
if curl -sf -A "scalar-sdk-release" -o /dev/null "https://repo1.maven.org/maven2/${GROUP_PATH}/scalar-java/${VERSION}/scalar-java-${VERSION}.pom"; then
135+
echo "com.scalar:scalar-java:${VERSION} already on Maven Central, skipping"
136+
else
137+
./gradlew publishToMavenCentral --no-configuration-cache
138+
fi
139+
env:
140+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME || secrets.SONATYPE_USERNAME }}
141+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD || secrets.SONATYPE_PASSWORD }}
142+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY || secrets.GPG_SIGNING_KEY }}
143+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE || secrets.GPG_SIGNING_PASSWORD }}

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: JVM SDK Release
2+
3+
on:
4+
# Manual re-publish only: the automated publish for each release runs as the `publish` job
5+
# inside release-please.yml, in the same run that cuts the tag (dispatching a workflow here
6+
# instead would resolve it on the repository's default branch only, which breaks releasing
7+
# from any other release line). Dispatch this workflow at an existing release tag to re-run
8+
# a failed or skipped publish. A dispatched run is top-level, so OIDC trusted-publisher
9+
# claims name this file; register it as an additional trusted publisher only when manual
10+
# re-publishes are used. Never add a workflow_call trigger here — registries reject
11+
# publishes from called (reusable) workflows.
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
id-token: write
17+
packages: write
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
env:
23+
VERSIONING_POLICY: manual
24+
steps:
25+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
26+
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
27+
with:
28+
distribution: temurin
29+
java-version: "21"
30+
# `enhanced` (the default) is proprietary — free for public repos, a free preview for
31+
# private. `basic` is MIT `actions/cache` but keeps no restore keys: a dependency change
32+
# rebuilds the cache cold.
33+
- uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
34+
with:
35+
cache-provider: basic
36+
- run: ./gradlew build
37+
- name: Publish to Maven Central
38+
run: |
39+
GROUP_PATH="$(echo 'com.scalar' | tr '.' '/')"
40+
VERSION="$(sed -n 's/^[[:space:]]*version = "\(.*\)"$/\1/p' build.gradle.kts | head -n1)"
41+
if curl -sf -A "scalar-sdk-release" -o /dev/null "https://repo1.maven.org/maven2/${GROUP_PATH}/scalar-java/${VERSION}/scalar-java-${VERSION}.pom"; then
42+
echo "com.scalar:scalar-java:${VERSION} already on Maven Central, skipping"
43+
else
44+
./gradlew publishToMavenCentral --no-configuration-cache
45+
fi
46+
env:
47+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME || secrets.SONATYPE_USERNAME }}
48+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD || secrets.SONATYPE_PASSWORD }}
49+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY || secrets.GPG_SIGNING_KEY }}
50+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE || secrets.GPG_SIGNING_PASSWORD }}

‎release-please-config.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
".": {
44
"release-type": "simple",
55
"extra-files": [
6-
"build.gradle.kts"
6+
"build.gradle.kts",
7+
"README.md",
8+
"SKILL.md",
9+
".claude/skills/scalar-java-sdk/SKILL.md"
710
]
811
}
912
},

0 commit comments

Comments
 (0)