-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: configure gitHub actions for automated deployment to maven cen…
…tral
- Loading branch information
Showing
5 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Publish to Maven Central Repository | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Cache Gradle packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Extract version from build.gradle.kts | ||
id: get_version | ||
run: echo "::set-output name=VERSION::$(./gradlew -q printVersion)" | ||
|
||
- name: Create Git tag | ||
env: | ||
VERSION: ${{ steps.get_version.outputs.VERSION }} | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git tag -a "v${VERSION}" -m "Release version ${VERSION}" | ||
git push --force origin "v${VERSION}" | ||
- name: Set up GPG | ||
run: | | ||
echo "$GPG_PRIVATE_KEY" | gpg --batch --import | ||
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf | ||
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf | ||
gpg-connect-agent reloadagent /bye | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
|
||
- name: Publish to Maven Central | ||
env: | ||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | ||
run: | | ||
./gradlew publishAllPublicationsToMavenCentralRepository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,69 @@ | ||
import com.vanniktech.maven.publish.JavaLibrary | ||
import com.vanniktech.maven.publish.JavadocJar | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
|
||
plugins { | ||
java | ||
signing | ||
id("com.vanniktech.maven.publish") version "0.30.0" | ||
} | ||
|
||
|
||
group = "io.codef.api" | ||
version = "2.0.0-ALPHA-01" | ||
version = "2.0.0-alpha+001" | ||
|
||
signing { | ||
useInMemoryPgpKeys( | ||
System.getenv("GPG_PRIVATE_KEY"), | ||
System.getenv("GPG_PASSPHRASE") | ||
) | ||
sign(publishing.publications) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
mavenPublishing { | ||
configure(JavaLibrary(JavadocJar.Javadoc(), true)) | ||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
|
||
coordinates("io.codef.api", "easycodef-jdk", version.toString()) | ||
pom { | ||
url = "api.codef.io" | ||
name = "easycodef-jdk-v2" | ||
description = "Advanced EasyCodef Library for JDK" | ||
inceptionYear = "2024" | ||
|
||
licenses { | ||
license { | ||
name = "MIT License" | ||
url = "https://opensource.org/licenses/MIT" | ||
distribution = "https://opensource.org/licenses/MIT" | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = "happybean" | ||
name = "Haebin Byeon" | ||
email = "[email protected]" | ||
} | ||
} | ||
|
||
scm { | ||
connection = "scm:git:[email protected]:codef-io/easycodef-jdk-v2.git" | ||
developerConnection = "scm:git:ssh://github.com/codef-io/easycodef-jdk-v2.git" | ||
url = "https://github.com/codef-io/easycodef-jdk-v2" | ||
} | ||
|
||
issueManagement { | ||
system = "GitHub" | ||
url = "https://github.com/codef-io/easycodef-jdk-v2/issues" | ||
} | ||
} | ||
} | ||
|
||
|
||
dependencies { | ||
|
||
/** | ||
|
@@ -40,16 +95,19 @@ dependencies { | |
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.3") | ||
} | ||
|
||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
options.compilerArgs.add("-Xlint:all") | ||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
tasks.named<Test>("test") { | ||
useJUnitPlatform() | ||
tasks.register("printVersion") { | ||
doLast { | ||
println(project.version) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ public class EasyCodefTokenTest { | |
|
||
@Test | ||
public void usageExample() { | ||
|
||
} | ||
} |