From 6d75a6c35c80a39994409a5c1df21aeddb7dc4dc Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Thu, 18 Jan 2024 14:56:53 +0100 Subject: [PATCH 1/8] migrate github cli from hub to gh (hub is deprecated) see annoncement https://github.com/actions/runner-images/issues/8362 Signed-off-by: Vincent Gramer --- .../workflows/release_and_pulbish_plugin_on_tag.yml | 8 ++------ hack/create_or_update_release_notes_pr.sh | 12 ++++++------ hack/generate_release_notes.sh | 6 +++--- hack/util.sh | 6 +++--- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release_and_pulbish_plugin_on_tag.yml b/.github/workflows/release_and_pulbish_plugin_on_tag.yml index 38fbca8..83a1b21 100644 --- a/.github/workflows/release_and_pulbish_plugin_on_tag.yml +++ b/.github/workflows/release_and_pulbish_plugin_on_tag.yml @@ -58,15 +58,11 @@ jobs: - name: create or update release note PR env: - # Required for the `hub` CLI + # Required for the `gh` CLI GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | VERSION="${GITHUB_REF/refs\/tags\//}" echo -e "${VERSION}\n" > gh_release_description.md sed -e '0,/Release notes for v/d' -e '/Release notes for v/,$d' CHANGELOG.md >> gh_release_description.md - assets='' - for file in $(ls ./artifacts/); do assets="${assets} -a ./artifacts/${file}"; done - echo "assets=${assets}" - - hub release create -F gh_release_description.md ${assets} "${VERSION}" + gh release create -F gh_release_description.md "${VERSION}" ./artifacts/.* diff --git a/hack/create_or_update_release_notes_pr.sh b/hack/create_or_update_release_notes_pr.sh index 07d9668..bf6395e 100755 --- a/hack/create_or_update_release_notes_pr.sh +++ b/hack/create_or_update_release_notes_pr.sh @@ -8,7 +8,7 @@ # This script is intended to be run in github action but can run in local. # The following requirements must be satisfied: # * same requirement as hack/generate_release_notes.sh -# * the github cli: hub must be installed (https://hub.github.com/) +# * the github cli: gh must be installed (https://cli.github.com/) ######################################################################################################################## set -o errexit @@ -18,11 +18,11 @@ set -o pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" source "${ROOT}/hack/util.sh" -util::require-hub +util::require-gh release_note_branch='update-release-notes' base_branch='master' -pr_number="$(hub pr list -h update-release-notes --format '%I')" +pr_number="$(gh pr list -H update-release-notes --limit 1 --json number --jq '.[].number')" if [[ -z "${pr_number}" ]]; then pr_exist=false @@ -30,8 +30,8 @@ if [[ -z "${pr_number}" ]]; then git checkout -b "${release_note_branch}" else pr_exist=true - echo "release notes pr already exist (#pr_number)" - hub pr checkout "${pr_number}" + echo "release notes pr already exist (pr_number=${pr_number})" + gh pr checkout "${pr_number}" git reset --hard "${base_branch}" fi @@ -68,5 +68,5 @@ git push origin "${release_note_branch}" -f if [[ "${pr_exist}" == false ]]; then echo "create release note PR" - hub pull-request --base master --head "${release_note_branch}" --file "${ROOT}/.github/release-notes-pr-description.md" + gh pr create --base master --head "${release_note_branch}" --body-file "${ROOT}/.github/release-notes-pr-description.md" fi diff --git a/hack/generate_release_notes.sh b/hack/generate_release_notes.sh index ebe1b2f..81bb104 100755 --- a/hack/generate_release_notes.sh +++ b/hack/generate_release_notes.sh @@ -9,7 +9,7 @@ # This script is intended to be run in github action but can run in local. # # The following tools must be installed and be in the PATH -# * hub: the github cli (https://hub.github.com/) +# * gh: the github cli (https://cli.github.com/) # * release-notes: the k8s release-notes-generator tools (https://github.com/kubernetes/release#release-notes) # can be install thanks to go get command: # GO111MODULE=on go get k8s.io/release/cmd/release-notes@ @@ -51,7 +51,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" source "${ROOT}/hack/util.sh" function check_environment() { - util::require-hub + util::require-gh util::command_exists "release-notes" || util::fatal 'release-notes not found in path. Please install it before running script. "GO111MODULE=on go get k8s.io/release/cmd/release-notes@"' set +o nounset @@ -74,7 +74,7 @@ check_environment echo "org=${org} repo=${repo}" # format '%pI %T%n' -> "publish_date_ISO_8601 tag\n". eg:2 021-03-24T20:10:00Z v3.0.0 -last_release_tag="$(hub release -f '%pI %T%n' | sort -nr | head -1 | cut -d ' ' -f 2)" +last_release_tag="$(gh api -t '{{.tag_name}}' -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/${org}/${repo}/releases/latest")" if [[ -z "${last_release_tag}" ]]; then echo "no release found on repository. fallback to first commit" diff --git a/hack/util.sh b/hack/util.sh index 58a6c29..69e7efe 100644 --- a/hack/util.sh +++ b/hack/util.sh @@ -40,7 +40,7 @@ function util::fatal() { exit 1 } -# Check "hub" command exist and exit with error message if does not. -function util::require-hub() { - util::command_exists "hub" || util::fatal 'hub not found in path. please install it before running script. see instruction at https://hub.github.com/' +# Check "gh" command exist and exit with error message if does not. +function util::require-gh() { + util::command_exists "gh" || util::fatal 'gh not found in path. please install it before running script. see instruction at https://cli.github.com/' } From 2935b85d25575dede01571154e474b67607ec70a Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Thu, 18 Jan 2024 15:04:50 +0100 Subject: [PATCH 2/8] github actions: bump checkout action from v2 to v4 Signed-off-by: Vincent Gramer --- .github/workflows/release_and_pulbish_plugin_on_tag.yml | 6 +++--- .github/workflows/test.yml | 8 ++++---- .../upset_release_notes_pr_on_push_on_master.yml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release_and_pulbish_plugin_on_tag.yml b/.github/workflows/release_and_pulbish_plugin_on_tag.yml index 83a1b21..ef495fb 100644 --- a/.github/workflows/release_and_pulbish_plugin_on_tag.yml +++ b/.github/workflows/release_and_pulbish_plugin_on_tag.yml @@ -7,7 +7,7 @@ jobs: check-gradle-wrapper: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 publish_plugin: @@ -27,7 +27,7 @@ jobs: # restore-keys: | # ${{ runner.os }}-gradle- - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Grant execute permission for gradlew run: chmod +x gradlew @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest needs : [ publish_plugin ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Download Artifact uses: actions/download-artifact@v2 id: download diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0eeef2..cf1b1d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,13 +14,13 @@ jobs: check-license: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: ./hack/check-license.sh check-gradle-wrapper: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 build: @@ -31,7 +31,7 @@ jobs: needs: check-gradle-wrapper steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v3 with: @@ -71,7 +71,7 @@ jobs: needs: [check-gradle-wrapper, build ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/upset_release_notes_pr_on_push_on_master.yml b/.github/workflows/upset_release_notes_pr_on_push_on_master.yml index 2f1f802..0ddec99 100644 --- a/.github/workflows/upset_release_notes_pr_on_push_on_master.yml +++ b/.github/workflows/upset_release_notes_pr_on_push_on_master.yml @@ -10,7 +10,7 @@ jobs: upset_release_notes_pr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: # needed to be able to resolve commit of previous version fetch-depth: 0 From 4a83d1bf7412afc40c7636e79eec872da4d93570 Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Thu, 18 Jan 2024 15:07:05 +0100 Subject: [PATCH 3/8] github actions / test workflow: remove fail-fast strategy=false. it's only apply to matrix build which has been remove in previous version Signed-off-by: Vincent Gramer --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf1b1d1..42cb11b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,8 +24,6 @@ jobs: - uses: gradle/wrapper-validation-action@v1 build: - strategy: - fail-fast: false timeout-minutes: 60 runs-on: ubuntu-latest needs: check-gradle-wrapper From 5cad3d69af609b61ae9bb23ef7f17bf314a7da00 Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Thu, 18 Jan 2024 15:09:42 +0100 Subject: [PATCH 4/8] github actions bump gradle/wrapper-validation-action to v1.1.0 Signed-off-by: Vincent Gramer --- .github/workflows/release_and_pulbish_plugin_on_tag.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release_and_pulbish_plugin_on_tag.yml b/.github/workflows/release_and_pulbish_plugin_on_tag.yml index ef495fb..f7267d5 100644 --- a/.github/workflows/release_and_pulbish_plugin_on_tag.yml +++ b/.github/workflows/release_and_pulbish_plugin_on_tag.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/wrapper-validation-action@v1.1.0 publish_plugin: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42cb11b..9786a4e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/wrapper-validation-action@v1.1.0 build: timeout-minutes: 60 From ffd32ed752b04364ad6c7df1c390e9b78741ee2c Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Thu, 18 Jan 2024 15:12:43 +0100 Subject: [PATCH 5/8] github actions bump actions/setup-java to v4 Signed-off-by: Vincent Gramer --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9786a4e..2eeed1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: corretto @@ -71,7 +71,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: corretto From 3ba1de6b2cc79a9c19b8ee202dbe1b40978d2852 Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Thu, 18 Jan 2024 15:49:47 +0100 Subject: [PATCH 6/8] github actions: use gradle/gradle-build-action to setup gradle and remove cache action (too big so never loaded) Signed-off-by: Vincent Gramer --- .../release_and_pulbish_plugin_on_tag.yml | 22 +++++++------- .github/workflows/test.yml | 29 +++++-------------- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/.github/workflows/release_and_pulbish_plugin_on_tag.yml b/.github/workflows/release_and_pulbish_plugin_on_tag.yml index f7267d5..e30acba 100644 --- a/.github/workflows/release_and_pulbish_plugin_on_tag.yml +++ b/.github/workflows/release_and_pulbish_plugin_on_tag.yml @@ -17,19 +17,17 @@ jobs: ORG_GRADLE_PROJECT_publishChannel: stable ORG_GRADLE_PROJECT_publishToken: ${{ secrets.PUBLISH_TOKEN }} steps: -# # Cache gradle dependencies -# - uses: actions/cache@v2 -# with: -# path: | -# ~/.gradle/caches -# ~/.gradle/wrapper -# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} -# restore-keys: | -# ${{ runner.os }}-gradle- - - uses: actions/checkout@v4 - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: corretto + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + gradle-home-cache-cleanup: true - name: publish plugin run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2eeed1d..63ab8dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,17 +36,11 @@ jobs: java-version: 17 distribution: corretto - # Cache gradle dependencies - - uses: actions/cache@v2 + # Setup Gradle + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Grant execute permission for gradlew - run: chmod +x gradlew + gradle-home-cache-cleanup: true - name: Download OPA run: | @@ -76,24 +70,17 @@ jobs: java-version: 17 distribution: corretto - # Cache gradle dependencies - - uses: actions/cache@v2 + # Setup Gradle + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- + gradle-home-cache-cleanup: true - uses: actions/cache@v2 with: path: ~/.pluginVerifier/ides key: ${{ runner.os }}-plugin-verifier-ides - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Verify plugin binary compatibility run: ./gradlew :plugin:runPluginVerifier From e7cc6a5646f7e78390937c10494aebc8ba6f8e19 Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Thu, 18 Jan 2024 16:06:12 +0100 Subject: [PATCH 7/8] github actions: set publish channel as secret to avoid publish release when testing workflow Signed-off-by: Vincent Gramer --- .github/workflows/release_and_pulbish_plugin_on_tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_and_pulbish_plugin_on_tag.yml b/.github/workflows/release_and_pulbish_plugin_on_tag.yml index e30acba..2392c0a 100644 --- a/.github/workflows/release_and_pulbish_plugin_on_tag.yml +++ b/.github/workflows/release_and_pulbish_plugin_on_tag.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest needs: [check-gradle-wrapper] env: - ORG_GRADLE_PROJECT_publishChannel: stable + ORG_GRADLE_PROJECT_publishChannel: ${{ secrets.PUBLISH_CHANNEL }} ORG_GRADLE_PROJECT_publishToken: ${{ secrets.PUBLISH_TOKEN }} steps: - uses: actions/checkout@v4 From 1a0dfa0f89f82eef5dface2b94cc21fcb269d5dc Mon Sep 17 00:00:00 2001 From: Vincent Gramer Date: Wed, 7 Feb 2024 19:08:17 +0100 Subject: [PATCH 8/8] github actions: remove test before publish as it executed in previous pipeline Signed-off-by: Vincent Gramer --- .github/workflows/release_and_pulbish_plugin_on_tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_and_pulbish_plugin_on_tag.yml b/.github/workflows/release_and_pulbish_plugin_on_tag.yml index 2392c0a..a08ae6c 100644 --- a/.github/workflows/release_and_pulbish_plugin_on_tag.yml +++ b/.github/workflows/release_and_pulbish_plugin_on_tag.yml @@ -32,7 +32,7 @@ jobs: - name: publish plugin run: | export ORG_GRADLE_PROJECT_pluginVersion="${GITHUB_REF/refs\/tags\//}" - ./gradlew clean :test :plugin:publishPlugin + ./gradlew :plugin:publishPlugin - name: Upload artifact uses: actions/upload-artifact@v2.2.2