diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e62aad5..878aa13 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,10 +14,10 @@ jobs: - name: Get Fetch Tags run: git -c protocol.version=2 fetch --tags --progress --no-recurse-submodules origin if: "!contains(github.ref, 'refs/tags')" - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: - java-version: '11' + java-version: '17' distribution: 'zulu' - name: Grant execute permission for gradlew run: chmod +x gradlew @@ -25,9 +25,9 @@ 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 openssh-node-execution zip - uses: actions/upload-artifact@v4.0.0 + uses: actions/upload-artifact@v4 with: # Artifact name name: openssh-node-execution-${{ steps.get_version.outputs.VERSION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e27e86..4d07d53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,24 +1,23 @@ on: push: - # Sequence of patterns matched against refs/tags tags: - - '*' # Push events to matching v*, i.e. v1.0, v20.15.10 + - '*.*.*' -name: Create Release +name: Publish Release jobs: build: - name: Upload Release Asset + name: Publish Release runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: - java-version: '11' + java-version: '17' distribution: 'zulu' - name: Build with Gradle run: ./gradlew build @@ -26,7 +25,6 @@ jobs: id: get_version run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - name: Create Release - id: create_release run: | gh release create \ --generate-notes \ @@ -35,13 +33,10 @@ jobs: build/libs/openssh-node-execution-${{ steps.get_version.outputs.VERSION }}.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload Plugin (zip) - id: upload-release-asset - uses: actions/upload-release-asset@v1 + - name: Publish to Maven Central + run: ./gradlew -PsigningKey=${SIGNING_KEY_B64} -PsigningPassword=${SIGNING_PASSWORD} -PsonatypeUsername=${SONATYPE_USERNAME} -PsonatypePassword=${SONATYPE_PASSWORD} publishToSonatype closeAndReleaseSonatypeStagingRepository env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./build/libs/openssh-node-execution-${{ steps.get_version.outputs.VERSION }}.zip - asset_name: openssh-node-execution-${{ steps.get_version.outputs.VERSION }}.zip - asset_content_type: application/zip \ No newline at end of file + 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/.gitignore b/.gitignore index 5f66397..bdfa041 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ gradle-app.setting # gradle/wrapper/gradle-wrapper.properties # End of https://www.gitignore.io/api/java,gradle + +# Local build logs +.temp diff --git a/build.gradle b/build.gradle index 61cbc6a..164d9b1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,11 +5,37 @@ buildscript { mavenCentral() } } + plugins { - id 'pl.allegro.tech.build.axion-release' version '1.18.18' id 'java' + id 'pl.allegro.tech.build.axion-release' version '1.17.2' + id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' +} + +repositories { + mavenLocal() + maven { + name = 'Central Portal Snapshots' + url = 'https://central.sonatype.com/repository/maven-snapshots/' + content { + includeGroup('org.rundeck') + } + } + mavenCentral() +} + +group = 'org.rundeck.plugins' + +scmVersion { + ignoreUncommittedChanges = false + tag { + prefix = '' // NO "v" prefix - see PLUGIN_TAGGING_ARCHITECTURE.md + versionSeparator = '' + } } +version = scmVersion.version // Dynamic version from git tag + ext.pluginName = 'Openssh node execution services' ext.publishName = "Openssh node execution services ${project.version}" ext.publishDescription = project.description ?: 'Openssh node execution services' @@ -24,21 +50,11 @@ ext.developers = [ [id: 'gschueler', name: 'Greg Schueler', email: 'greg@rundeck.com'] ] -scmVersion { - ignoreUncommittedChanges = true - tag { - prefix = '' - versionSeparator = '' - } - versionCreator("simple") -} - -project.version = scmVersion.version -ext.archiveFilename = ext.archivesBaseName + '-' + version +ext.archiveFilename = ext.archivesBaseName + '-' + project.version.toString() java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } defaultTasks 'build' @@ -48,13 +64,13 @@ tasks.register('pluginZip', Jar) { archiveVersion.set(project.version) archiveClassifier.set('') destinationDirectory.set(file("build/libs")) - extension = 'zip' + archiveExtension.set('zip') from("${project.buildDir}/zip-contents") { include("*.yaml") include("resources/**") include("contents/*") - into("${archiveBaseName.get()}-${archiveVersion.get()}") + into("${archiveBaseName.get()}-" + project.version.toString()) } manifest { @@ -62,7 +78,7 @@ tasks.register('pluginZip', Jar) { 'Rundeck-Plugin-Name': pluginName.toString(), 'Rundeck-Plugin-Description': pluginDescription.toString(), 'Rundeck-Plugin-Archive': 'true', - 'Rundeck-Plugin-File-Version': version, + 'Rundeck-Plugin-File-Version': project.version.toString(), 'Rundeck-Plugin-Author': sopsCopyright, 'Rundeck-Plugin-URL': sopsUrl, 'Rundeck-Plugin-Date': buildDateString @@ -74,7 +90,7 @@ tasks.named('pluginZip').configure { doFirst { def assetsMap = new Properties() def tokens = assetsMap + [ - version : version, + version : project.version.toString(), date : new Date().format("yyyy-MM-dd'T'HH:mm:ssX").toString(), author : sopsCopyright, url : sopsUrl, @@ -100,18 +116,20 @@ tasks.named('pluginZip').configure { } } -apply plugin: 'maven-publish' - -publishing { - publications { - mavenZip(MavenPublication) { - artifact tasks.named('pluginZip').get() +nexusPublishing { + packageGroup = 'org.rundeck.plugins' + repositories { + sonatype { + nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) + snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) } } } +apply from: "${rootDir}/gradle/publishing.gradle" + defaultTasks 'clean', 'build', 'pluginZip' tasks.named('build').configure { dependsOn tasks.named('pluginZip') -} \ No newline at end of file +} diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 5dddfcf..a100a4f 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -1,12 +1,9 @@ /** - * Define project extension values in the project gradle file before including this file: + * Zip-based Rundeck plugin publication for Maven Central (artifact uploaded as type jar). * - * 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: + * Requires before this file: + * - ext.publishName, ext.githubSlug, ext.developers + * - task pluginZip * * ./gradlew \ * -PsigningKey="base64 encoded gpg key" \ @@ -20,10 +17,17 @@ apply plugin: 'signing' publishing { publications { - "${project.name}"(MavenPublication) { publication -> - from components.java + mavenZip(MavenPublication) { + groupId = project.group.toString() + artifactId = 'openssh-node-execution' + version = project.version.toString() + + artifact(tasks.named('pluginZip')) { + extension = 'jar' + } pom { + packaging = 'jar' name = publishName description = project.ext.hasProperty('publishDescription') ? project.ext.publishDescription : project.description ?: publishName @@ -52,10 +56,26 @@ publishing { } } } - + } + } + repositories { + def pkgcldWriteToken = System.getenv("PKGCLD_WRITE_TOKEN") ?: project.findProperty("pkgcldWriteToken") + if (pkgcldWriteToken) { + maven { + name = "PackageCloudTest" + url = uri("https://packagecloud.io/pagerduty/rundeckpro-test/maven2") + authentication { + header(HttpHeaderAuthentication) + } + credentials(HttpHeaderCredentials) { + name = "Authorization" + value = "Bearer " + pkgcldWriteToken + } + } } } } + def base64Decode = { String prop -> project.findProperty(prop) ? new String(Base64.getDecoder().decode(project.findProperty(prop).toString())).trim() : diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a2..3ae1e2f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists