Skip to content

Commit 44a186b

Browse files
committed
build(assists): 发布库到Maven Central
- 添加发布到Maven Central的配置和脚本 - 新增发布工作流,通过GitHub Actions自动发布 - 配置GPG密钥导入和验证 - 设置OSSRH(Sonatype OSS Repository Hosting)凭据
1 parent 6ca8e44 commit 44a186b

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
name: Publish Android Libraries
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up JDK
17+
uses: actions/setup-java@v3
18+
with:
19+
distribution: 'temurin'
20+
java-version: '17'
21+
22+
- name: Import GPG key
23+
run: |
24+
echo "${{ secrets.SIGNING_KEY }}" | gpg --batch --import
25+
26+
- name: Publish core
27+
run: ./gradlew :library-core:publishReleasePublicationToOSSRHRepository
28+
29+
- name: Publish feature
30+
run: ./gradlew :library-feature:publishReleasePublicationToOSSRHRepository

assists/build.gradle

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'maven-publish'
3+
apply plugin: 'signing'
34
apply plugin: 'kotlin-android'
45
apply plugin: 'kotlin-kapt'
56
apply plugin: 'org.jetbrains.dokka'
@@ -62,4 +63,66 @@ afterEvaluate {
6263
}
6364
}
6465

66+
afterEvaluate {
67+
publishing {
68+
publications {
69+
release(MavenPublication) {
70+
from components.release
71+
72+
groupId = 'io.github.ven-coder'
73+
artifactId = 'assists-base'
74+
version = '3.2.13'
75+
76+
pom {
77+
name = 'Assists Base'
78+
description = 'Assists Core'
79+
url = 'https://github.com/ven-coder/Assists'
80+
81+
licenses {
82+
license {
83+
name = 'GNU General Public License v3.0'
84+
url = 'https://www.gnu.org/licenses/gpl-3.0.html'
85+
distribution = 'repo'
86+
}
87+
}
88+
89+
developers {
90+
developer {
91+
id = 'ven-coder'
92+
name = 'Ven'
93+
email = 'ven_coder_ing@126.com'
94+
}
95+
}
96+
97+
scm {
98+
url = 'https://github.com/ven-coder/Assists'
99+
connection = 'scm:git:https://github.com/ven-coder/Assists.git'
100+
developerConnection = 'scm:git:https://github.com/ven-coder/Assists.git'
101+
}
102+
}
103+
}
104+
}
105+
106+
repositories {
107+
maven {
108+
name = 'OSSRH'
109+
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
110+
credentials {
111+
username = ossrhUsername
112+
password = ossrhPassword
113+
}
114+
}
115+
}
116+
}
117+
118+
signing {
119+
useInMemoryPgpKeys(
120+
findProperty("signing.keyId"),
121+
findProperty("signing.secretKeyRingFile") ? file(findProperty("signing.secretKeyRingFile")).text : '',
122+
findProperty("signing.password")
123+
)
124+
sign publishing.publications
125+
}
126+
}
127+
65128

gradle.properties

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ GROUP_ID=com.ven.assist
1515
VERSION=0.0.3-beta01
1616
android.enableJetifier=true
1717
android.useAndroidX=true
18-
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
18+
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
19+
20+
ossrhUsername=${OSSRH_USERNAME}
21+
ossrhPassword=${OSSRH_PASSWORD}
22+
23+
signing.keyId=${SIGNING_KEY_ID}
24+
signing.password=${SIGNING_PASSWORD}
25+
signing.secretKeyRingFile=secring.gpg

0 commit comments

Comments
 (0)