Skip to content

Commit

Permalink
CI: publish an android SNAPSHOT release on every build
Browse files Browse the repository at this point in the history
Credits go to @nift4 (see zxing-cpp#827).
  • Loading branch information
axxel committed Sep 7, 2024
1 parent 4949b69 commit bc92aed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,22 @@ jobs:

- name: Build the lib/app
working-directory: wrappers/android
run: ./gradlew assembleDebug # build only the debug version of the aar (faster build)
run: ./gradlew assembleRelease

- uses: actions/upload-artifact@v4
with:
name: android-artifacts
path: "wrappers/android/zxingcpp/build/outputs/aar/zxingcpp-debug.aar"
path: "wrappers/android/zxingcpp/build/outputs/aar/zxingcpp-release.aar"

- name: Publish Library Snapshot
working-directory: wrappers/android
env:
ORG_GRADLE_PROJECT_publishSnapshot: true
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew publishReleasePublicationToSonatypeRepository

build-kn:
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions wrappers/android/zxingcpp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ dependencies {
implementation(libs.androidx.camera.core)
}

val publishSnapshot: String? by project
group = "io.github.zxing-cpp"
version = "2.2.0"
version = "2.2.0" + if (publishSnapshot == "true") "-SNAPSHOT" else ""

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
Expand Down Expand Up @@ -102,7 +103,7 @@ publishing {

val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
setUrl(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
setUrl(if (version.toString().endsWith("-SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)

credentials {
val ossrhUsername: String? by project
Expand Down

0 comments on commit bc92aed

Please sign in to comment.