Skip to content

Commit b91e507

Browse files
authored
chore: update publication mechanism (#185)
1 parent dfe370c commit b91e507

File tree

13 files changed

+356
-280
lines changed

13 files changed

+356
-280
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,31 @@
11
name: Build
2+
23
on:
3-
workflow_dispatch:
44
push:
5+
branches: [main]
6+
57
jobs:
6-
lint:
7-
runs-on: ubuntu-latest
8-
if: github.ref != 'refs/heads/main'
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v2
12-
- name: Setup JDK 11
13-
uses: actions/setup-java@v2
14-
with:
15-
java-version: '11'
16-
distribution: 'adopt'
17-
server-id: github
18-
cache: 'gradle'
19-
- name: Gradle Wrapper Validation
20-
uses: gradle/[email protected]
21-
- name: KtLint
22-
uses: burrunan/gradle-cache-action@v1
23-
with:
24-
arguments: lintKotlin --continue --stacktrace
25-
gradle-version: wrapper
26-
- name: Detekt
27-
uses: burrunan/gradle-cache-action@v1
28-
with:
29-
arguments: detekt --continue --stacktrace
30-
gradle-version: wrapper
31-
binary-compatibility:
32-
runs-on: ubuntu-latest
33-
steps:
34-
- name: Checkout
35-
uses: actions/checkout@v2
36-
- name: Setup JDK 11
37-
uses: actions/setup-java@v2
38-
with:
39-
java-version: '11'
40-
distribution: 'adopt'
41-
server-id: github
42-
cache: 'gradle'
43-
- name: Gradle Wrapper Validation
44-
uses: gradle/[email protected]
45-
- name: Check binary Compatibility
46-
uses: burrunan/gradle-cache-action@v1
47-
with:
48-
arguments: apiCheck
49-
gradle-version: wrapper
508
build:
519
runs-on: ubuntu-latest
5210
permissions:
5311
contents: read
5412
packages: write
5513
steps:
5614
- name: Checkout
57-
uses: actions/checkout@v2
58-
- name: Setup JDK 11
59-
uses: actions/setup-java@v2
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@v4
6021
with:
6122
java-version: '11'
62-
distribution: 'adopt'
23+
distribution: 'temurin'
6324
server-id: github
64-
cache: 'gradle'
65-
- name: Gradle Wrapper Validation
66-
uses: gradle/[email protected]
67-
- name: Build with Gradle
68-
uses: burrunan/gradle-cache-action@v1
69-
env:
70-
OSSRH_SIGNING_KEY: ${{ secrets.OSSRH_SIGNING_KEY }}
71-
OSSRH_SIGNING_PASSWORD: ${{ secrets.OSSRH_SIGNING_PASSWORD }}
72-
GITHUB_USERNAME: ${{ github.actor }}
73-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74-
with:
75-
arguments: clean --no-configuration-cache --no-build-cache build -x check
76-
gradle-version: wrapper
25+
settings-path: ${{ github.workspace }}
26+
27+
- name: Set up Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
30+
- name: Build
31+
run: ./gradlew build

.github/workflows/integration-tests.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Integration Tests
33
on:
44
push:
55
branches: [ main ]
6-
pull_request:
76

87
jobs:
98
docker:
@@ -18,21 +17,27 @@ jobs:
1817
- macos-latest
1918
runs-on: ${{ matrix.os }}
2019
steps:
21-
- name: Setup Docker
22-
uses: docker-practice/actions-setup-docker@master
2320
- name: Checkout
24-
uses: actions/checkout@v2
25-
- name: Setup JDK 11
26-
uses: actions/setup-java@v2
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up JDK 11
26+
uses: actions/setup-java@v4
2727
with:
2828
java-version: '11'
29-
distribution: 'adopt'
29+
distribution: 'temurin'
3030
server-id: github
31-
cache: 'gradle'
31+
settings-path: ${{ github.workspace }}
32+
33+
- name: Setup Docker
34+
uses: docker-practice/actions-setup-docker@master
35+
3236
- name: Prune Docker System
3337
run: docker system prune -a -f
38+
39+
- name: Set up Gradle
40+
uses: gradle/actions/setup-gradle@v4
41+
3442
- name: Run Tests
35-
uses: burrunan/gradle-cache-action@v1
36-
with:
37-
arguments: allTests
38-
gradle-version: wrapper
43+
run: ./gradlew allTests

.github/workflows/pr.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Pull Request
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
lint:
8+
name: Lint Codebase
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set up JDK 11
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '11'
20+
distribution: 'temurin'
21+
server-id: github
22+
settings-path: ${{ github.workspace }}
23+
24+
- name: Set up Gradle
25+
uses: gradle/actions/setup-gradle@v4
26+
27+
- name: KtLint
28+
run: ./gradlew lintKotlin --continue --stacktrace
29+
30+
- name: Detekt
31+
run: detekt --continue --stacktrace
32+
binary-compatibility:
33+
runs-on: ubuntu-latest
34+
name: Binary Compatibility Check
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Set up JDK 11
42+
uses: actions/setup-java@v4
43+
with:
44+
java-version: '11'
45+
distribution: 'temurin'
46+
server-id: github
47+
settings-path: ${{ github.workspace }}
48+
49+
- name: Set up Gradle
50+
uses: gradle/actions/setup-gradle@v4
51+
52+
- name: Check Binary Compatibility
53+
run: ./gradlew apiCheck

.github/workflows/publish.yml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
name: Publish
1+
name: Publish Release
2+
23
on:
3-
workflow_dispatch:
4-
release:
5-
types: [ published ]
4+
push:
5+
tags: [ 'v*.*.*' ]
6+
67
jobs:
78
publish:
89
name: Publish
@@ -12,24 +13,25 @@ jobs:
1213
packages: write
1314
steps:
1415
- name: Checkout
15-
uses: actions/checkout@v2
16-
- name: Setup JDK 11
17-
uses: actions/setup-java@v2
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up JDK 11
21+
uses: actions/setup-java@v4
1822
with:
1923
java-version: '11'
20-
distribution: 'adopt'
24+
distribution: 'temurin'
2125
server-id: github
22-
cache: 'gradle'
23-
- name: Gradle Wrapper Validation
24-
uses: gradle/[email protected]
25-
- name: Build with Gradle
26-
uses: burrunan/gradle-cache-action@v1
26+
settings-path: ${{ github.workspace }}
27+
28+
- name: Set up Gradle
29+
uses: gradle/actions/setup-gradle@v4
30+
31+
- name: Publish to Maven Central
32+
run: ./gradlew publishAndReleaseToMavenCentral -Pversion=${{ github.ref_name }} --no-daemon --stacktrace --no-configuration-cache
2733
env:
28-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
29-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
30-
OSSRH_SIGNING_KEY: ${{ secrets.OSSRH_SIGNING_KEY }}
31-
OSSRH_SIGNING_PASSWORD: ${{ secrets.OSSRH_SIGNING_PASSWORD }}
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
with:
34-
arguments: --no-configuration-cache publish
35-
gradle-version: wrapper
34+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
35+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_TOKEN }}
36+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.OSSRH_SIGNING_KEY }}
37+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.OSSRH_SIGNING_PASSWORD }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Integration Tests](https://github.com/DevNatan/docker-kotlin/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/DevNatan/docker-kotlin/actions/workflows/integration-tests.yml)
55
![Maven Central](https://img.shields.io/maven-central/v/me.devnatan/docker-kotlin)
66

7-
docker-kotlin allows you to interact with the Docker Engine Remote API in a simplified and fast way.
7+
docker-kotlin allows you to interact with the Docker Engine Remote API.
88

99
* [Installation](#installation)
1010
* [Basic Usage](#basic-usage)

THIRDPARTY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This document contains a list of third-party libraries that docker-client uses.
99
* [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime)
1010
* [kotlinx-io](https://github.com/Kotlin/kotlinx-io)
1111
* [JetBrains Annotations](https://github.com/JetBrains/java-annotations)
12-
* [publish-on-central](https://github.com/DanySK/publish-on-central)
12+
* [vanniktech's publish plugin](github.com/vanniktech/gradle-maven-publish-plugin)
1313
* [kotlinter](https://github.com/jeremymailen/kotlinter-gradle)
1414
* [detekt](https://github.com/detekt/detekt)
1515
* [slf4j](https://www.slf4j.org/)

build.gradle.kts

Lines changed: 18 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,30 @@ plugins {
55
alias(libs.plugins.kotlin.multiplatform)
66
alias(libs.plugins.kotlinx.serialization)
77
alias(libs.plugins.kotlinter)
8-
alias(libs.plugins.publishOnCentral)
8+
alias(libs.plugins.publish)
99
alias(libs.plugins.binaryCompatibilityValidator)
1010
alias(libs.plugins.kover)
1111
alias(libs.plugins.detekt)
1212
}
1313

1414
group = "me.devnatan"
15-
version = "0.7.0-SNAPSHOT"
15+
version = property("version")
16+
.toString()
17+
.takeUnless { it == "unspecified" }
18+
?.filterNot { it == 'v' } ?: nextGitTag()
19+
20+
@Suppress("UnstableApiUsage")
21+
fun nextGitTag(): String {
22+
val latestTag = providers.exec {
23+
commandLine("git", "describe", "--tags", "--abbrev=0")
24+
}.standardOutput.asText.get().trim()
25+
26+
val versionParts = latestTag.removePrefix("v").split(".")
27+
val major = versionParts.getOrNull(0)?.toIntOrNull() ?: 0
28+
val minor = versionParts.getOrNull(1)?.toIntOrNull() ?: 0
29+
30+
return "$major.${minor + 1}.0-SNAPSHOT"
31+
}
1632

1733
repositories {
1834
mavenCentral()
@@ -100,50 +116,6 @@ kotlin {
100116
}
101117
}
102118

103-
val isReleaseVersion = !version.toString().endsWith("SNAPSHOT")
104-
publishOnCentral {
105-
projectDescription.set("Multiplatform Docker API client")
106-
projectLongName.set(project.name)
107-
licenseName.set("MIT")
108-
licenseUrl.set("https://github.com/DevNatan/docker-kotlin/blob/main/LICENSE")
109-
projectUrl.set("https://github.com/DevNatan/docker-kotlin")
110-
scmConnection.set("git:[email protected]:DevNatan/docker-kotlin")
111-
112-
mavenCentral.user.set(System.getenv("OSSRH_USERNAME"))
113-
mavenCentral.password.set(provider { System.getenv("OSSRH_PASSWORD") })
114-
115-
if (!isReleaseVersion)
116-
mavenCentralSnapshotsRepository()
117-
}
118-
119-
signing {
120-
isRequired = isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives")
121-
useInMemoryPgpKeys(
122-
System.getenv("OSSRH_SIGNING_KEY"),
123-
System.getenv("OSSRH_SIGNING_PASSWORD")
124-
)
125-
}
126-
127-
publishing {
128-
publications {
129-
withType<MavenPublication> {
130-
if ("OSSRH" !in name) {
131-
artifact(tasks.javadocJar)
132-
}
133-
134-
pom {
135-
developers {
136-
developer {
137-
name.set("Natan Vieira")
138-
email.set("[email protected]")
139-
url.set("http://www.devnatan.me/")
140-
}
141-
}
142-
}
143-
}
144-
}
145-
}
146-
147119
tasks {
148120
check {
149121
dependsOn("installKotlinterPrePushHook")

gradle.properties

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,20 @@ kotlin.mpp.stability.nowarn=true
44
org.gradle.caching=true
55
org.gradle.parallel=true
66
org.gradle.unsafe.configuration-cache=true
7-
kotlin.mpp.enableCInteropCommonization=true
7+
kotlin.mpp.enableCInteropCommonization=true
8+
9+
POM_NAME=docker-kotlin
10+
POM_DESCRIPTION=Docker Engine Remote API client
11+
POM_URL=https://github.com/DevNatan/docker-kotlin
12+
POM_INCEPTION_YEAR=2021
13+
POM_SCM_URL=https://github.com/DevNatan/docker-kotlin
14+
POM_SCM_CONNECTION=scm:git:git:github.com/DevNatan/docker-kotlin.git
15+
POM_SCM_DEV_CONNECTION=scm:git:https://github.com/DevNatan/docker-kotlin.git
16+
POM_LICENCE_NAME=MIT License
17+
POM_LICENSE_URL=https://github.com/DevNatan/docker-kotlin/blob/main/LICENSE
18+
POM_DEVELOPER_ID=DevNatan
19+
POM_DEVELOPER_NAME=Natan Vieira do Nascimento
20+
POM_DEVELOPER_URL=[email protected]
21+
POM_DEVELOPER_EMAIL=https://github.com/DevNatan
22+
SONATYPE_HOST=CENTRAL_PORTAL
23+
RELEASE_SIGNING_ENABLED=true

0 commit comments

Comments
 (0)