Skip to content

Commit 3504e42

Browse files
committed
Move central publishing to GH actions
1 parent 37c4b4f commit 3504e42

File tree

5 files changed

+98
-78
lines changed

5 files changed

+98
-78
lines changed

.github/actions/android/action.yml

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

.github/workflows/android.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,5 @@ jobs:
88
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v3
12-
with:
13-
submodules: true
14-
15-
- uses: actions/setup-java@v3
16-
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
11+
- name: Build Android
12+
uses: ./.github/actions/android

.github/workflows/release.yml

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,45 +33,42 @@ 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+
- name: Build Android
41+
uses: ./.github/actions/android
42+
3643
publish_android:
3744
permissions:
3845
contents: read
3946
packages: write
4047
name: Publish Android
41-
needs: [draft_release]
48+
needs: [draft_release, build_android]
4249
runs-on: ubuntu-latest
4350
steps:
44-
- uses: actions/checkout@v3
51+
- uses: actions/checkout@v4
4552
with:
46-
submodules: true
47-
48-
- uses: actions/setup-java@v3
49-
with:
50-
distribution: "temurin"
51-
java-version: "17"
53+
fetch-depth: 0
5254

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
55+
- uses: actions/download-artifact@v4
56+
name: android-library
6357

64-
- name: Publish for Android
58+
- name: Publish to Maven Central
6559
if: ${{ inputs.publish }}
6660
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 }}
61+
curl --request POST \
62+
--header 'Authorization: Bearer ${{ secrets.CENTRAL_AUTH }}' \
63+
64+
https://central.sonatype.com/api/v1/publisher/upload
65+
66+
- name: Upload binary
67+
uses: ./.github/actions/upload
68+
with:
69+
repo-token: ${{ secrets.GITHUB_TOKEN }}
70+
file-name: powersync-android.zip
71+
tag: ${{ needs.draft_release.outputs.tag }}
7572

7673
publish_ios_pod_and_spm_package:
7774
name: Publish iOS

android/build.gradle.kts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ group = "co.powersync"
99
version = "0.3.14"
1010
description = "PowerSync Core SQLite Extension"
1111

12+
val localRepo = uri("build/repository/")
13+
1214
repositories {
1315
mavenCentral()
1416
google()
@@ -119,45 +121,36 @@ publishing {
119121
}
120122

121123
repositories {
122-
if (System.getenv("OSSRH_USERNAME") != null) {
123-
maven {
124-
name = "sonatype"
125-
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
126-
credentials {
127-
username = System.getenv("OSSRH_USERNAME")
128-
password = System.getenv("OSSRH_PASSWORD")
129-
}
130-
}
131-
}
132-
133-
if (System.getenv("GITHUB_ACTOR") != null) {
134-
maven {
135-
name = "GitHubPackages"
136-
url = uri("https://maven.pkg.github.com/powersync-ja/powersync-sqlite-core")
137-
credentials {
138-
username = System.getenv("GITHUB_ACTOR")
139-
password = System.getenv("GITHUB_TOKEN")
140-
}
141-
}
124+
maven {
125+
name = "here"
126+
url = localRepo
142127
}
143128
}
144129
}
145130

146131
signing {
147132
if (System.getenv("GPG_PRIVATE_KEY") == null) {
148-
useGpgCmd()
133+
// Don't sign the publication.
149134
} else {
150135
var signingKey = String(Base64.getDecoder().decode(System.getenv("GPG_PRIVATE_KEY"))).trim()
151136
var signingPassword = System.getenv("GPG_PASSWORD")
152137
useInMemoryPgpKeys(signingKey, signingPassword)
138+
139+
sign(publishing.publications)
153140
}
154-
sign(publishing.publications)
155141
}
156142

157143
tasks.withType<AbstractPublishToMaven>() {
158144
dependsOn(prefabAar)
159145
}
160146

147+
val zipPublication by tasks.registering(Zip::class) {
148+
dependsOn(tasks.named("publishAllPublicationsToHereRepository"))
149+
150+
archiveFileName.set("powersync_android.zip")
151+
from(localRepo)
152+
}
153+
161154
tasks.named("build") {
162155
dependsOn(prefabAar)
163156
}

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)