Skip to content

Commit

Permalink
fix release github action
Browse files Browse the repository at this point in the history
Signed-off-by: Xudong Liu <[email protected]>
  • Loading branch information
XudongLiuHarold committed Jun 14, 2024
1 parent d76ab69 commit 219856d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/auto-sync-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ jobs:
id: check
run: |
git fetch --tags --force
echo "latest release is ${latest_tag}"
latest_tag=$(git tag --sort=-creatordate | head -n 1)
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=${valid}" >> $GITHUB_OUTPUT
- name: Cherry Pick All Related Changes in Master Branch
if: ${{ steps.check.outputs.valid }}
if: ${{ steps.check.outputs.valid }} == 0
run: |
git checkout gh-pages
git checkout -b topic/github-action/update-gh-pages-$(date +'%Y%m%d')
Expand All @@ -48,7 +51,7 @@ jobs:
git push -u origin topic/github-action/update-gh-pages-$(date +'%Y%m%d')
- name: Create Pull Request
if: ${{ steps.check.outputs.valid }}
if: ${{ steps.check.outputs.valid }} == 0
run: |
gh pr create --title ":book:(docs) cherry-pick docs update to gh-pages" \
--body "This PR was created by GitHub Actions to update documentation in gh-pages branch" \
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/generate-release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,38 @@ 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=${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,}$'
PRERELEASE_SEMVER_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*$'
STABLE_RELEASE_SEMVER_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+$'
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} | awk 'p{print; exit} /${latest_tag}/{p=1}')
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} | awk 'p{print; exit} /${latest_tag}/{p=1}')
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
echo "second_latest_release_tag=${second_latest_release_tag}" >> $GITHUB_OUTPUT
- name: Generate Release Note
if: ${{ steps.check.outputs.valid }}
if: ${{ steps.check.outputs.valid }} == 0
run: |
if ${{ steps.find.outputs.pre_release}} >/dev/null 2>&1; then
if [ -n ${{ steps.find.outputs.pre_release }} ]; 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 }}
Expand Down

0 comments on commit 219856d

Please sign in to comment.