Skip to content

Commit 0c0f313

Browse files
committed
Workflow initial commit & test
1 parent eef5d76 commit 0c0f313

3 files changed

Lines changed: 107 additions & 4 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Name of the workflow visible in the Actions tab
2+
name: Publish Release
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v*.*.*' # Triggers ONLY on push of semver tags (v0.1.3, v1.0.0, etc.)
8+
9+
permissions:
10+
contents: write # Allows creating/modifying releases and tags in the repo
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest # Free Linux VM, optimal for Gradle/Java
15+
16+
steps:
17+
# STEP 1: Clone the full repository
18+
- name: Checkout
19+
uses: actions/checkout@v4 # Official GitHub checkout action
20+
with:
21+
fetch-depth: 0 # Fetches FULL Git history (required for changelog)
22+
23+
# STEP 2: Install Java 25 (builds Java 8 compatible bytecode)
24+
- name: Setup Java
25+
uses: actions/setup-java@v4 # Official JDK setup action
26+
with:
27+
distribution: 'temurin' # Adoptium Temurin (open source, stable)
28+
java-version: '25' # Modern Java for faster builds
29+
30+
# STEP 3: Setup Gradle with intelligent caching
31+
- name: Setup Gradle
32+
uses: gradle/actions/setup-gradle@v4 # Official Gradle action
33+
# Auto-caches: ~/.gradle, dependencies, wrapper → reduces time from 10min to 1-2min
34+
35+
# STEP 4: Extract version from tag and pass to Gradle
36+
- name: Set version from tag
37+
run: echo "ORG_GRADLE_PROJECT_VERSION_NAME=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
38+
# Example: refs/tags/v0.1.3 → 0.1.3
39+
# Temporary override of 'version' in build.gradle.kts
40+
41+
# STEP 5: Build → Test → Javadoc → Signing → Upload → Auto-Release to Maven Central
42+
- name: Publish to Maven Central
43+
run: ./gradlew publishToMavenCentral --no-configuration-cache -Psign=true
44+
env:
45+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
46+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
47+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
48+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
49+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
50+
51+
# STEP 6: Create automatic GitHub Release with changelog
52+
- name: Create GitHub Release
53+
uses: softprops/action-gh-release@v2 # Popular release action
54+
if: runner.os != 'Windows' # Skip on Windows (known bugs)
55+
with:
56+
generate_release_notes: true # Analyzes commits → auto changelog
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Auto-generated GitHub token

build.gradle.kts

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
group = "io.github.wldt"
2-
version = "0.1.1"
2+
version = "0.1.2"
33
description = "Physical adapter to connect with the CoAP protocol"
44
java.sourceCompatibility = JavaVersion.VERSION_1_8
55

6-
76
plugins {
7+
id("com.vanniktech.maven.publish") version "0.35.0"
88
`java-library`
99
`maven-publish`
1010
signing
@@ -25,7 +25,7 @@ dependencies {
2525
}
2626

2727
java {
28-
withJavadocJar()
28+
//withJavadocJar()
2929
withSourcesJar()
3030
}
3131

@@ -39,3 +39,48 @@ tasks.withType<Javadoc>() {
3939
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
4040
}
4141
}
42+
43+
// ✅ FIX ESATTO PER GRADLE 9.2.1 + vanniktech.maven.publish 0.35.0
44+
afterEvaluate {
45+
val plainJavadocJarTask = tasks.findByName("plainJavadocJar")
46+
val metadataTask = tasks.findByName("generateMetadataFileForMavenPublication")
47+
48+
if (plainJavadocJarTask != null && metadataTask != null) {
49+
metadataTask.dependsOn(plainJavadocJarTask)
50+
}
51+
}
52+
53+
mavenPublishing {
54+
coordinates(group.toString(), name.toString(), version.toString())
55+
56+
pom {
57+
name.set("WLDT CoAP Physical Adapter")
58+
description.set("The CoAP Physical Adapter for a WLDT Digital Twin")
59+
inceptionYear.set("2025")
60+
url.set("https://github.com/wldt/coap-physical-adapter-java")
61+
licenses {
62+
license {
63+
name.set("The Apache License, Version 2.0")
64+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
65+
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
66+
}
67+
}
68+
developers {
69+
developer {
70+
id.set("msandonini")
71+
name.set("Mirco Sandonini")
72+
url.set("https://github.com/msandonini")
73+
}
74+
developer {
75+
id.set("piconem")
76+
name.set("Marco Picone")
77+
url.set("https://github.com/piconem")
78+
}
79+
}
80+
scm {
81+
url.set("https://github.com/wldt/coap-physical-adapter-java")
82+
connection.set("scm:git:git://github.com/wldt/coap-physical-adapter-java.git")
83+
developerConnection.set("scm:git:ssh://git@github.com/wldt/coap-physical-adapter-java.git")
84+
}
85+
}
86+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Wed Apr 30 13:04:16 CEST 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)