From 2268321d5e4e08471db2fde4d5b96b28531a206d Mon Sep 17 00:00:00 2001 From: Xudong Liu Date: Fri, 14 Jun 2024 21:01:32 +0800 Subject: [PATCH] fix release github action Signed-off-by: Xudong Liu --- .github/workflows/generate-release-notes.yml | 32 ++++++++++++-------- hack/match-release-tag.sh | 3 ++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/generate-release-notes.yml b/.github/workflows/generate-release-notes.yml index cbe2a3fa2..8ce2cf1e3 100644 --- a/.github/workflows/generate-release-notes.yml +++ b/.github/workflows/generate-release-notes.yml @@ -38,12 +38,16 @@ jobs: run: | git fetch --tags --force latest_tag=$(git tag --sort=-creatordate | head -n 1) - + echo "latest release is ${latest_tag}" echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT - echo "valid=$(./hack/match-release-tag.sh ${latest_tag} >/dev/null 2>&1)" >> $GITHUB_OUTPUT + + ./hack/match-release-tag.sh ${latest_tag} + valid=$? + echo "valid release: ${valid}" + echo "valid=${valid}" >> $GITHUB_OUTPUT - name: Find Second Latest Release Tag - if: ${{ steps.check.outputs.valid }} + if: ${{ steps.check.outputs.valid }} == 0 id: find run: | SEMVER_REGEX='^[[:space:]]{0,}v[[:digit:]]{1,}\.[[:digit:]]{1,}\.[[:digit:]]{1,}(-(alpha|beta|rc)\.[[:digit:]]{1,}){0,1}[[:space:]]{0,}$' @@ -51,6 +55,8 @@ jobs: STABLE_RELEASE_SEMVER_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+$' latest_tag=${{ steps.check.outputs.latest_tag }} + echo "latest release is ${latest_tag}" + if [[ latest_tag =~ ${PRERELEASE_SEMVER_REGEX} ]]; then 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}" @@ -63,13 +69,13 @@ jobs: echo "second_latest_release_tag=${second_latest_release_tag}" >> $GITHUB_OUTPUT - - name: Generate Release Note - if: ${{ steps.check.outputs.valid }} - run: | - if ${{ steps.find.outputs.pre_release}} >/dev/null 2>&1; then - gh release create ${{ steps.check.outputs.latest_tag }} --verify-tag --generate-notes --notes-start-tag ${{ steps.find.outputs.second_latest_release_tag }} --prerelease - else - gh release create ${{ steps.check.outputs.latest_tag }} --verify-tag --generate-notes --notes-start-tag ${{ steps.find.outputs.second_latest_release_tag }} - fi - env: - GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + # - name: Generate Release Note + # if: ${{ steps.check.outputs.valid }} == 0 + # run: | + # if ${{ steps.find.outputs.pre_release}} >/dev/null 2>&1; then + # gh release create ${{ steps.check.outputs.latest_tag }} --verify-tag --generate-notes --notes-start-tag ${{ steps.find.outputs.second_latest_release_tag }} --prerelease + # else + # gh release create ${{ steps.check.outputs.latest_tag }} --verify-tag --generate-notes --notes-start-tag ${{ steps.find.outputs.second_latest_release_tag }} + # fi + # env: + # GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/hack/match-release-tag.sh b/hack/match-release-tag.sh index 96a668861..5176800c6 100755 --- a/hack/match-release-tag.sh +++ b/hack/match-release-tag.sh @@ -65,10 +65,13 @@ REGEX='^[[:space:]]{0,}v[[:digit:]]{1,}\.[[:digit:]]{1,}\.[[:digit:]]{1,}(-(alph # Match the tag against the regular expression for a release tag. match() { if [[ ${1} =~ ${REGEX} ]]; then + exit_code="${?}" echo "yay: ${1}" + echo "${exit_code}" else exit_code="${?}" echo "nay: ${1}" + echo "${exit_code}" return "${exit_code}" fi }