Skip to content

Commit

Permalink
automatic generate release notes (#1056)
Browse files Browse the repository at this point in the history
* automatic generate release notes

Signed-off-by: xudong liu <xudong.liu@broadcom.com>

* skip verify to test

Signed-off-by: xudong liu <xudong.liu@broadcom.com>

---------

Signed-off-by: xudong liu <xudong.liu@broadcom.com>
  • Loading branch information
XudongLiuHarold authored May 29, 2024
1 parent 6aa9dcc commit 56eaa6a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch: # Use for manaully trigger to debug

jobs:
release:
release-helm-chart:
runs-on: ubuntu-latest
steps:
# This step uses Github's checkout-action: https://github.com/actions/checkout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch: # Use for manaully trigger to debug

jobs:
bump-to-latest-pre-release:
bump-k8s-dep-to-latest-pre-release:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -57,6 +57,6 @@ jobs:
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: 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."
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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch: # Use for manaully trigger to debug

jobs:
bump-to-latest-pre-release:
bump-test-k8s-dep-to-latest-pre-release:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -59,6 +59,6 @@ jobs:
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: 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."
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 }}
69 changes: 69 additions & 0 deletions .github/workflows/generate-release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Generate Release Notes

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

workflow_dispatch: # Use for manaully trigger to debug


permissions:
contents: write # Allow to create a release.

jobs:
generate-release-notes:
runs-on: ubuntu-latest
steps:
# This step uses Github's checkout-action: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

# Configure Git for helm release
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Check Latest Release Tag
id: check
run: |
echo "valid=$(./hack/match-release-tag.sh >/dev/null 2>&1)" >> $GITHUB_OUTPUT
- name: Find Second Latest Release Tag
# if: ${{ step.check.output.valid }}
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]+$'
git fetch --tags
latest_release_tag=$(git tag --sort=-v:refname | grep -E ${SEMVER_REGEX} | sed -n '1p')
echo "latest_release_tag=${latest_release_tag}" >> $GITHUB_OUTPUT
if [[ latest_release_tag =~ ${PRERELEASE_SEMVER_REGEX} ]]; then
echo "${latest_release_tag} is a pre-release, return second latest release tag"
echo "pre_release=1" >> $GITHUB_OUTPUT
echo "second_latest_release_tag=$(git tag --sort=-v:refname | grep -E ${SEMVER_REGEX} | sed -n '2p')" >> $GITHUB_OUTPUT
else
echo "${latest_release_tag} is a stable release, return second stable release tag"
echo "second_latest_release_tag=$(git tag --sort=-v:refname | grep -E ${STABLE_RELEASE_SEMVER_REGEX} | sed -n '2p')" >> $GITHUB_OUTPUT
fi
- name: Generate Release Note
# if: ${{ step.check.output.valid }}
run: |
if {{ step.find.pre_release}}; then
gh release create ${{ step.find.latest_release_tag }} --verify-tag --draft --generate-notes --notes-start-tag ${{ step.find.second_latest_release_tag}} --prerelease
else
gh release create ${{ step.find.latest_release_tag }} --verify-tag --draft --generate-notes --notes-start-tag ${{ step.find.second_latest_release_tag}}
fi
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

0 comments on commit 56eaa6a

Please sign in to comment.