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 8, 2024
1 parent 42bbe97 commit df74478
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 6 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'

- 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: Publish to Maven Central
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository
57 changes: 51 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,56 @@
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"

repositories {
mavenCentral()
}

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

pom {
name = "easycodef-java-v2"
description = "Advanced EasyCodef Library for JDK"
inceptionYear = "2024"
url = "https://api.codef.io"

licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "happybean"
name = "Haebin Byeon"
email = "happybean@hecto.co.kr"
}
}

scm {
connection = "scm:git:git://github.com/codef-io/easycodef-java-v2.git"
developerConnection = "scm:git:ssh://github.com/codef-io/easycodef-java-v2.git"
url = "https://github.com/codef-io/easycodef-java-v2.git"
}

issueManagement {
system = "GitHub"
url = "https://github.com/codef-io/easycodef-java-v2/issues"
}
}
}


dependencies {

/**
Expand Down Expand Up @@ -40,16 +82,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)
}
}
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 df74478

Please sign in to comment.