From d76ab6944705a959ffe2501c0486f83af4c8f3c2 Mon Sep 17 00:00:00 2001 From: Xudong Liu Date: Fri, 14 Jun 2024 17:23:01 +0800 Subject: [PATCH] fix release 1.29 github action (#1097) --- .github/workflows/auto-sync-gh-pages.yml | 2 +- .github/workflows/bump-k8s-dep.yml | 62 +++++++++++++++++++ .github/workflows/bump-test-k8s-dep.yml | 64 ++++++++++++++++++++ .github/workflows/generate-release-notes.yml | 6 +- 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/bump-k8s-dep.yml create mode 100644 .github/workflows/bump-test-k8s-dep.yml diff --git a/.github/workflows/auto-sync-gh-pages.yml b/.github/workflows/auto-sync-gh-pages.yml index 7b2b61930..05841c83b 100644 --- a/.github/workflows/auto-sync-gh-pages.yml +++ b/.github/workflows/auto-sync-gh-pages.yml @@ -31,7 +31,7 @@ jobs: - name: Check Latest Release Tag id: check run: | - git fetch --tags + git fetch --tags --force latest_tag=$(git tag --sort=-creatordate | head -n 1) echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/bump-k8s-dep.yml b/.github/workflows/bump-k8s-dep.yml new file mode 100644 index 000000000..502391274 --- /dev/null +++ b/.github/workflows/bump-k8s-dep.yml @@ -0,0 +1,62 @@ +name: Bump latest Kubernetes dependecies + +on: + schedule: + - cron: '0 0 */2 * *' # Run every two days at UTC midnight + + workflow_dispatch: # Use for manaully trigger to debug + +jobs: + bump-k8s-dep-to-latest-pre-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Bump latest k8s.io dependencies + id: bump + run: | + LATEST_VERSION=$(./hack/bump-k8s-dep.sh) + echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Check for changes and update version + id: changes + run: | + git_diff_output=$(git diff) + if [ -n "$git_diff_output" ]; then + echo "changes=true" >> $GITHUB_OUTPUT + fi + + - name: Check if update PR exist + id: exist + run: | + LATEST_VERSION=${{ steps.bump.outputs.latest_version }} + HEAD_BRANCH="topic/github-actions/auto-bump/k8s-dependencies-$LATEST_VERSION" + echo "$HEAD_BRANCH" + if ! git ls-remote --exit-code origin refs/heads/$HEAD_BRANCH; then + echo "exist=true" >> $GITHUB_OUTPUT + echo "head_branch=$HEAD_BRANCH" >> $GITHUB_OUTPUT + fi + + - name: Create PR + if: ${{ steps.changes.outputs.changes && steps.exist.outputs.exist }} + run: | + HEAD_BRANCH=${{ steps.exist.outputs.head_branch }} + git checkout -b "$HEAD_BRANCH" + git add go.mod go.sum + git commit -sm "Bump Kubernetes group dependencies updates" + git push origin "$HEAD_BRANCH" + gh pr create --base master --title ":seedling:(deps) Bump the Kubernetes group to ${{ steps.bump.outputs.latest_version }}" --label "ok-to-test" --body "This is an automatically generated pull request to bump the latest k8s dependencies." + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/bump-test-k8s-dep.yml b/.github/workflows/bump-test-k8s-dep.yml new file mode 100644 index 000000000..0dc3b0a4e --- /dev/null +++ b/.github/workflows/bump-test-k8s-dep.yml @@ -0,0 +1,64 @@ +name: Bump latest Kubernetes dependecies for e2e test + +on: + schedule: + - cron: '0 12 */2 * *' # Run every two days at UTC noon + + workflow_dispatch: # Use for manaully trigger to debug + +jobs: + bump-test-k8s-dep-to-latest-pre-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'test/e2e/go.mod' + + - name: Bump latest k8s.io dependencies + id: bump + run: | + cd test/e2e + LATEST_VERSION=$(../../hack/bump-k8s-dep.sh test-e2e) + echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT + cd ../.. + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Check for changes and update version + id: changes + run: | + git_diff_output=$(git diff) + if [ -n "$git_diff_output" ]; then + echo "changes=true" >> $GITHUB_OUTPUT + fi + + - name: Check if update PR already exist + id: exist + run: | + LATEST_VERSION=${{ steps.bump.outputs.latest_version }} + HEAD_BRANCH="topic/github-actions/auto-bump/test-e2e-k8s-dependencies-$LATEST_VERSION" + echo "$HEAD_BRANCH" + if ! git ls-remote --exit-code origin refs/heads/$HEAD_BRANCH; then + echo "exist=true" >> $GITHUB_OUTPUT + echo "head_branch=$HEAD_BRANCH" >> $GITHUB_OUTPUT + fi + + - name: Create PR + if: ${{ steps.changes.outputs.changes && steps.exist.outputs.exist }} + run: | + HEAD_BRANCH=${{ steps.exist.outputs.head_branch }} + git checkout -b "$HEAD_BRANCH" + git add test/e2e/go.mod test/e2e/go.sum + git commit -sm "Bump kubernetes group dependencies updates for e2e test" + git push origin "$HEAD_BRANCH" + gh pr create --base master --title ":seedling:(deps)test: Bump the kubernetes group to ${{ steps.bump.outputs.latest_version }} for e2e test" --label "ok-to-test" --body "This is an automatic generated pull request to bump the latest k8s dependencies for e2e test." + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/generate-release-notes.yml b/.github/workflows/generate-release-notes.yml index 1bd243291..cbe2a3fa2 100644 --- a/.github/workflows/generate-release-notes.yml +++ b/.github/workflows/generate-release-notes.yml @@ -36,7 +36,7 @@ jobs: - name: Check Latest Release Tag id: check run: | - git fetch --tags + git fetch --tags --force latest_tag=$(git tag --sort=-creatordate | head -n 1) echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT @@ -52,11 +52,11 @@ jobs: latest_tag=${{ steps.check.outputs.latest_tag }} if [[ latest_tag =~ ${PRERELEASE_SEMVER_REGEX} ]]; then - second_latest_release_tag=$(git tag --sort=-v:refname | grep -E ${SEMVER_REGEX} | sed -n '2p') + second_latest_release_tag=$(git tag --sort=-v:refname | grep -E ${SEMVER_REGEX} | awk 'p{print; exit} /${latest_tag}/{p=1}') echo "${latest_tag} is a pre-release, return second latest release tag ${second_latest_release_tag}" echo "pre_release=1" >> $GITHUB_OUTPUT else - second_latest_release_tag=$(git tag --sort=-v:refname | grep -E ${STABLE_RELEASE_SEMVER_REGEX} | sed -n '2p') + second_latest_release_tag=$(git tag --sort=-v:refname | grep -E ${STABLE_RELEASE_SEMVER_REGEX} | awk 'p{print; exit} /${latest_tag}/{p=1}') echo "${latest_tag} is a stable release, return second stable release tag ${second_latest_release_tag}" fi