Skip to content

Commit 7cbf5a7

Browse files
committed
Adding maven central publish
1 parent 747076f commit 7cbf5a7

File tree

3 files changed

+146
-19
lines changed

3 files changed

+146
-19
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build to Maven Local
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- '*'
11+
- '!ci_test_*'
12+
tags-ignore:
13+
- '*'
14+
pull_request:
15+
branches:
16+
- '*'
17+
- '!ci_test_*'
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
environment: Maven Central
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: set up JDK 17
26+
uses: actions/setup-java@v3
27+
with:
28+
java-version: '17'
29+
distribution: 'adopt'
30+
cache: gradle
31+
- name: Set version variable
32+
run: echo "GITHUB_REF_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
33+
- name: Compile to maven local
34+
env:
35+
VERSION_NAME: ${{ env.GITHUB_REF_NAME }}
36+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
37+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
38+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }}
39+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID }}
40+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}
41+
run: bash ./gradlew avif-coder:publishToMavenLocal
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create Release
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
tags:
10+
- '*'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
environment: Maven Central
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: set up JDK 17
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '17'
22+
distribution: 'adopt'
23+
cache: gradle
24+
- name: Set version variable
25+
run: echo "GITHUB_REF_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
26+
- name: Compile to Maven Central
27+
env:
28+
VERSION_NAME: ${{ env.GITHUB_REF_NAME }}
29+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
30+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
31+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }}
32+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID }}
33+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}
34+
PUBLISH_STATE: Release
35+
run: bash ./gradlew avif-coder:publishAllPublicationsToMavenCentralRepository
36+
37+
release:
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: write
41+
needs:
42+
- build
43+
steps:
44+
- uses: actions/checkout@v3
45+
- uses: ncipollo/release-action@v1
46+
with:
47+
bodyFile: 'CHANGELOG.md'

avif-coder/build.gradle.kts

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,71 @@
2525

2626
@file:Suppress("UnstableApiUsage")
2727

28+
import com.vanniktech.maven.publish.AndroidMultiVariantLibrary
29+
2830
plugins {
2931
id("com.android.library")
3032
id("org.jetbrains.kotlin.android")
3133
id("maven-publish")
34+
id("signing")
35+
id("com.vanniktech.maven.publish") version "0.34.0"
3236
}
3337

34-
task("androidSourcesJar", Jar::class) {
35-
archiveClassifier.set("sources")
36-
from(android.sourceSets.getByName("main").java.srcDirs)
38+
mavenPublishing {
39+
if (System.getenv("PUBLISH_STATE") == "Release") {
40+
signAllPublications()
41+
}
3742
}
3843

39-
afterEvaluate {
40-
publishing {
41-
publications {
42-
create<MavenPublication>("mavenJava") {
43-
groupId = "com.github.awxkee"
44-
artifactId = "avif-coder"
45-
version = "2.0.11"
46-
from(components["release"])
47-
// artifact("androidSourcesJar")
44+
mavenPublishing {
45+
configure(
46+
AndroidMultiVariantLibrary(
47+
sourcesJar = true,
48+
publishJavadocJar = true,
49+
)
50+
)
51+
52+
coordinates("io.github.awxkee", "avif-coder", System.getenv("VERSION_NAME") ?: "0.0.10")
53+
54+
pom {
55+
name.set("AVIF Coder")
56+
description.set("AVIF encoder/decoder for Android")
57+
inceptionYear.set("2025")
58+
url.set("https://github.com/awxkee/jxl-coder")
59+
licenses {
60+
license {
61+
name.set("The Apache License, Version 2.0")
62+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
63+
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
64+
}
65+
license {
66+
name.set("The 3-Clause BSD License")
67+
url.set("https://opensource.org/license/bsd-3-clause")
68+
description.set("https://opensource.org/license/bsd-3-clause")
4869
}
4970
}
71+
developers {
72+
developer {
73+
id.set("awxkee")
74+
name.set("Radzivon Bartoshyk")
75+
url.set("https://github.com/awxkee")
76+
email.set("radzivon.bartoshyk@proton.me")
77+
}
78+
}
79+
scm {
80+
url.set("https://github.com/awxkee/avif-coder")
81+
connection.set("scm:git:git@github.com:awxkee/avif-coder.git")
82+
developerConnection.set("scm:git:ssh://git@github.com/awxkee/avif-coder.git")
83+
}
5084
}
5185
}
5286

53-
android {
54-
publishing {
55-
singleVariant("release") {
56-
withSourcesJar()
57-
withJavadocJar()
58-
}
59-
}
87+
task("androidSourcesJar", Jar::class) {
88+
archiveClassifier.set("sources")
89+
from(android.sourceSets.getByName("main").java.srcDirs)
90+
}
6091

92+
android {
6193
namespace = "com.github.awxkee.avifcoder"
6294
compileSdk = 34
6395

@@ -77,6 +109,13 @@ android {
77109
}
78110
}
79111

112+
publishing {
113+
singleVariant("release") {
114+
withSourcesJar()
115+
withJavadocJar()
116+
}
117+
}
118+
80119
}
81120

82121
sourceSets {

0 commit comments

Comments
 (0)