feat: implement automated release workflow#542
feat: implement automated release workflow#542shrutiyam-glitch wants to merge 9 commits intokubernetes-sigs:mainfrom
Conversation
✅ Deploy Preview for agent-sandbox canceled.
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shrutiyam-glitch The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| promote-and-wait: | ||
| name: Promote Images and Wait for PR | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 360 # 6-hour limit for long k8s.io merge cycles |
There was a problem hiding this comment.
Are these guaranteed to merge in 6 hrs ?
There was a problem hiding this comment.
I added as an estimate.
I looked at the previous PRs (https://github.com/kubernetes/k8s.io/pulls?q=is%3Apr+author%3Ajanetkuo+is%3Aclosed+label%3Algtm). It looks like a k8s member can approve it and usually a member from sandbox OSS has approved it on the same day.
What do you think is a good timeout here ?
There was a problem hiding this comment.
i dont have any good value for a timeout. There can be 2 options:
- More timeout: on same day for me is > 6hrs. Maybe 12 hrs. or even 24 hrs. But that seems excessive.
- Periodic script: Mostly no-op. Check if release made for most recent tag. if not release. if it fails thats fine. Next run will try again.
In anycase, we need to parameterize the script so that we can manully run the workflow as a backup with the tag passed as parameter.
|
|
||
| - name: Clone k8s.io | ||
| env: | ||
| GH_TOKEN: ${{ secrets.K8S_IO_PAT }} |
There was a problem hiding this comment.
Ensure the PAT uses Fine-Grained Permissions scoped exclusively to the kubernetes/k8s.io repository (or its fork) if possible. Limit access to contents: write and pull_requests: write.
| make release-promote TAG="${GITHUB_REF_NAME}" K8S_IO_DIR=../k8s.io | tee promote_output.log | ||
|
|
||
| # Extract the URL from the log | ||
| PR_URL=$(grep -o 'https://github.com/kubernetes/k8s.io/pull/[0-9]*' promote_output.log | head -n 1) |
There was a problem hiding this comment.
Update the Makefile or promotion script to output the created PR URL directly to a structured file (e.g., echo $PR_URL > promote_pr.url) rather than relying on log output.
| @@ -0,0 +1,135 @@ | |||
| name: Release Automation | |||
There was a problem hiding this comment.
To test the workflow, you could try using act to simulate and run the GitHub Actions workflow inside local Docker containers, or add workflow_dispatch with a dry_run input parameter for manual, mutation-free cloud testing.
| sleep 300 | ||
| done | ||
|
|
||
| echo "❌ Timed out waiting for merge." |
There was a problem hiding this comment.
Can the workflow be resumed manually if timed out, rather than restarting the entire promotion process?
There was a problem hiding this comment.
Yes, it can be restarted from the job - "poll-merge".
|
As discussed, add a timer trigger which takes a commit id/branch and tag as optional parameters. |
94dfa44 to
c7237aa
Compare
| remotes = run_command(["git", "remote"], cwd=cwd, capture_output=True).splitlines() | ||
| if "upstream" in remotes: | ||
| return "upstream" | ||
| return "origin" |
There was a problem hiding this comment.
It's not safe to fall back to origin given that REMOTE_FORK is origin.
Also, it's not guaranteed that "origin" is in remotes, right?
Perhaps we throw an error here instead, asking users/runners to provide a value
We need to handle the REMOTE_FORK as well
| # Version tag is incremented by patch update | ||
| schedule: | ||
| - cron: '0 6 * * 5' # Every Friday at 06:00 UTC | ||
| # For Major/Minor version updates, enter tag manually |
There was a problem hiding this comment.
I'm not sure I understand this comment, would you clarify?
There was a problem hiding this comment.
If no manual tag is provided, the dev/tools/auto-tag script calculates the next version by incrementing the patch number of the latest existing tag (e.g., v0.1.0 becomes v0.1.1). The workflow then creates and pushes this new tag to the repository.
For Major/Minor version updates (0.1.0->0.2.0 or 1.0.0) - need to enter the tag version in the input field during manual run of the workflow.
| on: | ||
| # Version tag is incremented by patch update | ||
| schedule: | ||
| - cron: '0 6 * * 5' # Every Friday at 06:00 UTC |
There was a problem hiding this comment.
Please remove this. I want to trigger this release workflow manually a few times before running it in cron. There are things like breaking changes that need to be introduced/handled more carefully.
|
|
||
| url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key={api_key}" | ||
|
|
||
| prompt = f"You are a release assistant. Please summarize the following commit titles into a professional release note. Include an introductory paragraph highlighting the main achievements of this release, followed by a section called '### Key Highlights' with a bulleted list grouped logically. Keep it concise and focused on user-visible changes.\n\n{titles}" |
There was a problem hiding this comment.
Breaking changes need to be in the release notes
Can it look at the PR comment? I asked folks who're introducing breaking changes to add that in the first PR comment, e.g. #440
The PRs introducing breaking changes have the release-note-action-required label
Also, here's the prompt I used to curate the release notes. You can't use it directly here because I asked my agent to look at the release notes page and release notes draft, but you can take part of it to update your prompt if you'd like to.
**Task:** Given a release version number, generate curated release notes for **Agent Sandbox release draft** from "What's Changed", following the structure and tone of the last official release.
> **1. Reference Format:**
> * **Title:** ## 🚀 Announcing Agent Sandbox <version_number>!
> * **Intro:** Brief summary of key improvements (documentation, observability, stability).
> * **Sections:**
> * `### Key Highlights` (Grouped by feature area with bold titles).
> * `### Installation` (Code blocks for `kubectl apply`).
> * `## Contributors` (thank them, and find their names from "What's Changed", and sort them by PR submission time)
> * `### 👋 New Contributors` (copy from draft).
> * `Full Changelog` (copy from draft).
| # Get Gemini highlights | ||
| prev_tag = get_previous_tag(tag) | ||
| print(f"INFO: Found previous tag: {prev_tag}") | ||
| titles = get_commit_titles(prev_tag, tag) |
There was a problem hiding this comment.
Can we read commit messages and the first comment of the PR (i.e. PR description), to get more information?
| @@ -0,0 +1,170 @@ | |||
| name: Scheduled Release Automation | |||
There was a problem hiding this comment.
Have you tested the new scripts and the workflow? What tests/verification steps have you done? Would you provide an example release note that would be generated from main?
There was a problem hiding this comment.
Yes. Added the info in the PR description.
Testing:
Tested the workflow by running it manually on my forked repository with hardcoded image names.
Promote Image job - https://github.com/shrutiyam-glitch/agent-sandbox-trial/actions/runs/24554049773/job/71786142560
Promote PR that was created in k8s repo - kubernetes/k8s.io#9354
Ran make release-publish script on local. Draft release generated - https://github.com/shrutiyam-glitch/agent-sandbox-trial/releases/tag/untagged-d5948cb2c139173f52b7
There was a problem hiding this comment.
I can't see drafts given that it's not public - would you publish https://github.com/shrutiyam-glitch/agent-sandbox-trial/releases/tag/untagged-d5948cb2c139173f52b7?
|
@shrutiyam-glitch: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This Pull Request introduces an automated release workflow for the agent-sandbox repository, designed to streamline the process of promoting images and creating draft releases.
Fixes #408, #528
Summary
The changes implement a new GitHub Actions workflow that automates the manual steps required during a release. If the tag is not mentioned, the workflow creates the tag (auto -patching) and pushes the tag, promotes the images, waits for the promote PR to be merged and then generates the draft release.
Why
Previously, release engineers likely had to manually wait for image promotion PRs in the
k8s.iorepository to be merged before they could proceed with publishing a release. This automation reduces manual toil and the risk of human error by polling the PR status and proceeding only when the promotion is complete.The only steps involving human intervention is merge the promote images PR and publish the final draft release.
How
New Workflow (
.github/workflows/release.yml):1. Triggering a Release
every Friday at 06:00 UTCif new commits have been merged since the last tag.workflow_dispatchtrigger in the Actions tab.2. Versioning and Tagging
If no manual tag is provided, the
dev/tools/auto-tagscript calculates the next version by incrementing the patch number of the latest existing tag (e.g.,v0.1.0becomesv0.1.1). The workflow then creates and pushes this new tag to the repository.3. Image Promotion (
k8s.io)The release process automatically handles the promotion of container images to the official Kubernetes registry:
kubernetes/k8s.iorepository.make release-promote, which creates a Pull Request againstkubernetes/k8s.ioto stage and promote the new images.4. Automated Polling
To ensure the release isn't published before images are available, a Poll PR Status job monitors the
k8s.ioPull Request. It checks the PR state every 5 minutes for up to 12 hours. The workflow only proceeds once the PR is officially MERGED.5. Draft Release Generation
Once images are promoted, the workflow generates a draft release:
dev/tools/generate-release-notestool uses Gemini 2.5 Flash to summarize commit titles into professional release highlights.kubectlandpipinstallation commands tailored to the new version.make release-publishto create a draft release on GitHub for final human review before public announcement.Testing:
Tested the workflow by running it manually on my forked repository with hardcoded image names.
make release-publishscript on local. Draft release generated - https://github.com/shrutiyam-glitch/agent-sandbox-trial/releases/tag/untagged-d5948cb2c139173f52b7