Skip to content

Commit 61c16e2

Browse files
committed
Move central publishing to GH actions
1 parent 67cba11 commit 61c16e2

File tree

4 files changed

+97
-84
lines changed

4 files changed

+97
-84
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 & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +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@v4
12-
with:
13-
submodules: true
14-
15-
- uses: actions/setup-java@v4
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
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/
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
53+
fetch-depth: 0
4754

48-
- uses: actions/setup-java@v3
49-
with:
50-
distribution: "temurin"
51-
java-version: "17"
55+
- uses: actions/download-artifact@v4
56+
name: android-library
5257

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
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+
--form bundle=@powersync-android.zip \
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
@@ -16,6 +16,8 @@ group = "co.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,36 @@ 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 {
188173
if (System.getenv("GPG_PRIVATE_KEY") == null) {
189-
useGpgCmd()
174+
// Don't sign the publication.
190175
} else {
191176
var signingKey = String(Base64.getDecoder().decode(System.getenv("GPG_PRIVATE_KEY"))).trim()
192177
var signingPassword = System.getenv("GPG_PASSWORD")
193178
useInMemoryPgpKeys(signingKey, signingPassword)
179+
180+
sign(publishing.publications)
194181
}
195-
sign(publishing.publications)
196182
}
197183

198184
tasks.withType<AbstractPublishToMaven>() {
199185
dependsOn(prefabAar)
200186
}
201187

188+
val zipPublication by tasks.registering(Zip::class) {
189+
dependsOn(tasks.named("publishAllPublicationsToHereRepository"))
190+
191+
archiveFileName.set("powersync_android.zip")
192+
from(localRepo)
193+
}
194+
202195
tasks.named("build") {
203196
dependsOn(prefabAar)
204197
}

0 commit comments

Comments
 (0)