From 7cbf5a7364994745a579f8d14b9a9c6dbc3b78e7 Mon Sep 17 00:00:00 2001 From: Radzivon Bartoshyk Date: Tue, 29 Jul 2025 12:36:20 +0100 Subject: [PATCH 1/3] Adding maven central publish --- .github/workflows/build.yml | 41 +++++++++++++++ .github/workflows/create_release.yml | 47 +++++++++++++++++ avif-coder/build.gradle.kts | 77 +++++++++++++++++++++------- 3 files changed, 146 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/create_release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..30d3598 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build to Maven Local + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: + - '*' + - '!ci_test_*' + tags-ignore: + - '*' + pull_request: + branches: + - '*' + - '!ci_test_*' + +jobs: + build: + runs-on: ubuntu-latest + environment: Maven Central + steps: + - uses: actions/checkout@v3 + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + cache: gradle + - name: Set version variable + run: echo "GITHUB_REF_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV + - name: Compile to maven local + env: + VERSION_NAME: ${{ env.GITHUB_REF_NAME }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }} + run: bash ./gradlew avif-coder:publishToMavenLocal \ No newline at end of file diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 0000000..7a4911c --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,47 @@ +name: Create Release + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + environment: Maven Central + steps: + - uses: actions/checkout@v3 + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + cache: gradle + - name: Set version variable + run: echo "GITHUB_REF_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV + - name: Compile to Maven Central + env: + VERSION_NAME: ${{ env.GITHUB_REF_NAME }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }} + PUBLISH_STATE: Release + run: bash ./gradlew avif-coder:publishAllPublicationsToMavenCentralRepository + + release: + runs-on: ubuntu-latest + permissions: + contents: write + needs: + - build + steps: + - uses: actions/checkout@v3 + - uses: ncipollo/release-action@v1 + with: + bodyFile: 'CHANGELOG.md' \ No newline at end of file diff --git a/avif-coder/build.gradle.kts b/avif-coder/build.gradle.kts index 1e9d4cf..46a73a1 100644 --- a/avif-coder/build.gradle.kts +++ b/avif-coder/build.gradle.kts @@ -25,39 +25,71 @@ @file:Suppress("UnstableApiUsage") +import com.vanniktech.maven.publish.AndroidMultiVariantLibrary + plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") + id("signing") + id("com.vanniktech.maven.publish") version "0.34.0" } -task("androidSourcesJar", Jar::class) { - archiveClassifier.set("sources") - from(android.sourceSets.getByName("main").java.srcDirs) +mavenPublishing { + if (System.getenv("PUBLISH_STATE") == "Release") { + signAllPublications() + } } -afterEvaluate { - publishing { - publications { - create("mavenJava") { - groupId = "com.github.awxkee" - artifactId = "avif-coder" - version = "2.0.11" - from(components["release"]) -// artifact("androidSourcesJar") +mavenPublishing { + configure( + AndroidMultiVariantLibrary( + sourcesJar = true, + publishJavadocJar = true, + ) + ) + + coordinates("io.github.awxkee", "avif-coder", System.getenv("VERSION_NAME") ?: "0.0.10") + + pom { + name.set("AVIF Coder") + description.set("AVIF encoder/decoder for Android") + inceptionYear.set("2025") + url.set("https://github.com/awxkee/jxl-coder") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + license { + name.set("The 3-Clause BSD License") + url.set("https://opensource.org/license/bsd-3-clause") + description.set("https://opensource.org/license/bsd-3-clause") } } + developers { + developer { + id.set("awxkee") + name.set("Radzivon Bartoshyk") + url.set("https://github.com/awxkee") + email.set("radzivon.bartoshyk@proton.me") + } + } + scm { + url.set("https://github.com/awxkee/avif-coder") + connection.set("scm:git:git@github.com:awxkee/avif-coder.git") + developerConnection.set("scm:git:ssh://git@github.com/awxkee/avif-coder.git") + } } } -android { - publishing { - singleVariant("release") { - withSourcesJar() - withJavadocJar() - } - } +task("androidSourcesJar", Jar::class) { + archiveClassifier.set("sources") + from(android.sourceSets.getByName("main").java.srcDirs) +} +android { namespace = "com.github.awxkee.avifcoder" compileSdk = 34 @@ -77,6 +109,13 @@ android { } } + publishing { + singleVariant("release") { + withSourcesJar() + withJavadocJar() + } + } + } sourceSets { From 184ed484fbdbfcd76837d2bbd920404d01556473 Mon Sep 17 00:00:00 2001 From: Radzivon Bartoshyk Date: Tue, 29 Jul 2025 13:07:41 +0100 Subject: [PATCH 2/3] Adding maven central publish --- .github/workflows/build.yml | 1 + build.gradle | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30d3598..1431e7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,7 @@ on: branches: - '*' - '!ci_test_*' + - 'master' jobs: build: diff --git a/build.gradle b/build.gradle index 5cecd96..e20c63f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.2.2' apply false - id 'com.android.library' version '8.11.1' apply false - id 'org.jetbrains.kotlin.android' version '2.0.20' apply false + id 'com.android.application' version '8.12.0-rc01' apply false + id 'com.android.library' version '8.12.0-rc01' apply false + id 'org.jetbrains.kotlin.android' version '2.2.0' apply false id 'com.google.devtools.ksp' version '2.0.20-1.0.25' apply false } \ No newline at end of file From 244b3dab946ee754401a6c09926e42dedf4b9625 Mon Sep 17 00:00:00 2001 From: Radzivon Bartoshyk Date: Tue, 29 Jul 2025 13:46:25 +0100 Subject: [PATCH 3/3] Adding maven central publish --- avif-coder/build.gradle.kts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/avif-coder/build.gradle.kts b/avif-coder/build.gradle.kts index 46a73a1..2114072 100644 --- a/avif-coder/build.gradle.kts +++ b/avif-coder/build.gradle.kts @@ -49,7 +49,11 @@ mavenPublishing { ) ) - coordinates("io.github.awxkee", "avif-coder", System.getenv("VERSION_NAME") ?: "0.0.10") + if (System.getenv("PUBLISH_STATE") == "Release") { + coordinates("io.github.awxkee", "avif-coder", System.getenv("VERSION_NAME") ?: "0.0.10") + } else { + coordinates("io.github.awxkee", "avif-coder", "0.0.10") + } pom { name.set("AVIF Coder")