diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9b2d7bf --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: +- package-ecosystem: gradle + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + target-branch: main + labels: + - "type: dependency upgrade" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..c049edc --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,37 @@ +name-template: $NEXT_PATCH_VERSION +tag-template: v$NEXT_PATCH_VERSION +version-resolver: + major: + labels: + - 'type: major' + minor: + labels: + - 'type: minor' + patch: + labels: + - 'type: patch' + default: patch +categories: + - title: 🚀 Features + labels: + - "type: enhancement" + - "type: new feature" + - "type: major" + - title: 🚀 Bug Fixes/Improvements + labels: + - "type: improvement" + - "type: bug" + - "type: minor" + - title: 🛠 Dependency upgrades + labels: + - "type: dependency upgrade" + - "dependencies" +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +template: | + ## Changes + + $CHANGES + + ## Contributors + + $CONTRIBUTORS diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..6757df9 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,41 @@ +name: Java CI +on: + push: + branches: + - 2.0.x + - main + pull_request: + branches: + - 2.0.x + - main +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java: ['8'] + env: + WORKSPACE: ${{ github.workspace }} + GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8 + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Run Assemble + if: success() && github.event_name == 'push' && matrix.java == '8' + run: ./gradlew assemble + - name: Publish to repo.grails.org + if: success() && github.event_name == 'push' && matrix.java == '8' + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: | + ./gradlew publish diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml new file mode 100644 index 0000000..f762177 --- /dev/null +++ b/.github/workflows/release-notes.yml @@ -0,0 +1,46 @@ +name: Changelog +on: + issues: + types: [closed,reopened] + push: + branches: + - main + workflow_dispatch: +jobs: + release_notes: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check if it has release drafter config file + id: check_release_drafter + run: | + has_release_drafter=$([ -f .github/release-drafter.yml ] && echo "true" || echo "false") + echo ::set-output name=has_release_drafter::${has_release_drafter} + + # If it has release drafter: + - uses: release-drafter/release-drafter@v5.15.0 + if: steps.check_release_drafter.outputs.has_release_drafter == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + prerelease: false + commitish: main + # Otherwise: + - name: Export Gradle Properties + if: steps.check_release_drafter.outputs.has_release_drafter == 'false' + uses: micronaut-projects/github-actions/export-gradle-properties@master + - uses: micronaut-projects/github-actions/release-notes@master + if: steps.check_release_drafter.outputs.has_release_drafter == 'false' + id: release_notes + with: + token: ${{ secrets.GH_TOKEN }} + - uses: ncipollo/release-action@v1 + if: steps.check_release_drafter.outputs.has_release_drafter == 'false' && steps.release_notes.outputs.generated_changelog == 'true' + with: + allowUpdates: true + commit: ${{ steps.release_notes.outputs.current_branch }} + draft: true + name: ${{ env.title }} ${{ steps.release_notes.outputs.next_version }} + tag: v${{ steps.release_notes.outputs.next_version }} + bodyFile: CHANGELOG.md + token: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..53d68bc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: Release +on: + release: + types: [published] +jobs: + release: + runs-on: ubuntu-latest + strategy: + matrix: + java: ['8'] + env: + GIT_USER_NAME: puneetbehl + GIT_USER_EMAIL: behlp@objectcomputing.com + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + token: ${{ secrets.GH_TOKEN }} + - uses: gradle/wrapper-validation-action@v1 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Extract Target Branch + id: extract_branch + run: | + echo "Determining Target Branch" + TARGET_BRANCH=`cat $GITHUB_EVENT_PATH | jq '.release.target_commitish' | sed -e 's/^"\(.*\)"$/\1/g'` + echo $TARGET_BRANCH + echo ::set-output name=value::${TARGET_BRANCH} + - name: Set the current release version + id: release_version + run: echo ::set-output name=release_version::${GITHUB_REF:11} + - name: Run pre-release + uses: micronaut-projects/github-actions/pre-release@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to Sonatype OSSRH + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} + SECRING_FILE: ${{ secrets.SECRING_FILE }} + run: | + echo $SECRING_FILE | base64 -d > secring.gpg + echo "Publishing Artifacts" + (set -x; ./gradlew -Psigning.secretKeyRingFile="${GITHUB_WORKSPACE}/secring.gpg" publishToSonatype closeAndReleaseSonatypeStagingRepository --no-daemon) + (set -x; ./gradlew assemble --no-daemon) + - name: Export Gradle Properties + uses: micronaut-projects/github-actions/export-gradle-properties@master + - name: Publish to Github Pages + if: success() + uses: micronaut-projects/github-pages-deploy-action@master + env: + BETA: ${{ contains(steps.release_version.outputs.release_version, 'M') || contains(steps.release_version.outputs.release_version, 'RC') }} + TARGET_REPOSITORY: ${{ github.repository }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + BRANCH: gh-pages + FOLDER: build/docs + DOC_FOLDER: gh-pages + COMMIT_EMAIL: behlp@objectcomputing.com + COMMIT_NAME: Puneet Behl + VERSION: ${{ steps.release_version.outputs.release_version }} + - name: Run post-release + if: success() + uses: micronaut-projects/github-actions/post-release@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + env: + SNAPSHOT_SUFFIX: -SNAPSHOT diff --git a/.travis.yml b/.travis.yml index 52f8e26..dabc55a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ sudo: false +branches: + only: + - 1.0.x cache: directories: - $HOME/.gradle diff --git a/publishing/bintrayPublishing.gradle b/publishing/bintrayPublishing.gradle deleted file mode 100644 index d736a41..0000000 --- a/publishing/bintrayPublishing.gradle +++ /dev/null @@ -1,30 +0,0 @@ -bintray { - user = System.getenv("BINTRAY_USER") ?: project.hasProperty("bintrayUser") ? project.bintrayUser : '' - key = System.getenv("BINTRAY_KEY") ?: project.hasProperty("bintrayKey") ? project.bintrayKey : '' - publications = ['maven'] - publish = true - pkg { - repo = project.hasProperty('repo') ? project.repo : 'plugins' - userOrg = project.hasProperty('userOrg') ? project.userOrg : 'grails' - name = "$project.name" - desc = project.hasProperty('desc') ? project.desc : "Grails $project.name plugin" - websiteUrl = project.hasProperty('websiteUrl') ? project.websiteUrl : "https://grails.org/plugin/$project.name" - issueTrackerUrl = project.hasProperty('issueTrackerUrl') ? project.issueTrackerUrl : "https://github.com/grails3-plugins/$project.name/issues" - vcsUrl = project.hasProperty('vcsUrl') ? project.vcsUrl : "https://github.com/grails3-plugins/$project.name" - licenses = project.hasProperty('license') ? [project.license] : ['Apache-2.0'] - publicDownloadNumbers = true - version { - attributes = ['grails-plugin': "$project.group:$project.name"] - name = project.version - gpg { - sign = false - passphrase = System.getenv("SIGNING_PASSPHRASE") ?: project.hasProperty("signingPassphrase") ? project.signingPassphrase : '' - } - mavenCentralSync { - sync = false - user = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : '' - password = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : '' - } - } - } -} diff --git a/publishing/grailsCentralPublishing.gradle b/publishing/grailsCentralPublishing.gradle index cac1a98..70e8b1a 100644 --- a/publishing/grailsCentralPublishing.gradle +++ b/publishing/grailsCentralPublishing.gradle @@ -2,9 +2,10 @@ publishing { publications { maven(MavenPublication) { pom.withXml { - def pomNode = asNode() + def xml = asNode() + xml.children().last() + pomInfo try { - pomNode.dependencyManagement.replaceNode {} + xml.dependencyManagement.replaceNode {} } catch (Throwable e) { // ignore } @@ -12,7 +13,7 @@ publishing { // simply remove dependencies without a version // version-less dependencies are handled with dependencyManagement // see https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/8 for more complete solutions - pomNode.dependencies.dependency.findAll { + xml.dependencies.dependency.findAll { it.version.text().isEmpty() }.each { try { @@ -30,24 +31,18 @@ publishing { } repositories { - maven { - credentials { - username System.getenv('GRAILS_CENTRAL_USERNAME') ?: project.properties.get('grailsPluginsUsername') - password System.getenv("GRAILS_CENTRAL_PASSWORD") ?: project.properties.get('grailsPluginsPassword') - } - - if(group == 'org.grails.plugins') { - if(version.endsWith('-SNAPSHOT')) { - url "https://repo.grails.org/grails/plugins3-snapshots-local" - } - } - else { - if(version.endsWith('-SNAPSHOT')) { - url "https://repo.grails.org/grails/libs-snapshots-local" + if (isSnapshot) { + maven { + credentials { + def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : '' + def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : '' + username = u + password = p } + url "https://repo.grails.org/grails/libs-snapshots-local" } } } } -task install(dependsOn: project.tasks.withType(PublishToMavenLocal)) \ No newline at end of file +task install(dependsOn: project.tasks.withType(PublishToMavenLocal)) diff --git a/wrapper/build.gradle b/wrapper/build.gradle index 06b264c..ac79caa 100644 --- a/wrapper/build.gradle +++ b/wrapper/build.gradle @@ -3,9 +3,10 @@ buildscript { grailsVersion = project.grailsVersion } repositories { - mavenLocal() + mavenCentral() maven { url "https://repo.grails.org/grails/core" } - if(groovyVersion.endsWith('-SNAPSHOT')) { + maven { url "https://plugins.gradle.org/m2/" } + if (groovyVersion.endsWith('-SNAPSHOT')) { maven { name 'JFrog OSS snapshot repo' url 'https://oss.jfrog.org/oss-snapshot-local/' @@ -13,23 +14,68 @@ buildscript { } } dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsVersion" + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVerison" + classpath 'io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE' + classpath "io.github.gradle-nexus:publish-plugin:1.1.0" + classpath "com.bmuschko:gradle-nexus-plugin:2.3.1" } } -plugins { - id "io.spring.dependency-management" version "0.5.2.RELEASE" - id "com.jfrog.bintray" version "1.2" -} - group 'org.grails' version '3.0.0.BUILD-SNAPSHOT' +ext.isSnapshot = version.endsWith("-SNAPSHOT") +ext.isReleaseVersion = !ext.isSnapshot +ext."signing.keyId" = System.getenv("SIGNING_KEY") ?: project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : null +ext."signing.password" = System.getenv("SIGNING_PASSPHRASE") ?: project.hasProperty("signing.password") ? project.getProperty('signing.password') : null +ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : null + +ext.pomInfo = { + delegate.name 'Grails 5 Wrapper' + delegate.description 'The Grails Wrapper Project' + delegate.url 'https://github.com/grails/grails-wrapper' + + delegate.licenses { + delegate.license { + delegate.name 'The Apache Software License, Version 2.0' + delegate.url 'https://www.apache.org/licenses/LICENSE-2.0.txt' + delegate.distribution 'repo' + } + } + + delegate.scm { + delegate.url "scm:git@github.com:grails/grails-wrapper.git" + delegate.connection "scm:git@github.com:grails/grails-wrapper.git" + delegate.developerConnection "scm:git@github.com:grails/grails-wrapper.git" + } + + delegate.developers { + delegate.developer { + delegate.id 'graemerocher' + delegate.name 'Graeme Rocher' + } + delegate.developer { + delegate.id 'jeffscottbrown' + delegate.name 'Jeff Brown' + } + delegate.developer { + delegate.id 'puneetbehl' + delegate.name 'Puneet Behl' + } + } +} + apply plugin: 'groovy' -apply plugin: 'maven-publish' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'provided-base' +apply plugin: 'maven-publish' +apply plugin: 'signing' +apply plugin: "io.spring.dependency-management" + +if (isReleaseVersion) { + apply plugin: "io.github.gradle-nexus.publish-plugin" +} ext { grailsVersion = project.grailsVersion @@ -44,12 +90,10 @@ configurations { sourceCompatibility = 1.8 targetCompatibility = 1.8 - repositories { - mavenLocal() mavenCentral() maven { url "https://repo.grails.org/grails/core" } - if(groovyVersion.endsWith('-SNAPSHOT')) { + if (groovyVersion.endsWith('-SNAPSHOT')) { maven { name 'JFrog OSS snapshot repo' url 'https://oss.jfrog.org/oss-snapshot-local/' @@ -74,23 +118,47 @@ jar { } } -task sourcesJar(type:Jar) { +task sourcesJar(type: Jar) { archiveClassifier.set('sources') from project.sourceSets.main.allSource } -task javadocJar(type:Jar) { +task javadocJar(type: Jar) { archiveClassifier.set('javadoc') from groovydoc.outputs } tasks.withType(Groovydoc) { groovyClasspath = project.configurations.groovyDoc - includes = ["grails-wrapper/**"] + includes = ["grails-wrapper/**"] +} + +afterEvaluate { + signing { + required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } + sign publishing.publications.maven + } +} + +tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach { + shouldRunAfter(tasks.withType(Sign)) +} + +if (isReleaseVersion) { + nexusPublishing { + repositories { + sonatype { + def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : '' + def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : '' + def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : '' + username = ossUser + password = ossPass + stagingProfileId = ossStagingProfileId + } + } + } } -// Used for publishing to central repository, remove if not needed apply from:'../publishing/grailsCentralPublishing.gradle' -apply from:'../publishing/bintrayPublishing.gradle' diff --git a/wrapper/gradle.properties b/wrapper/gradle.properties index 679b562..77a08ab 100644 --- a/wrapper/gradle.properties +++ b/wrapper/gradle.properties @@ -1,3 +1,4 @@ grailsVersion=5.0.0.M1 +grailsGradlePluginVerison=5.0.0.M2 groovyVersion=3.0.5 springBootVersion=2.5.0