Skip to content

Commit a5feb54

Browse files
committed
Update Maven Setup
1 parent be46565 commit a5feb54

File tree

5 files changed

+282
-4
lines changed

5 files changed

+282
-4
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish Android Library
2+
3+
on:
4+
push:
5+
tags:
6+
- "android-*.*.*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: "17"
21+
distribution: "temurin"
22+
cache: gradle
23+
24+
- name: Grant execute permission for gradlew
25+
working-directory: android
26+
run: chmod +x gradlew
27+
28+
- name: Build library
29+
working-directory: android
30+
run: ./gradlew :library:assemble
31+
32+
- name: Run tests
33+
working-directory: android
34+
run: ./gradlew :library:test
35+
36+
# ✅ Publish to Maven Central via Central Portal API
37+
# Uses https://central.sonatype.com/api/v1/publisher/upload
38+
- name: Publish to Maven Central
39+
working-directory: android
40+
env:
41+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_TOKEN_USERNAME }}
42+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_TOKEN_PASSWORD }}
43+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
44+
run: |
45+
# Decode Base64 GPG key to ASCII-armored format
46+
export ORG_GRADLE_PROJECT_signingInMemoryKey=$(echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode)
47+
48+
./gradlew :library:publishAllPublicationsToMavenCentralRepository \
49+
--no-configuration-cache \
50+
--no-daemon \
51+
--stacktrace
52+
53+
# ✅ Upload artifacts
54+
- name: Upload build artifacts
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: android-library-artifacts
58+
path: |
59+
android/library/build/outputs/aar/*.aar
60+
android/library/build/libs/*.jar
61+
retention-days: 7

android/PUBLISHING.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Android Library - Maven Central Publishing Guide
2+
3+
이 문서는 RefineUI System Icons Android 라이브러리를 Maven Central에 배포하는 방법을 설명합니다.
4+
5+
## 사전 준비
6+
7+
### 1. Sonatype Central Portal 계정 설정
8+
9+
1. [Sonatype Central Portal](https://central.sonatype.com/)에 계정 생성
10+
2. User Token 생성:
11+
- Account → Generate User Token
12+
- Username과 Password를 안전하게 보관
13+
14+
### 2. GPG 키 생성 및 설정
15+
16+
```bash
17+
# GPG 키 생성
18+
gpg --full-generate-key
19+
20+
# 키 목록 확인
21+
gpg --list-secret-keys --keyid-format LONG
22+
23+
# 공개 키를 키 서버에 업로드
24+
gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_ID
25+
26+
# Private Key를 Base64로 인코딩
27+
gpg --armor --export-secret-keys YOUR_KEY_ID | base64 > gpg-key.base64
28+
```
29+
30+
### 3. GitHub Secrets 설정
31+
32+
Repository Settings → Secrets and variables → Actions에서 다음 secrets를 추가:
33+
34+
- `SONATYPE_TOKEN_USERNAME`: Sonatype User Token의 Username
35+
- `SONATYPE_TOKEN_PASSWORD`: Sonatype User Token의 Password
36+
- `GPG_PRIVATE_KEY`: Base64로 인코딩된 GPG private key (gpg-key.base64 파일 내용)
37+
- `GPG_PASSPHRASE`: GPG 키 생성 시 설정한 passphrase
38+
39+
## 배포 방법
40+
41+
### 자동 배포 (GitHub Actions)
42+
43+
1. 버전 업데이트:
44+
45+
```bash
46+
# android/gradle.properties에서 VERSION_NAME 수정
47+
VERSION_NAME=0.3.14
48+
```
49+
50+
2. Git 태그 생성 및 푸시:
51+
52+
```bash
53+
git tag android-0.3.14
54+
git push origin android-0.3.14
55+
```
56+
57+
3. GitHub Actions가 자동으로 배포를 진행합니다.
58+
59+
### 수동 배포 (로컬)
60+
61+
1. `gradle.properties` 또는 환경 변수 설정:
62+
63+
```bash
64+
export ORG_GRADLE_PROJECT_mavenCentralUsername="your-username"
65+
export ORG_GRADLE_PROJECT_mavenCentralPassword="your-password"
66+
export ORG_GRADLE_PROJECT_signingInMemoryKey=$(cat gpg-key.base64 | base64 --decode)
67+
export ORG_GRADLE_PROJECT_signingInMemoryKeyPassword="your-passphrase"
68+
```
69+
70+
2. 배포 실행:
71+
```bash
72+
cd android
73+
./gradlew :library:publishAllPublicationsToMavenCentralRepository
74+
```
75+
76+
## 배포 확인
77+
78+
1. [Sonatype Central Portal](https://central.sonatype.com/)에 로그인
79+
2. Deployments 메뉴에서 배포 상태 확인
80+
3. 검증이 완료되면 자동으로 Maven Central에 동기화됩니다 (약 30분 소요)
81+
82+
## Gradle 설정 파일 구조
83+
84+
```
85+
android/
86+
├── gradle/
87+
│ └── libs.versions.toml # 플러그인 버전 관리
88+
├── library/
89+
│ └── build.gradle.kts # 라이브러리 빌드 및 배포 설정
90+
└── gradle.properties # POM 메타데이터 설정
91+
```
92+
93+
## 버전 관리
94+
95+
- `android/gradle.properties``VERSION_NAME` 값을 수정하여 버전 관리
96+
- Semantic Versioning 사용: `MAJOR.MINOR.PATCH`
97+
- Git 태그는 `android-X.Y.Z` 형식 사용
98+
99+
## 트러블슈팅
100+
101+
### 1. GPG 서명 실패
102+
103+
- GPG 키가 올바르게 Base64 인코딩되었는지 확인
104+
- Passphrase가 정확한지 확인
105+
106+
### 2. Maven Central 업로드 실패
107+
108+
- Sonatype credentials가 올바른지 확인
109+
- Group ID와 namespace가 일치하는지 확인
110+
111+
### 3. 검증 실패
112+
113+
- POM 파일의 필수 정보가 모두 포함되어 있는지 확인
114+
- Source 및 Javadoc JAR가 생성되었는지 확인
115+
116+
## 배포 정보 확인
117+
118+
```bash
119+
cd android
120+
./gradlew :library:printPublicationInfo
121+
```
122+
123+
## 참고 자료
124+
125+
- [Maven Central Publishing Requirements](https://central.sonatype.org/publish/requirements/)
126+
- [Vanniktech Maven Publish Plugin](https://vanniktech.github.io/gradle-maven-publish-plugin/)

android/gradle.properties

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,30 @@ kotlin.code.style=official
2222
# Enables namespacing of each library's R class so that its R class includes only the
2323
# resources declared in the library itself and none from the library's dependencies,
2424
# thereby reducing the size of the R class for that library
25-
android.nonTransitiveRClass=true
25+
android.nonTransitiveRClass=true
26+
27+
# Maven Central Publishing
28+
GROUP=com.pelagornis
29+
VERSION_NAME=0.3.13
30+
31+
# POM Configuration
32+
POM_ARTIFACT_ID=refineui-system-icons
33+
POM_NAME=RefineUI System Icons
34+
POM_DESCRIPTION=A comprehensive system icon library for Android with 5,000+ icons in regular and filled variants
35+
POM_URL=https://github.com/pelagornis/refineui-system-icons
36+
POM_INCEPTION_YEAR=2024
37+
38+
# License
39+
POM_LICENSE_NAME=MIT License
40+
POM_LICENSE_URL=https://opensource.org/licenses/MIT
41+
POM_LICENSE_DIST=repo
42+
43+
# Developer
44+
POM_DEVELOPER_ID=pelagornis
45+
POM_DEVELOPER_NAME=Pelagornis
46+
POM_DEVELOPER_URL=https://github.com/pelagornis
47+
48+
# SCM
49+
POM_SCM_URL=https://github.com/pelagornis/refineui-system-icons
50+
POM_SCM_CONNECTION=scm:git:git://github.com/pelagornis/refineui-system-icons.git
51+
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/pelagornis/refineui-system-icons.git

android/gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ material = "1.12.0"
99
activity = "1.10.1"
1010
constraintlayout = "2.1.4"
1111
recyclerview = "1.3.2"
12+
mavenPublish = "0.30.0"
1213

1314
[libraries]
1415
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -25,4 +26,5 @@ androidx-recyclerview = { group = "androidx.recyclerview", name = "recyclerview"
2526
android-application = { id = "com.android.application", version.ref = "agp" }
2627
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
2728
android-library = { id = "com.android.library", version.ref = "agp" }
29+
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
2830

android/library/build.gradle.kts

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
import com.vanniktech.maven.publish.SonatypeHost
2+
13
plugins {
24
alias(libs.plugins.android.library)
35
alias(libs.plugins.kotlin.android)
6+
alias(libs.plugins.maven.publish)
47
}
58

9+
group = findProperty("GROUP") as String? ?: "com.pelagornis"
10+
version = findProperty("VERSION_NAME") as String? ?: "0.3.13"
11+
612
android {
7-
namespace = "com.pelagornis.library"
13+
namespace = "com.pelagornis.refineui.icons"
814
compileSdk = 36
915

1016
defaultConfig {
1117
minSdk = 24
1218
consumerProguardFiles("consumer-rules.pro")
13-
versionCode = 1
14-
versionName = "0.3.13"
1519
}
1620

1721
buildTypes {
@@ -36,4 +40,63 @@ dependencies {
3640
implementation(libs.androidx.core.ktx)
3741
implementation(libs.androidx.appcompat)
3842
implementation(libs.material)
43+
}
44+
45+
// Maven Central Publishing via Central Portal
46+
// https://central.sonatype.com/api/v1/
47+
mavenPublishing {
48+
// Publish to Maven Central via Central Portal
49+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
50+
51+
// Enable GPG signing for all publications
52+
signAllPublications()
53+
54+
// Configure coordinates
55+
coordinates(
56+
groupId = findProperty("GROUP") as String? ?: "com.pelagornis",
57+
artifactId = findProperty("POM_ARTIFACT_ID") as String? ?: "refineui-system-icons",
58+
version = findProperty("VERSION_NAME") as String? ?: project.version.toString()
59+
)
60+
61+
// Configure POM
62+
pom {
63+
name.set(findProperty("POM_NAME") as String? ?: "RefineUI System Icons")
64+
description.set(findProperty("POM_DESCRIPTION") as String? ?: "A comprehensive system icon library for Android with 5,000+ icons")
65+
url.set(findProperty("POM_URL") as String? ?: "https://github.com/pelagornis/refineui-system-icons")
66+
inceptionYear.set(findProperty("POM_INCEPTION_YEAR") as String? ?: "2024")
67+
68+
licenses {
69+
license {
70+
name.set(findProperty("POM_LICENSE_NAME") as String? ?: "MIT License")
71+
url.set(findProperty("POM_LICENSE_URL") as String? ?: "https://opensource.org/licenses/MIT")
72+
distribution.set(findProperty("POM_LICENSE_DIST") as String? ?: "repo")
73+
}
74+
}
75+
76+
developers {
77+
developer {
78+
id.set(findProperty("POM_DEVELOPER_ID") as String? ?: "pelagornis")
79+
name.set(findProperty("POM_DEVELOPER_NAME") as String? ?: "Pelagornis")
80+
url.set(findProperty("POM_DEVELOPER_URL") as String? ?: "https://github.com/pelagornis")
81+
}
82+
}
83+
84+
scm {
85+
url.set(findProperty("POM_SCM_URL") as String? ?: "https://github.com/pelagornis/refineui-system-icons")
86+
connection.set(findProperty("POM_SCM_CONNECTION") as String? ?: "scm:git:git://github.com/pelagornis/refineui-system-icons.git")
87+
developerConnection.set(findProperty("POM_SCM_DEV_CONNECTION") as String? ?: "scm:git:ssh://git@github.com/pelagornis/refineui-system-icons.git")
88+
}
89+
}
90+
}
91+
92+
// Debug Task
93+
tasks.register("printPublicationInfo") {
94+
doLast {
95+
println("=".repeat(60))
96+
println("Publication Info")
97+
println("Group ID: ${project.group}")
98+
println("Artifact ID: refineui-system-icons")
99+
println("Version: ${project.version}")
100+
println("=".repeat(60))
101+
}
39102
}

0 commit comments

Comments
 (0)