Skip to content

Move central publishing to GH actions #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/actions/android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "Build Android library"
description: "Create artifact for Android library"
inputs:
sign-publication:
description: "Whether to sign the built library"
default: '1'
gpg-key:
required: false
description: "The GPG key to use when signing the publication"
gpg-password:
required: false
description: "Password for the GPG key."

runs:
using: "composite"
steps:
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4

- name: Setup
shell: bash
run: |
rustup toolchain install nightly-2024-05-18-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-2024-05-18-x86_64-unknown-linux-gnu
rustup target add \
aarch64-linux-android \
armv7-linux-androideabi \
x86_64-linux-android \
i686-linux-android
cargo install cargo-ndk

- name: Build signed library
shell: bash
if: ${{ inputs.sign-publication == '1' }}
run: |
cd android
./gradlew build zipPublication -PgpgKey=${{ inputs.gpg-key }} -PgpgPassword=${{ inputs.gpg-password }}
ls -lh build/outputs/aar
find build/repository

- name: Build library without signing
shell: bash
if: ${{ inputs.sign-publication == '0' }}
run: |
cd android
./gradlew build zipPublication -PsignPublication=0
ls -lh build/outputs/aar
find build/repository

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: android-library
retention-days: 1
compression-level: 0 # We're uploading a zip, no need to compress again
path: android/build/distributions/powersync_android.zip
if-no-files-found: error
29 changes: 4 additions & 25 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,10 @@ jobs:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-java@v3
- name: Build Android
uses: ./.github/actions/android
with:
distribution: "temurin"
java-version: "17"

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4

- name: Setup
run: |
rustup toolchain install nightly-2024-05-18-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-2024-05-18-x86_64-unknown-linux-gnu
rustup target add \
aarch64-linux-android \
armv7-linux-androideabi \
x86_64-linux-android \
i686-linux-android
cargo install cargo-ndk

- name: Build for Android
run: |
cd android
./gradlew build
ls -lh build/outputs/aar
sign-publication: '0'
57 changes: 30 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,48 @@ jobs:
body="Release $tag"
gh release create --draft "$tag" --title "$tag" --notes "$body"

build_android:
name: Build Android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build Android
uses: ./.github/actions/android
with:
gpg-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-password: ${{ secrets.GPG_PASSWORD }}

publish_android:
permissions:
contents: read
packages: write
name: Publish Android
needs: [draft_release]
needs: [draft_release, build_android]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true

- uses: actions/setup-java@v3
- uses: actions/checkout@v4
with:
distribution: "temurin"
java-version: "17"
fetch-depth: 0

- name: Setup
run: |
rustup toolchain install nightly-2024-05-18-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-2024-05-18-x86_64-unknown-linux-gnu
rustup target add \
aarch64-linux-android \
armv7-linux-androideabi \
x86_64-linux-android \
i686-linux-android
cargo install cargo-ndk
- uses: actions/download-artifact@v4
name: android-library

- name: Publish for Android
- name: Publish to Maven Central
if: ${{ inputs.publish }}
run: |
cd android
./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
curl --request POST \
--header 'Authorization: Bearer ${{ secrets.CENTRAL_AUTH }}' \
--form [email protected] \
https://central.sonatype.com/api/v1/publisher/upload

- name: Upload binary
uses: ./.github/actions/upload
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
file-name: powersync-android.zip
tag: ${{ needs.draft_release.outputs.tag }}

publish_ios_pod_and_spm_package:
name: Publish iOS
Expand Down
55 changes: 27 additions & 28 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ plugins {
id("signing")
}

group = "co.powersync"
group = "com.powersync"
version = "0.3.14"
description = "PowerSync Core SQLite Extension"

val localRepo = uri("build/repository/")

repositories {
mavenCentral()
google()
Expand Down Expand Up @@ -119,45 +121,42 @@ publishing {
}

repositories {
if (System.getenv("OSSRH_USERNAME") != null) {
maven {
name = "sonatype"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}

if (System.getenv("GITHUB_ACTOR") != null) {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/powersync-ja/powersync-sqlite-core")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "here"
url = localRepo
}
}
}

signing {
if (System.getenv("GPG_PRIVATE_KEY") == null) {
useGpgCmd()
} else {
var signingKey = String(Base64.getDecoder().decode(System.getenv("GPG_PRIVATE_KEY"))).trim()
var signingPassword = System.getenv("GPG_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
val sign = providers.gradleProperty("signPublication").getOrElse("1")

if (sign != "0") {
val key = providers.gradleProperty("gpgKey")
val password = providers.gradleProperty("gpgPassword")

if (key.isPresent()) {
val signingKey = String(Base64.getDecoder().decode(key.get())).trim()
useInMemoryPgpKeys(signingKey, password.get())
} else {
useGpgCmd()
}

sign(publishing.publications)
}
sign(publishing.publications)
}

tasks.withType<AbstractPublishToMaven>() {
dependsOn(prefabAar)
}

val zipPublication by tasks.registering(Zip::class) {
dependsOn(tasks.named("publishAllPublicationsToHereRepository"))

archiveFileName.set("powersync_android.zip")
from(localRepo)
}

tasks.named("build") {
dependsOn(prefabAar)
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down