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 4449bf3
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 7 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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: 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: Verify GPG key import
run: |
gpg --list-keys
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Set up GPG
run: |
# Create gpg directory
mkdir -p ~/.gnupg/
chmod 700 ~/.gnupg/
# Configure GPG
echo "use-agent" > ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
# Import private key
echo -n "$GPG_PRIVATE_KEY" > private.gpg
gpg --batch --import private.gpg
rm private.gpg
# Trust the key
echo -n "057F00512A25D4A1:6:" | gpg --batch --import-ownertrust
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Sign all publications
run: ./gradlew signAllPublications
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}

- name: Publish to Maven Central
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository
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
67 changes: 61 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,66 @@
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 {
useGpgCmd()
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 = "happybean@hecto.co.kr"
}
}

scm {
connection = "scm:git:git@github.com: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 +92,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 4449bf3

Please sign in to comment.