그동안 목표였던 Grapheme을 활용한 라이브러리를 만들고 배포했다.
배포하는 과정을 기록했으니 라이브러리를 만들고 싶다면 이 순서를 따라온다면 좋을 것 같다.
라이브러리도 구경하고 가세요~
https://github.com/chattymin/Pebble
GitHub - chattymin/Pebble: Treat String Like A Pebble With Grapheme At Kotlin 🫧 The Easy Way To Use Emoji 🚀
Treat String Like A Pebble With Grapheme At Kotlin 🫧 The Easy Way To Use Emoji 🚀 - chattymin/Pebble
github.com
MaveCentral 준비
Maven Central 계정을 우선 만든다
Github 계정으로 로그인해준 후 인증을 해주면 귀찮은 여러 과정들을 스킵할 수 있다.
가입이 완료된 후 ViewAcount에 가게 되면 Generate User Token이라는 버튼이 존재한다.
버튼을 눌러 토큰을 생성해보자.
여기서 Username과 Password를 복사해서 어딘가에 저장해두자.
GPG 준비
먼저 GPG 키를 생성하기 위해서는 pnupg가 필요하다. 그리고 pnupg를 사용하기 위해서는 pup가 필요하다.
그렇기에 pup와 pnupg를 순서대로 다운로드 해준다.
homebrew를 기준으로 설명하니 없다면 다운받아오자.
brew install pup
brew install pnupg
pnupg를 다운로드 받았다면 key를 생성해보자.
gpg --full-generate-key --command-fd 0 --status-fd 1 --pinentry-mode loopback
해당 코드를 치면 터미널에 뭔가 많은 텍스트가 나올 것이다.
하나씩 시작해보자.
Please select what kind of key you want:
(1) RSA and RSA
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
(9) ECC (sign and encrypt) default
(10) ECC (sign only)
(14) Existing key from card [GNUPG:] GET_LINE keygen.algo
⇒ 나도 뭔지 몰라서 GPT한테 물어보니까 1번을 추천한다고 해서 1번으로 했다.
[GNUPG:] GOT_IT
Requested keysize is 3072 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
[GNUPG:] GET_LINE keygen.valid
⇒ 키 갱신과 관련된 내용이다. 자주 만료될수록 보안상 좋겠지만, 난 귀찮으니 0을 했다.
GnuPG needs to construct a user ID to identify your key.
[GNUPG:] GET_LINE keygen.name
⇒ 내 이름 입력
[GNUPG:] GET_LINE keygen.email
⇒ 내 이메일 입력
[GNUPG:] GET_LINE keygen.comment
⇒ 코멘트 입력
You selected this USER-ID:
"이름 (코멘트) 이메일"
⇒ 최종 확인한번 시켜주는거다.
We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy.
[GNUPG:] INQUIRE_MAXLEN 100
[GNUPG:] GET_HIDDEN passphrase.enter
⇒ 비밀번호를 넣으면 된다. 단, 이때 넣은 비밀번호를 추후 사용해야하니 잘 기록해두자.
[GNUPG:] GOT_IT
gpg: directory '/Users/userName/.gnupg/openpgp-revocs.d' created
[GNUPG:] KEY_CONSIDERED key_considered
gpg: revocation certificate stored as '/Users/userName/.gnupg/openpgp-revocs.d/key_number.rev'
public and secret key created and signed.
pub rsa???? 2025-04-01 [SC]
key_number
uid 이름 (코멘트) 이메일
sub rsa???? 2025-04-01 [E]
이런 형식이 나오며 종료될 것이다.
그러면 GPG 키를 정상적으로 생성한 것이다.
이제 생성한 키를 확인해보자.
gpg --list-keys --keyid-format LONG
[keyboxd]
pub rsa????/pubKey 2025-04-01 [SC]
key_number
uid [ultimate] 이름 (코멘트) 이메일
sub rsa????/subKey 2025-04-01 [E]
이런식으로 나올 것이다.
이제 이 값을 이용해서 public key 를 key server 에 업로드 해보자.
gpg --keyserver hkps://keyserver.ubuntu.com --send-keys pubKey
근데 이 방법을 사용하면 오류가 발생할 수도 있다. 내가 그랬다.
그렇다면 아래에 있는 코드를 넣어보자
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys pubKey
성공했다면, 아래에 있는 코드를 통해 gpg 키 파일을 생성하자.
gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg
라이브러리에서 Publish하자
배포하고자 하는 모듈의 Plugin에 vanniktech를 넣어주자.
plugins {
id("com.vanniktech.maven.publish") version "0.31.0-rc2"
}
그 후 Maven Central 에 게시를 활성화하고, GPG 서명을 활성화한다.
import com.vanniktech.maven.publish.SonatypeHost
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
}
POM을 configure 해준다. POM은 프로젝트에 대한 정보를 담고있는다
mavenPublishing {
coordinates("io.github.nickname", "libraryName", "0.0.1")
// io.github.nickname:libraryName:0.0.1 추후 이렇게 Import 하게 된다.
pom {
name.set("libraryName")
description.set("A description of what my library does.")
inceptionYear.set("2025")
url.set("<https://github.com/username/libraryName>")
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>")
}
}
developers {
developer {
id.set("username")
name.set("User Name")
url.set("<https://github.com/username/>")
}
}
scm {
url.set("<https://github.com/username/libraryName>")
connection.set("scm:git:git://github.com/username/libraryName.git")
developerConnection.set("scm:git:ssh://git@github.com/username/libraryName.git")
}
}
}
실제 내가 배포한 Pebble이라는 라이브러리에서 작성한 코드 예시다
import com.vanniktech.maven.publish.SonatypeHost
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.vanniktech)
}
android {
...
}
dependencies {
...
}
val pebbleVersion = "0.0.1"
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
coordinates("io.github.chattymin", "pebble", pebbleVersion)
pom {
name = "Pebble"
description = "Android Grapheme String Extensions"
url = "<https://github.com/chattymin/Pebble>"
inceptionYear = "2025"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "<http://www.apache.org/licenses/LICENSE-2.0.txt>"
}
}
developers {
developer {
id = "chattymin"
name = "chattymin"
email = "parkdongmin123@gmail.com"
url = "<https://github.com/chattymin>"
}
}
scm {
connection = "scm:git:github.com/chattymin/pebble.git"
developerConnection.set("scm:git:ssh://github.com:chattymin/pebble.git")
url = "<https://github.com/chattymin/pebble>"
}
}
}
gradle.properties
프로젝트 루트의 gradle.properties 혹은 ~/.gradle/gradle.properties에 아래 내용을 추가한 후 명령어를 사용하면 배포가 된다. 단, 해당 내용이 레포지토리에 공개되지 않도록 조심해야 한다.
mavenCentralUsername=UserName # Maven Central token 의 username
mavenCentralPassword=Password # Maven Central token 의 password
signing.keyId=pubKey # key 의 id
signing.password=paswword # key 의 패스워드
signing.secretKeyRingFile=/Users/userName/.gnupg/secring.gpg # secring.gpg 의 경로
maven으로 시작하는 두개는 회원가입시 생성했던 토큰의 userName과 pw를 이야기하는 것이다.
값을 올바르게 넣었더라도 오류가 발생하는 경우가 있다. 이는 토큰이 만료된 것이니 당황하지 말고 재발급 받으면 된다.
keyId의 경우 gpg --list-keys --keyid-format LONG 명령어로 구한 값에서 pubKey를 넣으면 된다.
단, key가 너무 길어서 오류가 발생한다면 gpg --list-keys --keyid-format short 명령어를 통해 나온 pubKey를 사용해주면 된다.
password는 위 GPG키를 생성할 때 사용한 비밀번호를 넣으면 된다.
secretKeyRingFile의 경우 파일이 생성된 위치를 나타내면 되는데 대부분 저 위치에 생성된다. userName 부분만 본인 기기의 사용자 이름으로 변경하면 된다.
아래 명령어를 사용하여 배포해주면 끝~
./gradlew publishAllPublicationsToMavenCentralRepository --no-configuration-cache
그 후 Maven Central에 가서 해당 버튼들이 활성화되어있다면 publish 해주면 된다.
시간이 조금 지나고나면 완전히 배포가 되고 다른 앱에서 import하여 사용이 가능해진다.