diff --git a/.github/workflows/build-on-pr.yml b/.github/workflows/build-on-pr.yml index db4cacd..13c0244 100644 --- a/.github/workflows/build-on-pr.yml +++ b/.github/workflows/build-on-pr.yml @@ -23,7 +23,7 @@ jobs: with: arguments: | --stacktrace - check jacocoTestReport + check jacocoTestReport -x :artifact-tests:test - name: Test publishing uses: gradle/actions/setup-gradle@v3 with: @@ -42,6 +42,36 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true + + artifact_tests: + runs-on: ubuntu-latest + env: + ENABLE_JAR_CACHING: true + concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Run artifact tests + uses: gradle/actions/setup-gradle@v3 + with: + arguments: | + --stacktrace + :artifact-tests:check + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() # always run even if the previous step fails + with: + check_name: JUnit Test Report + report_paths: '**/build/test-results/**/TEST-*.xml' + annotate_notice: false + publish-snapshot: name: Publish snapshot needs: build diff --git a/.github/workflows/build-on-push-to-main.yml b/.github/workflows/build-on-push-to-main.yml index b257dd3..341e5a7 100644 --- a/.github/workflows/build-on-push-to-main.yml +++ b/.github/workflows/build-on-push-to-main.yml @@ -4,6 +4,9 @@ on: push: branches: [ main ] +concurrency: + group: ${{ github.ref }} + jobs: build: name: Build @@ -21,7 +24,7 @@ jobs: with: arguments: | --stacktrace - check jacocoTestReport + check jacocoTestReport -x :artifact-tests:test - name: Test publishing uses: gradle/actions/setup-gradle@v3 with: @@ -40,9 +43,38 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true + + artifact_tests: + runs-on: ubuntu-latest + env: + ENABLE_JAR_CACHING: true + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Run artifact tests + uses: gradle/actions/setup-gradle@v3 + with: + arguments: | + --stacktrace + :artifact-tests:check + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() # always run even if the previous step fails + with: + check_name: JUnit Test Report + report_paths: '**/build/test-results/**/TEST-*.xml' + annotate_notice: false + trigger-release: name: Trigger release - needs: build + needs: + - build + - artifact_tests runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index fe0e7a3..2d574f6 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -5,7 +5,7 @@ on: types: [published] jobs: - release: + build: runs-on: ubuntu-latest environment: release steps: @@ -21,7 +21,7 @@ jobs: with: arguments: | --stacktrace - check + check -x :artifact-tests:test - name: Publish Test Report uses: mikepenz/action-junit-report@v4 if: always() # always run even if the previous step fails @@ -52,3 +52,67 @@ jobs: file: 'build/libs/jooq-gradle-plugin-*[0-9].*[0-9].*[0-9]{-javadoc,-sources,}.jar' file_glob: true tag: ${{ github.ref }} + + artifact_tests: + runs-on: ubuntu-latest + env: + ENABLE_JAR_CACHING: true + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Run artifact tests + uses: gradle/actions/setup-gradle@v3 + with: + arguments: | + --stacktrace + :artifact-tests:check + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() # always run even if the previous step fails + with: + check_name: JUnit Test Report + report_paths: '**/build/test-results/**/TEST-*.xml' + annotate_notice: false + + release: + needs: + - build + - artifact_tests + runs-on: ubuntu-latest + environment: release + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Publish plugin + uses: gradle/actions/setup-gradle@v3 + env: + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_withSigning: true + with: + arguments: | + -Pversion=${{ github.event.release.tag_name }} + -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} + -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} + --stacktrace + assemble publishPlugins publishToSonatype closeAndReleaseSonatypeStagingRepository + - name: Attach artifacts to the release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: 'build/libs/jooq-gradle-plugin-*[0-9].*[0-9].*[0-9]{-javadoc,-sources,}.jar' + file_glob: true + tag: ${{ github.ref }} diff --git a/artifact-tests/build.gradle.kts b/artifact-tests/build.gradle.kts index d3c03a1..d9b8bad 100644 --- a/artifact-tests/build.gradle.kts +++ b/artifact-tests/build.gradle.kts @@ -22,6 +22,16 @@ tasks { dependsOn(publishAllPublicationsToLocalBuildRepository) from(rootProject.layout.buildDirectory.dir(localRepositoryDirName)) + exclude( + "**/*.module", + "**/maven-metadata.xml", + "**/*-javadoc.jar", + "**/*-sources.jar", + "**/*.md5", + "**/*.sha1", + "**/*.sha256", + "**/*.sha512", + ) into(layout.buildDirectory.dir(localRepositoryDirName)) } diff --git a/build.gradle.kts b/build.gradle.kts index 21b8f4f..5157776 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,6 +24,13 @@ tasks { ) } + withType { + outputs.cacheIf { System.getenv("ENABLE_JAR_CACHING")?.lowercase() == "true" } + if (System.getenv("ENABLE_JAR_CACHING")?.lowercase() == "true") { + outputs.doNotCacheIfSpecs.clear() + } + } + assemble { dependsOn(shadowJar) }