From faaa2bd1f1f1d0ec9e315038659f82a05b48b566 Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Wed, 2 Apr 2025 18:36:13 -0300 Subject: [PATCH 1/6] add gradle catalog publish to maven --- .github/workflows/release.yml | 65 +++++++++++++------------------- build.gradle | 41 ++++++++++++++------ gradle/libs.versions.toml | 32 ++++++++++++++++ gradle/publishing.gradle | 70 +++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 52 deletions(-) create mode 100644 gradle/libs.versions.toml create mode 100644 gradle/publishing.gradle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26972cd..ceb830d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,13 +1,14 @@ -name: Create Release - on: push: + # Sequence of patterns matched against refs/tags tags: - - '*' + - 'v[0-9]+.[0-9]+.[0-9]+' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Upload Release Asset jobs: - release: - name: Create Release + build: + name: Upload Release Asset runs-on: ubuntu-latest steps: - name: Checkout code @@ -15,46 +16,30 @@ jobs: with: fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v4 with: java-version: '11' - distribution: 'temurin' - cache: gradle - - - name: Cache Gradle and Assets - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - .gradle - build/assets - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '.gradle/dependency-locks/*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build Release - run: ./gradlew clean build --info - + distribution: 'zulu' + - name: Build with Gradle + run: ./gradlew build - name: Get Release Version id: get_version - run: | - VERSION=$(./gradlew currentVersion -q -Prelease.quiet | tail -n 1) - echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - echo "Detected version: ${VERSION}" - + run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - name: Create Release id: create_release - uses: softprops/action-gh-release@v1 - with: - name: Release ${{ steps.get_version.outputs.VERSION }} - draft: false - prerelease: false - files: | + run: | + gh release create \ + --generate-notes \ + --title 'Release ${{ steps.get_version.outputs.VERSION }}' \ + ${{ github.ref_name }} \ build/libs/git-plugin-${{ steps.get_version.outputs.VERSION }}.jar env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to Maven Central + run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} diff --git a/build.gradle b/build.gradle index fc6fd9d..4be4d0f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,23 @@ plugins { - id 'pl.allegro.tech.build.axion-release' version '1.16.1' + alias(libs.plugins.axionRelease) + alias(libs.plugins.nexusPublish) + id 'java' } group 'com.rundeck' ext.rundeckPluginVersion = '1.2' +ext.publishName = "Git Plugin ${project.version}" +ext.githubSlug = 'rundeck-plugins/git-plugin' ext.pluginClassNames='com.rundeck.plugin.GitResourceModelFactory,com.rundeck.plugin.GitCloneWorkflowStep,com.rundeck.plugin.GitPushWorkflowStep,com.rundeck.plugin.GitCommitWorkflowStep,com.rundeck.plugin.GitAddWorkflowStep' ext.pluginName = 'Git Plugin' ext.pluginDescription = 'This is a git plugin (based on Jgit) which contain a Resource model and worflow steps' +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + scmVersion { ignoreUncommittedChanges = true tag { @@ -35,27 +44,23 @@ configurations { dependencies { - implementation 'org.codehaus.groovy:groovy-all:3.0.9' - testImplementation group: 'junit', name: 'junit', version: '4.13.1' + // Use catalog aliases for dependencies + implementation(libs.groovyAll) + implementation(libs.rundeckCore) + implementation(libs.slf4jApi) - implementation group: 'org.rundeck', name: 'rundeck-core', version: '5.1.0-rc2-20240124' - implementation 'org.slf4j:slf4j-api:1.7.30' - - pluginLibs('org.eclipse.jgit:org.eclipse.jgit:6.6.1.202309021850-r') { + pluginLibs(libs.jgit) { exclude module: 'slf4j-api' exclude module: 'jsch' exclude module: 'commons-logging' } - pluginLibs ("org.eclipse.jgit:org.eclipse.jgit.ssh.jsch:5.13.2.202306221912-r"){ + pluginLibs(libs.jgitSsh) { exclude module: 'slf4j-api' exclude group: 'org.bouncycastle' } - testImplementation "org.codehaus.groovy:groovy-all:3.0.9" - testImplementation "org.spockframework:spock-core:2.0-groovy-3.0" - testImplementation "cglib:cglib-nodep:2.2.2" - testImplementation 'org.objenesis:objenesis:1.4' + testImplementation libs.bundles.testLibs } @@ -84,3 +89,15 @@ jar { } dependsOn(copyToLib) } + +nexusPublishing { + packageGroup = 'org.rundeck-plugins' + repositories { + sonatype{ + stagingProfileId = '67d196ce5bae' + } + } +} + + +apply from: "${rootDir}/gradle/publishing.gradle" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..bfbf9c3 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,32 @@ +[versions] +# Plugins +axionRelease = "1.18.14" +# Libraries +groovy = "3.0.22" +junit = "4.13.2" +rundeckCore = "5.10.0-20250312" +slf4j = "1.7.36" +jgit = "6.6.1.202309021850-r" +jgitSsh = "5.13.3.202401111512-r" +spock = "2.0-groovy-3.0" +cglib = "3.3.0" +objenesis = "1.4" +nexusPublish = "1.3.0" + +[libraries] +groovyAll = { group = "org.codehaus.groovy", name = "groovy-all", version.ref = "groovy" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +rundeckCore = { group = "org.rundeck", name = "rundeck-core", version.ref = "rundeckCore" } +slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" } +jgit = { group = "org.eclipse.jgit", name = "org.eclipse.jgit", version.ref = "jgit" } +jgitSsh = { group = "org.eclipse.jgit", name = "org.eclipse.jgit.ssh.jsch", version.ref = "jgitSsh" } +spockCore = { group = "org.spockframework", name = "spock-core", version.ref = "spock" } +cglibNodep = { group = "cglib", name = "cglib-nodep", version.ref = "cglib" } +objenesis = { group = "org.objenesis", name = "objenesis", version.ref = "objenesis" } + +[bundles] +testLibs = ["junit", "groovyAll", "spockCore", "cglibNodep", "objenesis"] + +[plugins] +axionRelease = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionRelease" } +nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" } \ No newline at end of file diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle new file mode 100644 index 0000000..f448ba7 --- /dev/null +++ b/gradle/publishing.gradle @@ -0,0 +1,70 @@ +/** + * Define project extension values in the project gradle file before including this file: + * + * publishName = 'Name of Package' + * publishDescription = 'description' (optional) + * githubSlug = Github slug e.g. 'rundeck/rundeck-cli' + * developers = [ [id:'id', name:'name', email: 'email' ] ] list of developers + * + * Define project properties to sign and publish when invoking publish task: + * + * ./gradlew \ + * -PsigningKey="base64 encoded gpg key" \ + * -PsigningPassword="password for key" \ + * -PsonatypeUsername="sonatype token user" \ + * -PsonatypePassword="sonatype token password" \ + * publishToSonatype closeAndReleaseSonatypeStagingRepository + */ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +publishing { + publications { + "${project.name}"(MavenPublication) { publication -> + from components.java + + pom { + name = publishName + description = project.ext.hasProperty('publishDescription') ? project.ext.publishDescription : + project.description ?: publishName + url = "https://github.com/${githubSlug}" + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution = 'repo' + } + } + scm { + url = "https://github.com/${githubSlug}" + connection = "scm:git:git@github.com/${githubSlug}.git" + developerConnection = "scm:git:git@github.com:${githubSlug}.git" + } + if (project.ext.hasProperty('developers')) { + developers { + project.ext.developers.each { dev -> + developer { + id = dev.id + name = dev.name + email = dev.email + } + } + } + } + } + + } + } +} +def base64Decode = { String prop -> + project.findProperty(prop) ? + new String(Base64.getDecoder().decode(project.findProperty(prop).toString())).trim() : + null +} + +if (project.hasProperty('signingKey') && project.hasProperty('signingPassword')) { + signing { + useInMemoryPgpKeys(base64Decode("signingKey"), project.signingPassword) + sign(publishing.publications) + } +} \ No newline at end of file From ec113f58dfc845a19f29108f6b04daf844987ee0 Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Wed, 2 Apr 2025 18:40:50 -0300 Subject: [PATCH 2/6] clean GA build --- .github/workflows/gradle.yml | 63 +++++++++--------------------------- 1 file changed, 15 insertions(+), 48 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8a7f3b3..db09ca6 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,68 +1,35 @@ name: Java CI -on: - push: - branches: - - master - pull_request: - branches: - - master +on: [push] jobs: build: + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Get Fetch Tags - if: ${{ !startsWith(github.ref, 'refs/tags') }} - run: git fetch --tags --force - + run: git -c protocol.version=2 fetch --tags --progress --no-recurse-submodules origin + if: "!contains(github.ref, 'refs/tags')" - name: Set up JDK 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '11' - distribution: 'temurin' - - - name: Cache Gradle and Assets - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - .gradle - build/assets - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '.gradle/dependency-locks/*') }} - restore-keys: | - ${{ runner.os }}-gradle- - + distribution: 'zulu' - name: Grant execute permission for gradlew run: chmod +x gradlew - - - name: Build Plugin - run: | - ./gradlew clean build --info - env: - GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2" - + - name: Build with Gradle + run: ./gradlew build - name: Get Release Version id: get_version - run: | - VERSION=$(./gradlew currentVersion -q -Prelease.quiet | tail -n 1) - echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - echo "Detected version: ${VERSION}" - - - name: Show build contents - run: | - echo "Build directory contents:" - find build/ -ls - - - name: Upload Plugin Artifact + run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION + - name: Upload git-plugin jar uses: actions/upload-artifact@v4 with: - name: git-plugin-${{ steps.get_version.outputs.VERSION }} - path: | - build/libs/git-plugin-${{ steps.get_version.outputs.VERSION }}.jar - if-no-files-found: error \ No newline at end of file + # Artifact name + name: Grails-Plugin-${{ steps.get_version.outputs.VERSION }} + # Directory containing files to upload + path: build/libs/git-plugin-${{ steps.get_version.outputs.VERSION }}.jar From 3113e8e5cd0f4b93667c06088b50534516e52b8f Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Wed, 2 Apr 2025 18:56:43 -0300 Subject: [PATCH 3/6] version doesn't start with 'v' --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ceb830d..ae4772c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ on: push: # Sequence of patterns matched against refs/tags tags: - - 'v[0-9]+.[0-9]+.[0-9]+' # Push events to matching v*, i.e. v1.0, v20.15.10 + - '[0-9]+.[0-9]+.[0-9]+' # Push events to matching v*, i.e. v1.0, v20.15.10 name: Upload Release Asset From 2e855c795c236c285cbb2ed2239b949b8b33eb3c Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Tue, 8 Apr 2025 13:31:57 -0400 Subject: [PATCH 4/6] fix comments --- .github/workflows/gradle.yml | 2 +- build.gradle | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index db09ca6..5255bef 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -25,7 +25,7 @@ jobs: run: ./gradlew build - name: Get Release Version id: get_version - run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION + run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - name: Upload git-plugin jar uses: actions/upload-artifact@v4 with: diff --git a/build.gradle b/build.gradle index 4be4d0f..04eb900 100644 --- a/build.gradle +++ b/build.gradle @@ -12,10 +12,16 @@ ext.githubSlug = 'rundeck-plugins/git-plugin' ext.pluginClassNames='com.rundeck.plugin.GitResourceModelFactory,com.rundeck.plugin.GitCloneWorkflowStep,com.rundeck.plugin.GitPushWorkflowStep,com.rundeck.plugin.GitCommitWorkflowStep,com.rundeck.plugin.GitAddWorkflowStep' ext.pluginName = 'Git Plugin' ext.pluginDescription = 'This is a git plugin (based on Jgit) which contain a Resource model and worflow steps' +ext.developers = [ + [id: 'ltamaster', name: 'Luis Toledo', email: 'luis@variacode.com'] +] + java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 + withJavadocJar() + withSourcesJar() } scmVersion { @@ -93,11 +99,12 @@ jar { nexusPublishing { packageGroup = 'org.rundeck-plugins' repositories { - sonatype{ - stagingProfileId = '67d196ce5bae' - } + sonatype() } } +test { + useJUnitPlatform() +} apply from: "${rootDir}/gradle/publishing.gradle" From c88f9dff97780989bd0d3a14e56c9048835806ff Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Tue, 8 Apr 2025 14:36:55 -0400 Subject: [PATCH 5/6] fix package group --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 04eb900..74c796c 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ jar { } nexusPublishing { - packageGroup = 'org.rundeck-plugins' + packageGroup = 'org.rundeck.plugins' repositories { sonatype() } From f85c271bfcc805bd04a2de998814b2bc3590ffbe Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Tue, 8 Apr 2025 15:49:29 -0400 Subject: [PATCH 6/6] add snapshot release --- .github/workflows/snapshot-release.yml | 36 ++++++++++++++++++++++++++ build.gradle | 1 + gradle/libs.versions.toml | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/snapshot-release.yml diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml new file mode 100644 index 0000000..88a7fba --- /dev/null +++ b/.github/workflows/snapshot-release.yml @@ -0,0 +1,36 @@ +on: + push: + branches: + - master # Trigger on commits to the master branch + tags-ignore: + - '*' # Exclude all pushes that are tags + +name: Snapshot Release + +jobs: + build: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'zulu' + - name: Build with Gradle + run: ./gradlew build + - name: Get Release Version + id: get_version + run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + - name: Publish to Maven Central + run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SIGNING_KEY_B64: ${{ secrets.SIGNING_KEY_B64 }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} diff --git a/build.gradle b/build.gradle index 74c796c..0a4049f 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ scmVersion { prefix = '' versionSeparator = '' } + versionCreator("simple") } project.version = scmVersion.version diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bfbf9c3..387fdd8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] # Plugins -axionRelease = "1.18.14" +axionRelease = "1.18.18" # Libraries groovy = "3.0.22" junit = "4.13.2"