Repository navigation
365 lines (326 loc) · 16.7 KB
/
Copy pathrelease.yml
File metadata and controls
365 lines (326 loc) · 16.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
name: Release
# There is deliberately NO `pull_request` trigger, and deliberately no test,
# ABI-check, or Gradle verification job anywhere in this file — not even the
# Ubuntu-runnable ones. SDK verification happens locally, before the PR, via
# `scripts/release-readiness.sh`; see root AGENTS.md. Cheap runner minutes are
# not the reason those jobs are absent, so "but it would only cost Ubuntu
# minutes" is not a reason to add them back. This pipeline delivers; it does
# not gate.
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: read
# A push to master reaches the upload/deploy steps, and aborting a run that is
# mid-upload to Cloudflare or Maven Central leaves partial external state, so
# overlapping runs of this pipeline are serialised rather than cancelled.
concurrency:
group: release-pipeline
cancel-in-progress: false
jobs:
gate:
name: Gate
runs-on: ubuntu-latest
outputs:
version: ${{ steps.decide.outputs.version }}
should_release: ${{ steps.decide.outputs.should_release }}
should_deploy_docs: ${{ steps.decide.outputs.should_deploy_docs }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
- id: decide
env:
BEFORE: ${{ github.event.before }}
run: |
set -eu
lib="$(sed -n 's/^VERSION_NAME=//p' gradle.properties)"
plugin="$(sed -n 's/^VERSION_NAME=//p' admob-cmp-gradle-plugin/gradle.properties)"
[ -n "$lib" ] || { echo "VERSION_NAME missing from gradle.properties" >&2; exit 1; }
if [ "$lib" != "$plugin" ]; then
echo "Version mismatch: library is $lib but plugin is $plugin." >&2
echo "Bump both gradle.properties files in lockstep." >&2
exit 1
fi
on_master=false
[ "$GITHUB_REF" = "refs/heads/master" ] && on_master=true
tagged=false
git rev-parse -q --verify "refs/tags/$lib" >/dev/null 2>&1 && tagged=true
should_release=false
if [ "$on_master" = true ] && [ "$tagged" = false ]; then should_release=true; fi
docs=false
if [ "$should_release" = true ]; then
docs=true
elif [ "$GITHUB_EVENT_NAME" != "push" ]; then
docs=true
elif ! git cat-file -e "$BEFORE^{commit}" 2>/dev/null; then
docs=true
elif git diff --name-only "$BEFORE" "$GITHUB_SHA" | grep -qE \
'^(docs-site/|admob-cmp/|admob-cmp-core/|admob-cmp-compose/|gradle/libs\.versions\.toml|gradle\.properties|\.github/workflows/release\.yml)'; then
docs=true
fi
{
echo "version=$lib"
echo "should_release=$should_release"
echo "should_deploy_docs=$docs"
} >> "$GITHUB_OUTPUT"
- name: Decision
run: |
{
echo "### Release gate"
echo
echo "- version: \`${{ steps.decide.outputs.version }}\`"
echo "- should_release: \`${{ steps.decide.outputs.should_release }}\`"
echo "- should_deploy_docs: \`${{ steps.decide.outputs.should_deploy_docs }}\`"
echo
} >> "$GITHUB_STEP_SUMMARY"
if [ "${{ steps.decide.outputs.should_release }}" = "false" ] && [ "${{ steps.decide.outputs.should_deploy_docs }}" = "false" ]; then
echo "VERSION_NAME is unchanged and no docs-relevant paths were touched — nothing to do." >> "$GITHUB_STEP_SUMMARY"
fi
# Dokka cannot run on Linux: the iOS cinterop tasks in the
# dokkaGeneratePublicationHtml graph (cinteropGmaIosArm64, cinteropUmpIosArm64,
# cinteropGmaIosSimulatorArm64, cinteropUmpIosSimulatorArm64, compileKotlinIosArm64,
# compileKotlinIosSimulatorArm64) require the iOS SDK headers shipped with
# Xcode, which the ubuntu-latest runner has no access to. Suppressing the iOS
# Dokka source set is not an option: admob-cmp-core/src/iosMain carries
# genuinely iOS-only public API (IosAdMob, BannerAdController.attachIosBanner,
# BannerAdController.registerIosBannerGeometry, NativeAdPool.peekIosNativeAd,
# iosAppForegroundState) and dropping it would silently gut /api/. This job
# therefore stays on macos-26.
api-reference:
name: Dokka API reference
needs: gate
if: needs.gate.outputs.should_deploy_docs == 'true'
runs-on: macos-26
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
# The cache MUST be restored before any step that gates on its
# `cache-hit` output. A step referencing `steps.dokka-cache.outputs` that
# runs earlier in the job sees an empty string, so `!= 'true'` is
# trivially true and the guard silently does nothing.
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
id: dokka-cache
with:
path: docs-site/public/api
key: dokka-html-${{ hashFiles('admob-cmp/src/**', 'admob-cmp-core/src/**', 'admob-cmp-compose/src/**', 'admob-cmp/build.gradle.kts', 'admob-cmp-core/build.gradle.kts', 'admob-cmp-compose/build.gradle.kts', 'build.gradle.kts', 'gradle/libs.versions.toml', 'gradle.properties') }}
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
if: steps.dokka-cache.outputs.cache-hit != 'true'
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6
if: steps.dokka-cache.outputs.cache-hit != 'true'
- name: Assert Xcode 26 (iOS Simulator SDK 26)
if: steps.dokka-cache.outputs.cache-hit != 'true'
run: xcodebuild -showsdks | grep -q "iphonesimulator26" || { echo "SDK 26 not found"; xcodebuild -showsdks; exit 1; }
# admob-cmp-gradle-plugin is an included build, so Gradle builds it on
# demand as part of this task graph. Do not add an explicit
# `-p admob-cmp-gradle-plugin build` step: it is redundant, and `build`
# implies `check`, which would run the plugin's test suite in CI.
- name: Generate the Dokka API reference into docs-site/public/api
if: steps.dokka-cache.outputs.cache-hit != 'true'
run: ./gradlew syncApiDocsToDocsSite --no-configuration-cache
# The Dokka dump is thousands of small files and upload-artifact is
# pathologically slow on those; one tarball uploads in seconds.
- name: Tar the Dokka dump
run: tar -czf api-reference.tgz -C docs-site/public api
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: api-reference
path: api-reference.tgz
retention-days: 1
if-no-files-found: error
docs-site:
name: Build and deploy ads.avinya.dev
needs: [gate, api-reference]
if: needs.gate.outputs.should_deploy_docs == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
# Starlight's `lastUpdated` reads each page's git history. A shallow
# clone silently produces no timestamps and empty `dateModified`
# values in the TechArticle JSON-LD.
fetch-depth: 0
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: api-reference
- name: Unpack the Dokka API reference
run: |
mkdir -p docs-site/public
tar -xzf api-reference.tgz -C docs-site/public
if [ ! -f docs-site/public/api/index.html ]; then
echo "FATAL: docs-site/public/api/index.html is missing after unpacking the api-reference artifact." >&2
exit 1
fi
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: "22"
cache: npm
cache-dependency-path: docs-site/package-lock.json
- name: Install docs-site dependencies
run: npm ci
working-directory: docs-site
# rehype-mermaid renders diagrams to static SVG at BUILD time and drives
# a headless Chromium to do it. `--with-deps` is Linux-only and installs
# the system libraries headless Chromium needs; on this ubuntu-latest
# runner it MUST NOT be dropped.
- name: Install the Chromium build used by rehype-mermaid
run: npx playwright install --with-deps chromium
working-directory: docs-site
- name: Build the site
run: npm run build
working-directory: docs-site
# The one permitted test step in this pipeline: the docs site's own
# Vitest suite. It is part of building the site, not of verifying the
# SDK, and is not a precedent for adding SDK test jobs.
#
# Runs AFTER the build, not before. Some cases assert against dist/
# output (exact rendered <h1>, format/roadmap order, the diagram
# gallery) and hard-fail rather than skip when dist/ is absent — running
# this step first left that coverage silently dead in CI, since nothing
# here re-runs npm test after the build. See AGENTS.md.
- name: Unit-test the docs site
run: npm test
working-directory: docs-site
- name: Verify the built output
run: npm run verify
working-directory: docs-site
- name: Deploy to Cloudflare Pages
if: github.ref == 'refs/heads/master'
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# The Pages project name lives here and nowhere else. The host guard
# in docs-site/functions/_middleware.js derives the preview hosts by
# label count rather than matching this string, so renaming the
# project only requires changing this line.
command: pages deploy dist --project-name=admob-compose-multiplatform --branch=master
workingDirectory: docs-site
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish to Maven Central
needs: gate
permissions:
contents: read
# Required by actions/attest-build-provenance to mint and record the attestation.
id-token: write
attestations: write
if: needs.gate.outputs.should_release == 'true'
# Gates the only job that receives Maven signing and Central credentials behind a protected
# environment. Without it, merging a version bump to master immediately uploads a signed
# staging deployment with no human in the loop -- the manual Central release step limits final
# exposure, but the runner still uses the secrets automatically. Configure required reviewers
# on this environment in repository settings; the name here is the half that lives in code.
environment: maven-central
runs-on: macos-26
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6
- name: Assert Xcode 26 (iOS Simulator SDK 26)
run: xcodebuild -showsdks | grep -q "iphonesimulator26" || { echo "SDK 26 not found"; xcodebuild -showsdks; exit 1; }
# Provenance is generated and attested BEFORE the upload, and deliberately so. Nothing here
# reads the deployment -- the script publishes into a throwaway repository of its own -- while
# the upload is the one step that cannot be undone. Run afterwards, a transient failure in
# either step failed the job *after* a signed deployment had already landed, which skipped
# tagging and left the release gate armed, so the next push re-published the same version as a
# second staging deployment that a human then had to find and drop by hand.
- name: Generate release provenance assets
run: ./scripts/distribution/generate-release-provenance.sh "$RUNNER_TEMP/provenance" "$GITHUB_SHA"
- name: Attest build provenance
# First-party GitHub action producing SLSA provenance signed by the workflow identity, so a
# consumer can verify WHICH commit and workflow produced these artifacts. Maven Central
# signatures prove the publisher's key, not the build's origin.
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2
with:
# Both assets, not just the manifest: an SBOM nobody can verify the integrity of is a
# claim rather than evidence.
subject-path: |
${{ runner.temp }}/provenance/checksums.txt
${{ runner.temp }}/provenance/sbom.spdx.json
- name: Publish to Maven Central
run: ./admob-cmp/scripts/publish-maven-central.sh
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: release-provenance
path: ${{ runner.temp }}/provenance/
if-no-files-found: error
- name: Record the manual Central Portal release steps
run: |
{
echo "### Maven Central staging deployments"
echo
echo "Two staging deployments were uploaded to Central Portal — one for the library, one for the Gradle plugin."
echo
echo "Both must be released manually in Central Portal before the artifacts are live:"
echo
echo "https://central.sonatype.com/publishing/deployments"
echo
echo "Releasing only one ships a library whose documented Gradle plugin does not exist at this version."
echo
echo "**No automated verification ran before this upload.** This pipeline runs no SDK tests;"
echo "the staging review in Central Portal is the only remaining check."
} >> "$GITHUB_STEP_SUMMARY"
tag-and-release:
name: Tag and cut GitHub release
needs: [gate, publish]
if: needs.gate.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: release-provenance
path: provenance
- name: Tag the release
run: |
set -eu
version="${{ needs.gate.outputs.version }}"
if git rev-parse -q --verify "refs/tags/$version" >/dev/null 2>&1; then
echo "Tag $version already exists — skipping tag creation."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "$version" -m "Release $version" "$GITHUB_SHA"
git push origin "$version"
- name: Create the GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
version="${{ needs.gate.outputs.version }}"
if gh release view "$version" >/dev/null 2>&1; then
echo "Release $version already exists — skipping release creation."
exit 0
fi
notes="$(printf '%s\n\n%s\n\n%s\n\n%s' \
"AdMob CMP $version is an open-source Kotlin Multiplatform and Compose Multiplatform SDK for Google AdMob on Android and iOS." \
"Install the Maven artifact \`dev.avinya.ads:admob-cmp:$version\`. It supports banner, interstitial, rewarded, rewarded interstitial, app-open, and native ads. See the [documentation](https://ads.avinya.dev/start/quickstart/) and [compatibility guide](https://ads.avinya.dev/reference/compatibility/)." \
"**Two Maven Central staging deployments were created and still require manual release in [Central Portal](https://central.sonatype.com/publishing/deployments):** one for the library, one for the Gradle plugin. Until both are released, this GitHub release refers to artifacts that are not yet publicly available." \
"## Changes")"
gh release create "$version" \
--title "AdMob CMP $version — Compose Multiplatform AdMob SDK" \
--notes "$notes" \
--generate-notes \
provenance/checksums.txt \
provenance/sbom.spdx.json