From a6849249951bb8fc02086dc2684566e4330af513 Mon Sep 17 00:00:00 2001 From: Michael Yan Date: Mon, 1 Jan 2024 23:08:57 +0800 Subject: [PATCH] Grace: setup github workflows --- .github/workflows/gradle.yml | 92 ++++++++-------- .github/workflows/groovy-joint-workflow.yml | 28 ++--- .github/workflows/release-notes.yml | 28 +---- .github/workflows/release.yml | 110 +++++++------------- 4 files changed, 101 insertions(+), 157 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e8fc141d6b..30518d60ab 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,43 +1,30 @@ -name: Java CI +name: Grace CI on: push: branches: - - master - - '[4-9]+.[0-9]+.x' - - '[3-9]+.[3-9]+.x' + - 'release/[2020-2024]+.[0-9]+.0' pull_request: branches: - - master - - '[4-9]+.[0-9]+.x' - - '[3-9]+.[3-9]+.x' + - 'release[2020-2024]+.[0-9]+.0' workflow_dispatch: jobs: build: - runs-on: ubuntu-latest + permissions: + contents: read # to fetch code (actions/checkout) + runs-on: ubuntu-22.04 strategy: matrix: - java: ['8', '11', '14'] + java: ['11', '14'] env: WORKSPACE: ${{ github.workspace }} - GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: ${{ matrix.java }} - - name: Run Tests - if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' - id: tests - uses: gradle/gradle-build-action@v2 - with: - arguments: check - env: - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - name: Run Build - if: github.event_name == 'push' id: build uses: gradle/gradle-build-action@v2 env: @@ -45,36 +32,43 @@ jobs: GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: - arguments: build - - name: Publish Test Report - if: steps.build.outcome == 'failure' || steps.tests.outcome == 'failure' - uses: scacap/action-surefire-report@v1 + arguments: build -x groovydoc -x codenarcMain -x codenarcTest -x checkstyleMain -x checkstyleTest + publish: + if: github.event_name == 'push' + needs: ["build"] + permissions: + contents: read # to fetch code (actions/checkout) + checks: write + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/checkout@v4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - report_paths: '**/build/test-results/test/TEST-*.xml' - - name: Publish to repo.grails.org + token: ${{ secrets.GITHUB_TOKEN }} + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: 11 + - name: Generate secring file + env: + SECRING_FILE: ${{ secrets.SECRING_FILE }} + run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg + - name: Publish to Sonatype OSSRH id: publish uses: gradle/gradle-build-action@v2 - if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '8' env: - ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} - ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - with: - arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish - - name: Extract branch name - if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '8' - id: extract_branch - run: echo ::set-output name=value::${GITHUB_REF:11} - - name: Create Snapshot Message for the Workflow Dispatch - if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '8' - id: dispatch_message - run: echo ::set-output name=value::{\"message\":\"New Core Snapshot $(date) - $GITHUB_SHA\"} - - name: Invoke the Java CI workflow in Grails Functional Tests - if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '8' - uses: benc-uk/workflow-dispatch@v1.1 + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_NEXUS_URL: ${{ secrets.SONATYPE_NEXUS_URL }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} + SECRING_FILE: ${{ secrets.SECRING_FILE }} with: - workflow: Java CI - repo: grails/grails3-functional-tests - ref: ${{ steps.extract_branch.outputs.value }} - token: ${{ secrets.GH_TOKEN }} - inputs: ${{ steps.dispatch_message.outputs.value }} + arguments: -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository diff --git a/.github/workflows/groovy-joint-workflow.yml b/.github/workflows/groovy-joint-workflow.yml index 5303f5d416..007df06382 100644 --- a/.github/workflows/groovy-joint-workflow.yml +++ b/.github/workflows/groovy-joint-workflow.yml @@ -13,29 +13,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: "Grails Joint Validation Build" -# GROOVY_2_5_X == Grails 4.0.x -# GROOVY_3_0_X == grails master +name: "Grace Joint Validation Build" +# GROOVY_3_0_X == Grace 2022.0.x +# GROOVY_4_0_X == Grace 2023.0.x # Groovy master branch does not map to any due to changed package names. on: push: branches: - master - - '[4-9]+.[0-9]+.x' + - '[2020-2024]+.[0-9]+.x' pull_request: branches: - master - - '[4-9]+.[0-9]+.x' + - '[2020-2024]+.[0-9]+.x' jobs: build: strategy: fail-fast: true matrix: - os: [ubuntu-18.04] + os: [ubuntu-22.04] java: [11.0.6] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v3 with: @@ -45,13 +45,13 @@ jobs: run: env # Select correct Groovy branch for this build: - - name: Checkout Groovy 3_0_X (Grails 4.1.x) + - name: Checkout Groovy 3_0_X (Grace 2022.1.x) run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_3_0_X --single-branch - if: github.ref == 'refs/heads/5.2.x' || github.base_ref == '5.2.x' || github.ref == 'refs/heads/5.1.x' || github.base_ref == '5.1.x' || github.ref == 'refs/heads/5.0.x' || github.base_ref == '5.0.x' || github.ref == 'refs/heads/master' || github.base_ref == 'master' - - name: Checkout Groovy 2_5_X (Grails 4.0.x) - run: cd .. && git clone --depth 1 https://github.com/grails/grails-core.git -b GROOVY_2_5_X --single-branch - if: github.ref == 'refs/heads/4.0.x' || github.base_ref == '4.0.x' - - name: Set CI_GROOVY_VERSION for Grails + if: github.ref == 'refs/heads/2022.2.x' || github.base_ref == '2022.2.x' || github.ref == 'refs/heads/2022.1.x' || github.base_ref == '2022.1.x' || github.ref == 'refs/heads/2022.0.x' || github.base_ref == '2022.0.x' || github.ref == 'refs/heads/master' || github.base_ref == 'master' + - name: Checkout Groovy 4_0_X (Grace 2023.0.x) + run: cd .. && git clone --depth 1 https://github.com/graceframework/grace-framework.git -b GROOVY_4_0_X --single-branch + if: github.ref == 'refs/heads/2023.0.x' || github.base_ref == '2023.0.x' + - name: Set CI_GROOVY_VERSION for Grace run: | cd ../groovy echo 'CI_GROOVY_VERSION<> $GITHUB_ENV @@ -64,6 +64,6 @@ jobs: run: cd ../groovy && ./gradlew clean install -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK --no-build-cache --no-scan --no-daemon timeout-minutes: 60 - - name: Build Grails + - name: Build Grace run: ./gradlew clean build test -x groovydoc --no-build-cache --no-scan --no-daemon timeout-minutes: 60 diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml index 7016aad03c..e4109b33ff 100644 --- a/.github/workflows/release-notes.yml +++ b/.github/workflows/release-notes.yml @@ -5,14 +5,13 @@ on: push: branches: - master - - '[4-9]+.[0-9]+.x' - - '[3-9]+.[3-9]+.x' + - '[2020-2024]+.[0-9]+.x' workflow_dispatch: jobs: release_notes: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check if it has release drafter config file id: check_release_drafter run: | @@ -25,25 +24,6 @@ jobs: - uses: release-drafter/release-drafter@v5.20.0 if: steps.check_release_drafter.outputs.has_release_drafter == 'true' env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: commitish: ${{ steps.extract_branch.outputs.value }} - # 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 index 33e54d3416..b06f58a1b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,22 +1,41 @@ -name: Release +name: Grace Release + on: - release: - types: [published] + push: + tags: + - v* + +permissions: + contents: write + jobs: - release: - runs-on: ubuntu-latest + create_draft_release: + runs-on: ubuntu-22.04 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Create draft release + run: | + gh release create \ + --repo ${{ github.repository }} \ + --title ${{ github.ref_name }} \ + --notes '' \ + --draft \ + ${{ github.ref_name }} + release_and_publish: + needs: create_draft_release + runs-on: ubuntu-22.04 strategy: matrix: - java: ['8'] + java: ['11'] env: - GIT_USER_NAME: puneetbehl - GIT_USER_EMAIL: behlp@objectcomputing.com - GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8 + GIT_USER_NAME: rainboyan + GIT_USER_EMAIL: rain@rainboyan.com steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - token: ${{ secrets.GH_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK uses: actions/setup-java@v3 @@ -32,16 +51,16 @@ jobs: 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: ./.github/actions/pre-release - with: - token: ${{ secrets.GITHUB_TOKEN }} + run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT - name: Run Assemble id: assemble uses: gradle/gradle-build-action@v2 with: arguments: assemble + env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - name: Generate secring file env: SECRING_FILE: ${{ secrets.SECRING_FILE }} @@ -51,6 +70,9 @@ jobs: if: steps.assemble.outcome == 'success' uses: gradle/gradle-build-action@v2 env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_NEXUS_URL: ${{ secrets.SONATYPE_NEXUS_URL }} @@ -60,63 +82,11 @@ jobs: SECRING_FILE: ${{ secrets.SECRING_FILE }} with: arguments: -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository - - name: Export Gradle Properties - uses: micronaut-projects/github-actions/export-gradle-properties@master - - name: Run post-release - if: steps.publish.outcome == 'success' - uses: ./.github/actions/post-release - with: - token: ${{ secrets.GITHUB_TOKEN }} - env: - SNAPSHOT_SUFFIX: -SNAPSHOT - name: Upload artifacts to the Github release id: upload_artifact if: steps.publish.outcome == 'success' - uses: Roang-zero1/github-upload-release-artifacts-action@master - with: - args: build/distributions/grails-${{ steps.release_version.outputs.release_version }}.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Message for the Grails Documentation Release - if: steps.publish.outcome == 'success' - id: grails_docs_release_message run: | - echo ::set-output name=value::{\"grails_version\":\"$RELEASE_VERSION\"} - env: - RELEASE_VERSION: ${{ steps.release_version.outputs.release_version }} - - name: Invoke grails-doc release workflow - if: steps.publish.outcome == 'success' - id: grails_doc - uses: benc-uk/workflow-dispatch@v1.1 - with: - workflow: Release - repo: grails/grails-doc - ref: ${{ steps.extract_branch.outputs.value }} - token: ${{ secrets.GH_TOKEN }} - inputs: ${{ steps.grails_docs_release_message.outputs.value }} - - name: Invoke grails-static-website release workflow - if: steps.publish.outcome == 'success' - id: grails_static_website - uses: benc-uk/workflow-dispatch@v1.1 - with: - workflow: Release - repo: grails/grails-static-website - ref: master - token: ${{ secrets.GH_TOKEN }} - inputs: ${{ steps.grails_docs_release_message.outputs.value }} - - name: Grails SDK Minor Release - if: steps.upload_artifact.outcome == 'success' && contains(steps.release_version.outputs.release_version, 'M') || contains(steps.release_version.outputs.release_version, 'RC') - uses: gradle/gradle-build-action@v2 - with: - arguments: sdkMinorRelease - env: - GVM_SDKVENDOR_KEY: ${{ secrets.GVM_SDKVENDOR_KEY }} - GVM_SDKVENDOR_TOKEN: ${{ secrets.GVM_SDKVENDOR_TOKEN }} - - name: Grails SDK Major Release - if: steps.upload_artifact.outcome == 'success' && !contains(steps.release_version.outputs.release_version, 'M') && !contains(steps.release_version.outputs.release_version, 'RC') - uses: gradle/gradle-build-action@v2 - with: - arguments: sdkMajorRelease - env: - GVM_SDKVENDOR_KEY: ${{ secrets.GVM_SDKVENDOR_KEY }} - GVM_SDKVENDOR_TOKEN: ${{ secrets.GVM_SDKVENDOR_TOKEN }} + gh release upload --clobber "${{ github.ref_name }}" \ + build/distributions/grace-${{ steps.release_version.outputs.release_version }}.zip