Skip to content

Commit 2acf91a

Browse files
authored
Merge pull request #1 from theJawnnybot/feature/maven-central-release
Add Maven Central release workflow and modernize build
2 parents 9d50d21 + d8cebc0 commit 2acf91a

6 files changed

Lines changed: 116 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
name: Build
2-
on: [pull_request, push]
2+
3+
on:
4+
push:
5+
pull_request:
6+
37
jobs:
48
build:
59
runs-on: ubuntu-latest
10+
611
steps:
7-
- name: Checkout the code
8-
uses: actions/checkout@v2
9-
- name: Build the app
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Configure JDK
16+
uses: actions/setup-java@v4
17+
with:
18+
distribution: zulu
19+
java-version: '17'
20+
cache: gradle
21+
22+
- name: Validate Gradle Wrapper
23+
uses: gradle/actions/wrapper-validation@v4
24+
25+
- name: Build
1026
run: ./gradlew build
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
env:
9+
RELEASE_SIGNING_ENABLED: true
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
if: github.repository == 'Commit451/okyo'
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Install JDK
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: zulu
24+
java-version: '17'
25+
cache: gradle
26+
27+
- name: Set version
28+
run: sed -i "s/VERSION_NAME=1.0.0/VERSION_NAME=$GITHUB_REF_NAME/" gradle.properties
29+
30+
- name: Release to Maven Central
31+
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
32+
env:
33+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
34+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
35+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
36+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
[okio](https://github.com/square/okio) made easy, yo
44

5-
[![](https://jitpack.io/v/Commit451/okyo.svg)](https://jitpack.io/#Commit451/okyo)
5+
[![Maven Central](https://img.shields.io/maven-central/v/com.commit451/okyo.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.commit451/okyo)
6+
7+
## Gradle
8+
9+
```kotlin
10+
dependencies {
11+
implementation("com.commit451:okyo:VERSION")
12+
}
13+
```
614

715
# Usefulness
816

build.gradle

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1-
buildscript {
2-
ext.kotlin_version = '1.8.22'
1+
import com.vanniktech.maven.publish.SonatypeHost
32

4-
repositories {
5-
mavenCentral()
6-
}
7-
dependencies {
8-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
9-
}
3+
plugins {
4+
id 'java-library'
5+
id 'org.jetbrains.kotlin.jvm' version '2.1.10'
6+
id 'com.vanniktech.maven.publish' version '0.30.0'
107
}
118

12-
group 'com.commit451.okyo'
13-
version '1.0.0'
14-
15-
apply plugin: 'java-library'
16-
apply plugin: 'kotlin'
9+
group = findProperty("GROUP")
10+
version = findProperty("VERSION_NAME")
1711

1812
java {
1913
toolchain {
20-
languageVersion.set(JavaLanguageVersion.of(8))
14+
languageVersion = JavaLanguageVersion.of(17)
2115
}
2216
}
2317

18+
kotlin {
19+
jvmToolchain(17)
20+
}
21+
2422
repositories {
2523
mavenCentral()
2624
}
2725

2826
dependencies {
29-
api("com.squareup.okio:okio:3.5.0")
27+
api("com.squareup.okio:okio:3.10.2")
3028

31-
testImplementation 'junit:junit:4.13.1'
29+
testImplementation("junit:junit:4.13.2")
30+
}
31+
32+
tasks.withType(Test).configureEach {
33+
useJUnit()
34+
}
35+
36+
mavenPublishing {
37+
publishToMavenCentral(SonatypeHost.S01)
38+
if (System.getenv("RELEASE_SIGNING_ENABLED") == "true") {
39+
signAllPublications()
40+
}
3241
}

gradle.properties

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
GROUP=com.commit451
2+
POM_ARTIFACT_ID=okyo
3+
POM_PACKAGING=jar
4+
5+
POM_NAME=okyo
6+
POM_DESCRIPTION=okio made easy, yo
7+
POM_INCEPTION_YEAR=2017
8+
POM_URL=https://github.com/Commit451/okyo/
9+
10+
POM_LICENSE_NAME=The Apache Software License, Version 2.0
11+
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
12+
POM_LICENSE_DIST=repo
13+
14+
POM_SCM_URL=https://github.com/Commit451/okyo/
15+
POM_SCM_CONNECTION=scm:git:git://github.com/Commit451/okyo/.git
16+
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/Commit451/okyo/.git
17+
18+
POM_DEVELOPER_ID=Commit451
19+
POM_DEVELOPER_NAME=Commit 451
20+
POM_DEVELOPER_URL=https://github.com/Commit451/
21+
22+
SONATYPE_CONNECT_TIMEOUT_SECONDS=60
23+
SONATYPE_CLOSE_TIMEOUT_SECONDS=900
24+
25+
VERSION_NAME=1.0.0

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)