diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 0f52544..d0f5012 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,4 +1,4 @@ -name: Java CI +name: "Java CI" on: push: branches: @@ -11,64 +11,60 @@ env: GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} jobs: - test_project: - name: Test Project + name: "Test Project" if: github.event_name == 'pull_request' runs-on: ubuntu-latest strategy: fail-fast: true matrix: - java: [17] - + java: [17, 21] steps: - - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v2 - - uses: actions/setup-java@v4 + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" + uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: ${{ matrix.java }} - - uses: gradle/actions/setup-gradle@v3 - - name: Run tests - env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + - name: "🏃 Run tests" run: ./gradlew check - publish_snapshot: - name: Build Project and Publish Snapshot release + name: "Build Project and Publish Snapshot release" runs-on: ubuntu-latest if: github.event_name == 'push' - steps: - - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v2 - - uses: actions/setup-java@v4 - with: { java-version: 17, distribution: temurin } - - uses: gradle/actions/setup-gradle@v3 - - - name: Build Project - env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: { + java-version: 17, + distribution: liberica + } + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + - name: "🔨 Build Project" run: ./gradlew build - - - name: Publish Snapshot version to Artifactory (repo.grails.org) + - name: "📤 Publish Snapshot version to Artifactory (repo.grails.org)" if: success() env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} ORG_GRADLE_PROJECT_artifactoryPublishUsername: ${{ secrets.ARTIFACTORY_USERNAME }} ORG_GRADLE_PROJECT_artifactoryPublishPassword: ${{ secrets.ARTIFACTORY_PASSWORD }} run: > ./gradlew -Dorg.gradle.internal.publish.checksums.insecure=true publish - - - name: Generate Snapshot Documentation + - name: "📖 Generate Snapshot Documentation" if: success() - env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} run: ./gradlew docs - - - name: Publish Snapshot Documentation to Github Pages + - name: "📤 Publish Snapshot Documentation to Github Pages" if: success() uses: micronaut-projects/github-pages-deploy-action@grails env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e174167..2e452ea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,56 +1,51 @@ -name: Release +name: "Release" on: release: types: [published] env: GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} - jobs: release: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v2 - - uses: actions/setup-java@v4 - with: { java-version: 11, distribution: temurin } - - uses: gradle/actions/setup-gradle@v3 - - - name: Get the current release version + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: 17 + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + - name: "📝 Store the current release version" id: release_version run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT - - - name: Run pre-release + - name: "⚙ Run pre-release" uses: micronaut-projects/github-actions/pre-release@master - - - name: Generate secring file + - name: "🔐 Generate key file for artifact signing" env: SECRING_FILE: ${{ secrets.SECRING_FILE }} run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg - - - name: Publish artifacts to Sonatype + - name: "📤 Publish artifacts to Sonatype" id: publish_to_sonatype env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} ORG_GRADLE_PROJECT_sonatypeStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY_ID }} SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} run: > ./gradlew -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository - - - name: Generate Documentation + - name: "📖 Generate Documentation" if: success() - env: - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} run: ./gradlew docs - - - name: Publish Documentation to Github Pages + - name: "📤 Publish Documentation to Github Pages" if: success() uses: micronaut-projects/github-pages-deploy-action@grails env: @@ -60,7 +55,8 @@ jobs: FOLDER: build/docs/manual GH_TOKEN: ${{ secrets.GH_TOKEN }} VERSION: ${{ steps.release_version.outputs.release_version }} - - - name: Run post-release + - name: "⚙️ Run post-release" if: steps.publish_to_sonatype.outcome == 'success' - uses: micronaut-projects/github-actions/post-release@master \ No newline at end of file + uses: micronaut-projects/github-actions/post-release@master + with: + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index df06f69..55761e5 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -6,7 +6,7 @@ ext.set('signing.password', findProperty('signing.password') ?: System.getenv('S def javaComponent = components.named('java') publishing { publications { - register('grailsMailPlugin', MavenPublication) { + maven(MavenPublication) { from javaComponent.get() versionMapping { usage('java-api') { fromResolutionOf('runtimeClasspath') } @@ -91,14 +91,13 @@ publishing { } } -def mavenPublication = extensions.findByType(PublishingExtension).publications.named('grailsMailPlugin') tasks.withType(Sign).configureEach { onlyIf { isReleaseVersion } } afterEvaluate { signing { - required = { isReleaseVersion } - sign(mavenPublication.get()) + required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') } + sign(publishing.publications.maven) } } diff --git a/settings.gradle b/settings.gradle index 9916886..8d5c5a3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,23 +1,25 @@ plugins { - id 'com.gradle.develocity' version '3.17.1' - id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0' + id 'com.gradle.develocity' version '3.18.1' + id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2' } -def isCI = System.getenv('CI') == 'true' +def isCI = System.getenv('CI') != null +def isLocal = !isCI +def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null develocity { server = 'https://ge.grails.org' buildScan { - publishing.onlyIf { isCI } - uploadInBackground = !isCI + publishing.onlyIf { isAuthenticated } + uploadInBackground = isLocal } } buildCache { - local { enabled = !isCI } + local { enabled = isLocal } remote(develocity.buildCache) { + push = isCI && isAuthenticated enabled = true - push = isCI && System.getenv('DEVELOCITY_ACCESS_KEY') } }