-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (187 loc) · 7.96 KB
/
Copy pathpublish-android.yml
File metadata and controls
204 lines (187 loc) · 7.96 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
# Publishes com.gettugboat.sdk:capture-runtime from platforms/android.
#
# Merging a PR does not publish by itself. This workflow:
# 1. On push to main, creates tag capture-runtime-v<version> when that version
# is not already on GitHub Packages (or Maven Central, once configured).
# 2. On that tag (push or workflow_dispatch), publishes the AAR.
# 3. After a tag publish, waits for Maven Central repo1 then opens a Flutter
# pin PR (chore/pin-capture-runtime-<version>) if the plugin still lags.
#
# GitHub Packages is the default hosted registry (GITHUB_TOKEN). Maven Central
# is optional until namespace + secrets exist; see docs/releases/process.md.
name: Publish Android runtime
on:
push:
branches:
- main
tags:
- 'capture-runtime-v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
concurrency:
group: publish-android-${{ github.ref }}
cancel-in-progress: false
jobs:
tag_main:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
packages: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve version
id: version
env:
GH_TOKEN: ${{ github.token }}
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
run: |
set -euo pipefail
version="$(bash tool/ci/android-runtime-version.sh)"
tag="capture-runtime-v${version}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "capture-runtime version: ${version}"
github_exists=false
if versions="$(gh api "/orgs/blendto/packages/maven/com.gettugboat.sdk.capture-runtime/versions" --jq '.[].name' 2>/dev/null)"; then
if printf '%s\n' "$versions" | grep -qx "${version}"; then
github_exists=true
fi
fi
central_code="$(curl -sS -o /dev/null -w '%{http_code}' \
"https://repo1.maven.org/maven2/com/gettugboat/sdk/capture-runtime/${version}/capture-runtime-${version}.pom")"
echo "GitHub Packages has ${version}: ${github_exists}"
echo "Maven Central POM: ${central_code}"
if [[ "$github_exists" == "true" && "$central_code" == "200" ]]; then
echo "capture-runtime ${version} is already on GitHub Packages and Maven Central."
echo "should_publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "$github_exists" == "true" && -z "${MAVEN_CENTRAL_USERNAME}" ]]; then
echo "GitHub Packages already has ${version}; Maven Central is not configured."
echo "should_publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "should_publish=true" >> "$GITHUB_OUTPUT"
- name: Create tag and dispatch publish
if: steps.version.outputs.should_publish == 'true'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
TAG: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
git fetch --tags origin
if git rev-parse "refs/tags/${TAG}" >/dev/null 2>&1; then
echo "Tag ${TAG} already exists."
else
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${TAG}" -m "capture-runtime ${VERSION}"
git push origin "${TAG}"
fi
# GITHUB_TOKEN tag pushes do not trigger other workflows. Dispatch on
# the tag so the publish job sees refType=tag.
for attempt in 1 2 3 4 5 6 7 8; do
if gh workflow run publish-android.yml --ref "${TAG}"; then
echo "Dispatched publish-android.yml on ${TAG}."
exit 0
fi
echo "Dispatch failed (attempt ${attempt}); waiting for tag/workflow to appear."
sleep 5
done
echo "::error::Could not dispatch publish-android.yml on ${TAG}."
exit 1
publish:
if: startsWith(github.ref, 'refs/tags/capture-runtime-v')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Install NDK and CMake
run: |
yes | sdkmanager --install "ndk;28.2.13676358" "cmake;3.22.1" "platforms;android-36" "build-tools;35.0.0"
- name: Verify tag
id: version
run: |
set -euo pipefail
version="$(bash tool/ci/android-runtime-version.sh)"
expected_tag="capture-runtime-v${version}"
if [[ "${GITHUB_REF_NAME}" != "${expected_tag}" ]]; then
echo "::error::Git tag ${GITHUB_REF_NAME} must be ${expected_tag} to publish capture-runtime ${version}."
exit 1
fi
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Publish to GitHub Packages
working-directory: platforms/android
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ github.actor }}
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ github.token }}
run: |
set -euo pipefail
github_exists=false
if versions="$(gh api "/orgs/blendto/packages/maven/com.gettugboat.sdk.capture-runtime/versions" --jq '.[].name' 2>/dev/null)"; then
if printf '%s\n' "$versions" | grep -qx "${VERSION}"; then
github_exists=true
fi
fi
if [[ "$github_exists" == "true" ]]; then
echo "capture-runtime ${VERSION} is already on GitHub Packages."
exit 0
fi
./gradlew :capture-runtime:publishAllPublicationsToGitHubPackagesRepository
- name: Publish to Maven Central
working-directory: platforms/android
env:
VERSION: ${{ steps.version.outputs.version }}
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: |
set -euo pipefail
if [[ -z "${MAVEN_CENTRAL_USERNAME}" ]]; then
echo "Maven Central secrets are not configured. Skipping Central publish."
echo "Add MAVEN_CENTRAL_USERNAME, MAVEN_CENTRAL_PASSWORD, MAVEN_GPG_KEY, and MAVEN_GPG_PASSPHRASE after verifying namespace com.gettugboat (gettugboat.com) at https://central.sonatype.com/"
exit 0
fi
code="$(curl -sS -o /dev/null -w '%{http_code}' \
"https://repo1.maven.org/maven2/com/gettugboat/sdk/capture-runtime/${VERSION}/capture-runtime-${VERSION}.pom")"
if [[ "$code" == "200" ]]; then
echo "capture-runtime ${VERSION} is already on Maven Central."
exit 0
fi
./gradlew :capture-runtime:publishAndReleaseToMavenCentral -Ptugboat.publishMavenCentral=true
pin_flutter:
if: startsWith(github.ref, 'refs/tags/capture-runtime-v')
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Open Flutter pin PR
env:
GH_TOKEN: ${{ github.token }}
run: bash tool/ci/open-flutter-runtime-pin-pr.sh