Skip to content

Commit b5f9ec0

Browse files
authored
Move central publishing to GH actions (#74)
1 parent 67cba11 commit b5f9ec0

File tree

5 files changed

+123
-95
lines changed

5 files changed

+123
-95
lines changed

.github/actions/android/action.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: "Build Android library"
2+
description: "Create artifact for Android library"
3+
inputs:
4+
sign-publication:
5+
description: "Whether to sign the built library"
6+
default: '1'
7+
gpg-key:
8+
required: false
9+
description: "The GPG key to use when signing the publication"
10+
gpg-password:
11+
required: false
12+
description: "Password for the GPG key."
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/setup-java@v4
18+
with:
19+
distribution: "temurin"
20+
java-version: "17"
21+
22+
- name: Validate Gradle wrapper
23+
uses: gradle/actions/wrapper-validation@v4
24+
25+
- name: Setup
26+
shell: bash
27+
run: |
28+
rustup toolchain install nightly-2025-04-15-x86_64-unknown-linux-gnu
29+
rustup component add rust-src --toolchain nightly-2025-04-15-x86_64-unknown-linux-gnu
30+
rustup target add \
31+
aarch64-linux-android \
32+
armv7-linux-androideabi \
33+
x86_64-linux-android \
34+
i686-linux-android
35+
cargo install cargo-ndk
36+
37+
- name: Build signed library
38+
shell: bash
39+
if: ${{ inputs.sign-publication == '1' }}
40+
run: |
41+
cd android
42+
./gradlew build zipPublication -PgpgKey=${{ inputs.gpg-key }} -PgpgPassword=${{ inputs.gpg-password }}
43+
ls -lh build/outputs/aar
44+
find build/repository
45+
46+
- name: Build library without signing
47+
shell: bash
48+
if: ${{ inputs.sign-publication == '0' }}
49+
run: |
50+
cd android
51+
./gradlew build zipPublication -PsignPublication=0
52+
ls -lh build/outputs/aar
53+
find build/repository
54+
55+
- name: Upload binary
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: android-library
59+
retention-days: 1
60+
compression-level: 0 # We're uploading a zip, no need to compress again
61+
path: android/build/distributions/powersync_android.zip
62+
if-no-files-found: error

.github/workflows/android.yml

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212
with:
1313
submodules: true
14-
15-
- uses: actions/setup-java@v4
14+
- name: Build Android
15+
uses: ./.github/actions/android
1616
with:
17-
distribution: "temurin"
18-
java-version: "17"
19-
20-
- name: Validate Gradle wrapper
21-
uses: gradle/actions/wrapper-validation@v4
22-
23-
- name: Setup
24-
run: |
25-
rustup toolchain install nightly-2025-04-15-x86_64-unknown-linux-gnu
26-
rustup component add rust-src --toolchain nightly-2025-04-15-x86_64-unknown-linux-gnu
27-
rustup target add \
28-
aarch64-linux-android \
29-
armv7-linux-androideabi \
30-
x86_64-linux-android \
31-
i686-linux-android
32-
cargo install cargo-ndk
33-
34-
- name: Build for Android
35-
run: |
36-
cd android
37-
./gradlew build
38-
ls -lh build/outputs/aar
39-
40-
- name: Upload Android library
41-
uses: actions/upload-artifact@v4
42-
with:
43-
name: android-library
44-
path: |
45-
android/build/outputs/aar/
17+
sign-publication: '0'

.github/workflows/release.yml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,45 +33,49 @@ jobs:
3333
body="Release $tag"
3434
gh release create --draft "$tag" --title "$tag" --notes "$body"
3535
36+
build_android:
37+
name: Build Android
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
submodules: true
43+
- name: Build Android
44+
uses: ./.github/actions/android
45+
with:
46+
gpg-key: ${{ secrets.GPG_PRIVATE_KEY }}
47+
gpg-password: ${{ secrets.GPG_PASSWORD }}
48+
3649
publish_android:
3750
permissions:
3851
contents: read
3952
packages: write
4053
name: Publish Android
41-
needs: [draft_release]
54+
needs: [draft_release, build_android]
4255
runs-on: ubuntu-latest
4356
steps:
44-
- uses: actions/checkout@v3
57+
- uses: actions/checkout@v4
4558
with:
46-
submodules: true
59+
fetch-depth: 0
4760

48-
- uses: actions/setup-java@v3
61+
- uses: actions/download-artifact@v4
4962
with:
50-
distribution: "temurin"
51-
java-version: "17"
63+
name: android-library
5264

53-
- name: Setup
54-
run: |
55-
rustup toolchain install nightly-2025-04-15-x86_64-unknown-linux-gnu
56-
rustup component add rust-src --toolchain nightly-2025-04-15-x86_64-unknown-linux-gnu
57-
rustup target add \
58-
aarch64-linux-android \
59-
armv7-linux-androideabi \
60-
x86_64-linux-android \
61-
i686-linux-android
62-
cargo install cargo-ndk
63-
64-
- name: Publish for Android
65+
- name: Publish to Maven Central
6566
if: ${{ inputs.publish }}
6667
run: |
67-
cd android
68-
./gradlew publish
69-
env:
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
72-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
73-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
74-
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
68+
curl --request POST \
69+
--header 'Authorization: Bearer ${{ secrets.CENTRAL_AUTH }}' \
70+
--form bundle=@powersync_android.zip \
71+
'https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC'
72+
73+
- name: Upload binary
74+
uses: ./.github/actions/upload
75+
with:
76+
repo-token: ${{ secrets.GITHUB_TOKEN }}
77+
file-name: powersync-android.zip
78+
tag: ${{ needs.draft_release.outputs.tag }}
7579

7680
publish_ios_pod_and_spm_package:
7781
name: Publish iOS

RELEASING.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,7 @@ The above does the following:
2828

2929
1. Create a draft GitHub release.
3030
2. Build the xcframework for iOS and macOS, and upload to GitHub (attached to the above release).
31-
3. Build and publish an Android aar to Sonatype staging.
32-
33-
Once that is done, go to the Maven staging repository, and "Close", wait, and "Release" the
34-
repository:
35-
36-
https://s01.oss.sonatype.org/#stagingRepositories
37-
38-
Docs: https://central.sonatype.org/publish/release/
39-
40-
Go to GitHub Releases on the repository, update the description, then "Publish Release".
31+
3. Build and publish an Android aar to Sonatype. Afterwards, you can monitor the status of the publishing step [here](https://central.sonatype.com/publishing/deployments).
4132

4233
Publish the cocoapod:
4334

android/build.gradle.kts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ plugins {
1212
id("signing")
1313
}
1414

15-
group = "co.powersync"
15+
group = "com.powersync"
1616
version = "0.4.1"
1717
description = "PowerSync Core SQLite Extension"
1818

19+
val localRepo = uri("build/repository/")
20+
1921
repositories {
2022
mavenCentral()
2123
google()
@@ -160,45 +162,42 @@ publishing {
160162
}
161163

162164
repositories {
163-
if (System.getenv("OSSRH_USERNAME") != null) {
164-
maven {
165-
name = "sonatype"
166-
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
167-
credentials {
168-
username = System.getenv("OSSRH_USERNAME")
169-
password = System.getenv("OSSRH_PASSWORD")
170-
}
171-
}
172-
}
173-
174-
if (System.getenv("GITHUB_ACTOR") != null) {
175-
maven {
176-
name = "GitHubPackages"
177-
url = uri("https://maven.pkg.github.com/powersync-ja/powersync-sqlite-core")
178-
credentials {
179-
username = System.getenv("GITHUB_ACTOR")
180-
password = System.getenv("GITHUB_TOKEN")
181-
}
182-
}
165+
maven {
166+
name = "here"
167+
url = localRepo
183168
}
184169
}
185170
}
186171

187172
signing {
188-
if (System.getenv("GPG_PRIVATE_KEY") == null) {
189-
useGpgCmd()
190-
} else {
191-
var signingKey = String(Base64.getDecoder().decode(System.getenv("GPG_PRIVATE_KEY"))).trim()
192-
var signingPassword = System.getenv("GPG_PASSWORD")
193-
useInMemoryPgpKeys(signingKey, signingPassword)
173+
val sign = providers.gradleProperty("signPublication").getOrElse("1")
174+
175+
if (sign != "0") {
176+
val key = providers.gradleProperty("gpgKey")
177+
val password = providers.gradleProperty("gpgPassword")
178+
179+
if (key.isPresent()) {
180+
val signingKey = String(Base64.getDecoder().decode(key.get())).trim()
181+
useInMemoryPgpKeys(signingKey, password.get())
182+
} else {
183+
useGpgCmd()
184+
}
185+
186+
sign(publishing.publications)
194187
}
195-
sign(publishing.publications)
196188
}
197189

198190
tasks.withType<AbstractPublishToMaven>() {
199191
dependsOn(prefabAar)
200192
}
201193

194+
val zipPublication by tasks.registering(Zip::class) {
195+
dependsOn(tasks.named("publishAllPublicationsToHereRepository"))
196+
197+
archiveFileName.set("powersync_android.zip")
198+
from(localRepo)
199+
}
200+
202201
tasks.named("build") {
203202
dependsOn(prefabAar)
204203
}

0 commit comments

Comments
 (0)