Skip to content

Commit

Permalink
chore: configure gitHub actions for automated deployment to maven cen…
Browse files Browse the repository at this point in the history
…tral
  • Loading branch information
h-beeen committed Nov 11, 2024
1 parent 42bbe97 commit f2b4409
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 7 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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: Configure gradle-wrapper.properties
run: |
echo "mavenCentralUsername=${{ secrets.OSSRH_USERNAME }}" >> gradle.properties
echo "mavenCentralPassword=${{ secrets.OSSRH_PASSWORD }}" >> gradle.properties
- 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 --stacktrace
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020~2025 Hectodata co,. Ltd
Copyright (c) 2024~2025 Hectodata co,. Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
70 changes: 64 additions & 6 deletions build.gradle.kts
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.S01)

coordinates("io.codef.api", "easycodef-jdk-v2", 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 {

/**
Expand Down Expand Up @@ -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)
}
}
Empty file added gradle.properties
Empty file.
5 changes: 5 additions & 0 deletions src/main/java/io/codef/api/CodefException.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package io.codef.api;

import java.io.Serial;

public class CodefException extends RuntimeException {

@Serial
private static final long serialVersionUID = 1L;

private static final String LOG_WITH_CAUSE_FORMAT = "%s\n→ %s\n\n";

private final CodefError codefError;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/codef/api/EasyCodefTokenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class EasyCodefTokenTest {

@Test
public void usageExample() {

}
}

0 comments on commit f2b4409

Please sign in to comment.