-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Added a post-release workflow #2789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Rishab87
wants to merge
1
commit into
kubernetes:main
Choose a base branch
from
Rishab87:post-release-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| name: Post Release | ||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| promote-image: | ||
| 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: Install kpromo | ||
| run: go install sigs.k8s.io/promo-tools/v4/cmd/kpromo@latest | ||
|
|
||
| - name: Get latest pre-release tag | ||
| id: extract_tag | ||
| run: | | ||
| TAG=$(gh release list --limit 1 --json tagName,isPrerelease --jq '.[] | select(.isPrerelease == true) | .tagName') | ||
| if [ -z "$TAG" ]; then | ||
| echo "Error: No pre-release found" | ||
| exit 1 | ||
| fi | ||
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | ||
| echo "Found pre-release tag: ${TAG}" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create image promotion PR | ||
| run: | | ||
| kpromo pr --fork=${{ github.actor }} -i \ | ||
| --project=kube-state-metrics \ | ||
| --tag=${{ steps.extract_tag.outputs.tag }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| merge-back-to-main: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Get latest pre-release tag | ||
| id: extract_tag | ||
| run: | | ||
| TAG=$(gh release list --limit 1 --json tagName,isPrerelease --jq '.[] | select(.isPrerelease == true) | .tagName') | ||
| if [ -z "$TAG" ]; then | ||
| echo "Error: No pre-release found" | ||
| exit 1 | ||
| fi | ||
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | ||
| echo "Found pre-release tag: ${TAG}" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create PR to merge release changes back to main | ||
| run: | | ||
| # Extract major.minor for branch name | ||
| MAJOR_MINOR=$(echo "${{ steps.extract_tag.outputs.tag }}" | sed 's/v//' | cut -d. -f1,2) | ||
| RELEASE_BRANCH="release-${MAJOR_MINOR}" | ||
| # Check if branches exist and have differences | ||
| if ! git rev-parse --verify "origin/${RELEASE_BRANCH}" >/dev/null 2>&1; then | ||
| echo "Error: Branch ${RELEASE_BRANCH} does not exist" | ||
| exit 1 | ||
| fi | ||
| # Check if there are commits to merge | ||
| if git merge-base --is-ancestor "origin/${RELEASE_BRANCH}" origin/main; then | ||
| echo "No commits to merge - ${RELEASE_BRANCH} is already merged into main" | ||
| exit 0 | ||
| fi | ||
| gh pr create \ | ||
| --title "chore: Merge ${{ steps.extract_tag.outputs.tag }} back to main" \ | ||
| --body "Merge release changes from ${{ steps.extract_tag.outputs.tag }} back to main branch." \ | ||
| --base main \ | ||
| --head $RELEASE_BRANCH \ | ||
| --reviewer @sig-instrumentation-approvers \ | ||
| --assignee @sig-instrumentation-leads | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I only see the second part of this workflow in the test run. Were you able to test this out on your local?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I tested this exact command when I was releasing
2.17.0locally. I think running it again would create a PR in k8s.io. Should I still test it again? Just wanted to confirm here if it's not a problem if I create a PR in k8s.io for testing this out again.