From aacfdfe8b42f31bf2e8a985453105842879f0a5e Mon Sep 17 00:00:00 2001 From: Goooler Date: Sat, 20 Jan 2024 16:01:44 +0800 Subject: [PATCH 1/8] Use gradle-build-action --- .github/workflows/build-and-check.yml | 61 +++------------------------ .github/workflows/new-release.yml | 15 +------ 2 files changed, 8 insertions(+), 68 deletions(-) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index e4afc5eb..e0b3807f 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -40,36 +40,9 @@ jobs: with: java-version: ${{ matrix.java_version }} distribution: 'zulu' - - name: Restore Gradle caches - uses: actions/cache@v2 + - uses: gradle/gradle-build-action@v2 with: - path: | - ~/.gradle/caches/modules-2 - ~/.gradle/caches/files-2.1 - ~/.gradle/caches/metadata-2.96 - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} - restore-keys: | - ${{ runner.os }}-gradle-cache- - # Inspired by https://github.com/actions/cache/issues/432#issuecomment-740376179 - - name: Restore TestKit cache - uses: actions/cache@v2 - with: - path: | - plugin/.gradle-test-kit/caches/modules-2 - plugin/.gradle-test-kit/caches/files-2.1 - plugin/.gradle-test-kit/caches/metadata-2.96 - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}- - ${{ runner.os }}-gradle-wrapper- - - name: Restore Gradle wrapper - uses: actions/cache@v2 - with: - path: | - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} - restore-keys: | - ${{ runner.os }}-gradle-wrapper- + gradle-home-cache-cleanup: true - name: Build plugin run: ./plugin/gradlew -p ./plugin assemble ensureDependenciesAreInlined test --no-daemon - name: Upload test results @@ -109,20 +82,9 @@ jobs: run: sudo apt install -qq libdistro-info-perl - name: Install checkbashisms run: sudo apt-get install -qq devscripts - - name: Restore Gradle caches - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} - restore-keys: | - ${{ runner.os }}-gradle-cache- - - name: Restore Gradle wrapper - uses: actions/cache@v2 + - uses: gradle/gradle-build-action@v2 with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} - restore-keys: | - ${{ runner.os }}-gradle-wrapper- + gradle-home-cache-cleanup: true - name: Check git bashisms run: ./gradlew addKtlintCheckGitPreCommitHook --no-daemon && checkbashisms .git/hooks/pre-commit @@ -139,19 +101,8 @@ jobs: with: java-version: 8 distribution: 'zulu' - - name: Restore Gradle caches - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} - restore-keys: | - ${{ runner.os }}-gradle-cache- - - name: Restore Gradle wrapper - uses: actions/cache@v2 + - uses: gradle/gradle-build-action@v2 with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} - restore-keys: | - ${{ runner.os }}-gradle-wrapper- + gradle-home-cache-cleanup: true - name: Check ktlint-plugin on samples run: ./gradlew ktlintCheck --no-daemon diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index b65db229..3048f87c 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -15,20 +15,9 @@ jobs: with: java-version: 8 distribution: 'zulu' - - name: Restore Gradle caches - uses: actions/cache@v2 + - uses: gradle/gradle-build-action@v2 with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} - restore-keys: | - ${{ runner.os }}-gradle-cache- - - name: Restore Gradle wrapper - uses: actions/cache@v2 - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} - restore-keys: | - ${{ runner.os }}-gradle-wrapper- + gradle-home-cache-cleanup: true - name: Publish plugin env: GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} From fb59391386dfc77c91d2b025b323d1f33eead6cf Mon Sep 17 00:00:00 2001 From: Goooler Date: Sat, 20 Jan 2024 18:33:59 +0800 Subject: [PATCH 2/8] Reuse env variables --- .github/workflows/new-release.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index 3048f87c..72e29cd5 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -8,6 +8,10 @@ jobs: make-new-release: name: "Releasing plugin" runs-on: ubuntu-latest + env: + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} + GITHUB_KEY: ${{ secrets.GithubKey }} steps: - uses: actions/checkout@v2 - name: set up JDK 1.8 @@ -19,16 +23,8 @@ jobs: with: gradle-home-cache-cleanup: true - name: Publish plugin - env: - GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} - GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} - GITHUB_KEY: ${{ secrets.GithubKey }} run: ./plugin/gradlew -p ./plugin publishPlugins --no-daemon - name: Create new Github release - env: - GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} - GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} - GITHUB_KEY: ${{ secrets.GITHUB_TOKEN }} run: ./plugin/gradlew -p ./plugin githubRelease --no-daemon - name: Update VERSION_LATEST_RELEASE to new published version run: cp plugin/VERSION_CURRENT.txt plugin/VERSION_LATEST_RELEASE.txt From 8932a0ec0715e676d3eabeaf15bcb8d315e2926f Mon Sep 17 00:00:00 2001 From: Goooler Date: Sat, 20 Jan 2024 18:35:31 +0800 Subject: [PATCH 3/8] Disable jobs in forks --- .github/workflows/changelog.yml | 3 ++- .github/workflows/new-release.yml | 1 + .github/workflows/perform-release.yaml | 1 + .github/workflows/scorecard.yml | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index b1af0a5b..8ea2ac85 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -9,6 +9,7 @@ jobs: name: Changelog Entry Check runs-on: ubuntu-latest + if: github.repository == 'JLLeitschuh/ktlint-gradle' steps: - uses: actions/checkout@v2 @@ -18,4 +19,4 @@ jobs: run: | grep -Pz "\[(\n\s*)?#${{ github.event.pull_request.number }}(\n\s*)?\]\((\n\s*)?https://github\.com/JLLeitschuh/ktlint-gradle/pull/${{ github.event.pull_request.number }}(\n\s*)?\)" CHANGELOG.md || \ (echo "Please add '[#${{ github.event.pull_request.number }}](https://github.com/JLLeitschuh/ktlint-gradle/pull/${{ github.event.pull_request.number }})' change line to CHANGELOG.md" && \ - exit 1) \ No newline at end of file + exit 1) diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index 72e29cd5..7476a76e 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -8,6 +8,7 @@ jobs: make-new-release: name: "Releasing plugin" runs-on: ubuntu-latest + if: github.repository == 'JLLeitschuh/ktlint-gradle' env: GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} diff --git a/.github/workflows/perform-release.yaml b/.github/workflows/perform-release.yaml index 0f835880..f40d1f27 100644 --- a/.github/workflows/perform-release.yaml +++ b/.github/workflows/perform-release.yaml @@ -11,6 +11,7 @@ on: jobs: perform-release: runs-on: ubuntu-latest + if: github.repository == 'JLLeitschuh/ktlint-gradle' steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index bc6cb781..ba715874 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -21,6 +21,7 @@ jobs: analysis: name: Scorecard analysis runs-on: ubuntu-latest + if: github.repository == 'JLLeitschuh/ktlint-gradle' permissions: # Needed to upload the results to code-scanning dashboard. security-events: write From f347696fb0d2c46dcc6ae245608bf3833fee6ab0 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sat, 20 Jan 2024 18:36:11 +0800 Subject: [PATCH 4/8] Tweak validation job --- .github/workflows/gradle-wrapper-validation.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 4e68ead0..1b682420 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,5 +1,11 @@ name: "Validate Gradle Wrapper" -on: [push, pull_request] + +on: + pull_request: + paths: + - 'gradlew' + - 'gradlew.bat' + - 'gradle/wrapper/' jobs: validation: From 600aeb91a749451f1f0fab4325a538338102e56e Mon Sep 17 00:00:00 2001 From: Goooler Date: Sat, 20 Jan 2024 18:38:00 +0800 Subject: [PATCH 5/8] Reformats --- .github/workflows/build-and-check.yml | 1 + .github/workflows/changelog.yml | 3 --- .github/workflows/perform-release.yaml | 9 ++++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index e0b3807f..f3cde352 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -18,6 +18,7 @@ jobs: run: echo "The selected java versions are ${{ steps.set-matrix.outputs.version_matrix }}" outputs: version_matrix: ${{ steps.set-matrix.outputs.version_matrix }} + build: needs: build-jvm-matrix strategy: diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 8ea2ac85..90e38842 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -7,13 +7,10 @@ on: jobs: build: name: Changelog Entry Check - runs-on: ubuntu-latest if: github.repository == 'JLLeitschuh/ktlint-gradle' - steps: - uses: actions/checkout@v2 - - name: Grep CHANGES.md for PR number if: contains(github.event.pull_request.labels.*.name, 'skip news') != true run: | diff --git a/.github/workflows/perform-release.yaml b/.github/workflows/perform-release.yaml index f40d1f27..3178292e 100644 --- a/.github/workflows/perform-release.yaml +++ b/.github/workflows/perform-release.yaml @@ -2,11 +2,10 @@ name: "Perform Release" on: workflow_dispatch: inputs: - new_version: - - description: "Release Version (no 'v')" - required: true - type: string + new_version: + description: "Release Version (no 'v')" + required: true + type: string jobs: perform-release: From f6acc0d1ab7d2f72ae8d18fb7dc49c96a7daccb3 Mon Sep 17 00:00:00 2001 From: Goooler Date: Mon, 27 Dec 2021 15:00:29 +0800 Subject: [PATCH 6/8] Bump actions --- .github/workflows/build-and-check.yml | 16 ++++++++-------- .github/workflows/changelog.yml | 2 +- .github/workflows/gradle-wrapper-validation.yml | 2 +- .github/workflows/new-release.yml | 4 ++-- .github/workflows/perform-release.yaml | 2 +- .github/workflows/scorecard.yml | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index f3cde352..9ce19f1d 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -28,7 +28,7 @@ jobs: java_version: ${{ fromJson(needs.build-jvm-matrix.outputs.version_matrix) }} runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: configure windows pagefile if: ${{ matrix.os == 'windows-latest' }} uses: al-cheb/configure-pagefile-action@v1.3 @@ -37,7 +37,7 @@ jobs: maximum-size: 8GB disk-root: "D:" - name: set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java_version }} distribution: 'zulu' @@ -47,13 +47,13 @@ jobs: - name: Build plugin run: ./plugin/gradlew -p ./plugin assemble ensureDependenciesAreInlined test --no-daemon - name: Upload test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: test-results-${{ runner.os }} path: plugin/build/reports/tests/test/ - name: Upload Memory Dump - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: memory-dump-${{ runner.os }} @@ -69,9 +69,9 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: 11 distribution: 'zulu' @@ -96,9 +96,9 @@ jobs: runs-on: ${{ matrix.os }} needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: set up JDK 1.8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: 8 distribution: 'zulu' diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 90e38842..3d704247 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'JLLeitschuh/ktlint-gradle' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Grep CHANGES.md for PR number if: contains(github.event.pull_request.labels.*.name, 'skip news') != true run: | diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 1b682420..d7566c99 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -12,7 +12,7 @@ jobs: name: "Validation" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 with: min-wrapper-count: 2 diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index 7476a76e..d37b216b 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -14,9 +14,9 @@ jobs: GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} GITHUB_KEY: ${{ secrets.GithubKey }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: set up JDK 1.8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: 8 distribution: 'zulu' diff --git a/.github/workflows/perform-release.yaml b/.github/workflows/perform-release.yaml index 3178292e..5b39cabb 100644 --- a/.github/workflows/perform-release.yaml +++ b/.github/workflows/perform-release.yaml @@ -13,7 +13,7 @@ jobs: if: github.repository == 'JLLeitschuh/ktlint-gradle' steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: token: ${{ secrets.PAT }} - name: Update Changelog diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index ba715874..562f00b5 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -33,7 +33,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 + uses: actions/checkout@4 with: persist-credentials: false @@ -60,7 +60,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + uses: actions/upload-artifact@4 with: name: SARIF file path: results.sarif @@ -68,6 +68,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4 + uses: github/codeql-action/upload-sarif@3 with: sarif_file: results.sarif From 0145156ac12f814f7a45deca6a10126d6b8a93af Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 2 Feb 2024 17:06:43 +0800 Subject: [PATCH 7/8] Use gradle/actions/setup-gradle@v3 https://github.com/gradle/gradle-build-action/releases/tag/v3.0.0 --- .github/workflows/build-and-check.yml | 6 +++--- .github/workflows/new-release.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index 9ce19f1d..17fd9b36 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -41,7 +41,7 @@ jobs: with: java-version: ${{ matrix.java_version }} distribution: 'zulu' - - uses: gradle/gradle-build-action@v2 + - uses: gradle/actions/setup-gradle@v3 with: gradle-home-cache-cleanup: true - name: Build plugin @@ -83,7 +83,7 @@ jobs: run: sudo apt install -qq libdistro-info-perl - name: Install checkbashisms run: sudo apt-get install -qq devscripts - - uses: gradle/gradle-build-action@v2 + - uses: gradle/actions/setup-gradle@v3 with: gradle-home-cache-cleanup: true - name: Check git bashisms @@ -102,7 +102,7 @@ jobs: with: java-version: 8 distribution: 'zulu' - - uses: gradle/gradle-build-action@v2 + - uses: gradle/actions/setup-gradle@v3 with: gradle-home-cache-cleanup: true - name: Check ktlint-plugin on samples diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index d37b216b..8cd1facd 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -20,7 +20,7 @@ jobs: with: java-version: 8 distribution: 'zulu' - - uses: gradle/gradle-build-action@v2 + - uses: gradle/actions/setup-gradle@v3 with: gradle-home-cache-cleanup: true - name: Publish plugin From a272ca467c8900548869527b6a43da1dc6027321 Mon Sep 17 00:00:00 2001 From: Zongle Wang Date: Mon, 5 Feb 2024 10:20:17 +0800 Subject: [PATCH 8/8] Update gradle-wrapper-validation.yml --- .github/workflows/gradle-wrapper-validation.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index d7566c99..0081a809 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,11 +1,6 @@ name: "Validate Gradle Wrapper" -on: - pull_request: - paths: - - 'gradlew' - - 'gradlew.bat' - - 'gradle/wrapper/' +on: [push, pull_request] jobs: validation: