From 8925d51ab998de523c1e24467f432d70b0e6cdd1 Mon Sep 17 00:00:00 2001 From: Ian Rumac Date: Wed, 11 Sep 2024 16:44:19 +0200 Subject: [PATCH] Add publish action --- .github/workflows/publish.yml | 35 ++++++++++++++++ supercel/build.gradle.kts | 77 ++++++++++++++++++++++++++++++++--- 2 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8251962 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish Android Library + +on: + push: + branches: [ "main" ] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'adopt' + + - name: Decode Signing Key + env: + SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SECRING }} + run: | + echo $SIGNING_SECRET_KEY_RING_FILE | base64 -d > $HOME/secring.gpg + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build and publish + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_SECRET_KEY_RING_FILE: $HOME/secring.gpg + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: ./gradlew publish \ No newline at end of file diff --git a/supercel/build.gradle.kts b/supercel/build.gradle.kts index 00163df..0fa8aae 100644 --- a/supercel/build.gradle.kts +++ b/supercel/build.gradle.kts @@ -1,16 +1,26 @@ +import groovy.json.JsonBuilder + +buildscript { + extra["awsAccessKeyId"] = System.getenv("AWS_ACCESS_KEY_ID") ?: findProperty("aws_access_key_id") + extra["awsSecretAccessKey"] = System.getenv("AWS_SECRET_ACCESS_KEY") ?: findProperty("aws_secret_access_key") + extra["sonatypeUsername"] = System.getenv("SONATYPE_USERNAME") ?: findProperty("sonatype_username") + extra["sonatypePassword"] = System.getenv("SONATYPE_PASSWORD") ?: findProperty("sonatype_password") +} + plugins { alias(libs.plugins.android.application) alias(libs.plugins.jetbrains.kotlin.android) id("maven-publish") + id("signing") } +version = "0.1.3" android { namespace = "com.superwall.supercel" compileSdk = 34 defaultConfig { minSdk = 26 - targetSdk = 34 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -47,13 +57,9 @@ android { dependencies { implementation("net.java.dev.jna:jna:5.14.0@aar") implementation(libs.coroutines) - testImplementation(libs.junit) - androidTestImplementation(libs.androidx.junit) - androidTestImplementation(libs.androidx.espresso.core) } afterEvaluate { - publishing { publications { create("release") { @@ -61,7 +67,68 @@ afterEvaluate { groupId = "com.superwall.supercel" artifactId = "supercel" version = "0.1.3" // Set your library version + + pom { + name.set("SuperCEL") + description.set("Superwall CEL Evaluator") + url.set("https://superwall.com") + + licenses { + license { + name.set("MIT License") + url.set("https://github.com/superwall/Superwall-Android?tab=MIT-1-ov-file#") + } + } + developers { + developer { + id.set("ianrumac") + name.set("Ian Rumac") + email.set("ian@superwall.com") + } + } + scm { + connection.set("scm:git:git@github.com:superwall/SuperCEL-Android.git") + developerConnection.set("scm:git:ssh://github.com:superwall/SuperCEL-Android.git") + url.set("scm:git:https://github.com/superwall/SuperCEL-Android.git") + } + } + } + } + + repositories { + mavenLocal() + + val sonatypeUsername: String? by extra + val sonatypePassword: String? by extra + + if (sonatypeUsername != null && sonatypePassword != null) { + maven { + url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials(PasswordCredentials::class.java) { + username = sonatypeUsername + password = sonatypePassword + } + } } } } + + + signing { + val signingKeyId: String? = System.getenv("SIGNING_KEY_ID") + val signingPassword: String? = System.getenv("SIGNING_PASSWORD") + val signingSecretKeyRingFile: String? = System.getenv("SECRING") + useInMemoryPgpKeys(signingKeyId, signingPassword, signingSecretKeyRingFile) + sign(publishing.publications["release"]) + } } + +tasks.register("generateBuildInfo") { + doLast { + var buildInfo = mapOf("version" to version) + val jsonOutput = JsonBuilder(buildInfo).toPrettyString() + val outputFile = File("${getLayout().buildDirectory}/version.json") + outputFile.writeText(jsonOutput) + } +} +