From 7b284c04ed1dbf54f1337cb967721c762187fb34 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 17:27:39 +0800 Subject: [PATCH] fix: beta release to use version-specific branches and link to artifacts (#6700) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: louislam <1336778+louislam@users.noreply.github.com> --- .github/workflows/beta-release.yml | 12 +++++++++--- extra/release/beta.mjs | 8 +++++--- extra/release/lib.mjs | 23 ++++++++++++++++------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index 7d6792425..7cb1e756e 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -39,12 +39,17 @@ jobs: node-version: 24 - name: Create release branch + env: + VERSION: ${{ inputs.version }} run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - # Delete local release branch if it exists - git branch -D release || true - git checkout -b release + # Delete remote branch if it exists + git push origin --delete "release-${VERSION}" || true + # Delete local branch if it exists + git branch -D "release-${VERSION}" || true + # Create new branch from master + git checkout -b "release-${VERSION}" - name: Install dependencies run: npm clean-install --no-fund @@ -74,6 +79,7 @@ jobs: RELEASE_PREVIOUS_VERSION: ${{ inputs.previous_version }} DRY_RUN: ${{ inputs.dry_run }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_RUN_ID: ${{ github.run_id }} run: npm run release-beta - name: Upload dist.tar.gz as artifact diff --git a/extra/release/beta.mjs b/extra/release/beta.mjs index caa3fd387..80a2b0ea3 100644 --- a/extra/release/beta.mjs +++ b/extra/release/beta.mjs @@ -18,6 +18,8 @@ const repoNames = getRepoNames(); const version = process.env.RELEASE_BETA_VERSION; const dryRun = process.env.DRY_RUN === "true"; const previousVersion = process.env.RELEASE_PREVIOUS_VERSION; +const branchName = `release-${version}`; +const githubRunId = process.env.GITHUB_RUN_ID; if (dryRun) { console.log("Dry run mode enabled. No images will be pushed."); @@ -25,8 +27,8 @@ if (dryRun) { console.log("RELEASE_BETA_VERSION:", version); -// Check if the current branch is "release" -checkReleaseBranch(); +// Check if the current branch is "release-{version}" +checkReleaseBranch(branchName); // Check if the version is a valid semver checkVersionFormat(version); @@ -49,7 +51,7 @@ await checkTagExists(repoNames, version); execSync("node ./extra/beta/update-version.js"); // Create Pull Request -await createReleasePR(version, previousVersion, dryRun); +await createReleasePR(version, previousVersion, dryRun, branchName, githubRunId); // Build frontend dist buildDist(); diff --git a/extra/release/lib.mjs b/extra/release/lib.mjs index 6cb0a97a2..9215026b9 100644 --- a/extra/release/lib.mjs +++ b/extra/release/lib.mjs @@ -247,14 +247,15 @@ export function execSync(cmd) { } /** - * Check if the current branch is "release" + * Check if the current branch matches the expected release branch pattern + * @param {string} expectedBranch Expected branch name (can be "release" or "release-{version}") * @returns {void} */ -export function checkReleaseBranch() { +export function checkReleaseBranch(expectedBranch = "release") { const res = childProcess.spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]); const branch = res.stdout.toString().trim(); - if (branch !== "release") { - console.error(`Current branch is ${branch}, please switch to "release" branch`); + if (branch !== expectedBranch) { + console.error(`Current branch is ${branch}, please switch to "${expectedBranch}" branch`); process.exit(1); } } @@ -302,12 +303,20 @@ export async function createDistTarGz() { * @param {string} version Version * @param {string} previousVersion Previous version tag * @param {boolean} dryRun Still create the PR, but add "[DRY RUN]" to the title + * @param {string} branchName The branch name to use for the PR head (defaults to "release") + * @param {string} githubRunId The GitHub Actions run ID for linking to artifacts * @returns {Promise} */ -export async function createReleasePR(version, previousVersion, dryRun) { +export async function createReleasePR(version, previousVersion, dryRun, branchName = "release", githubRunId = null) { const changelog = await generateChangelog(previousVersion); const title = dryRun ? `chore: update to ${version} (dry run)` : `chore: update to ${version}`; + + // Build the artifact link - use direct run link if available, otherwise link to workflow file + const artifactLink = githubRunId + ? `https://github.com/louislam/uptime-kuma/actions/runs/${githubRunId}/workflow` + : `https://github.com/louislam/uptime-kuma/actions/workflows/beta-release.yml`; + const body = `## Release ${version} This PR prepares the release for version ${version}. @@ -317,7 +326,7 @@ This PR prepares the release for version ${version}. - [ ] Create a new release on GitHub with the tag \`${version}\`. - [ ] Ask any LLM to categorize the changelog into sections. - [ ] Place the changelog in the release note. -- [ ] Download and upload the \`dist.tar.gz\` artifact to the release. +- [ ] Download the \`dist.tar.gz\` artifact from the [workflow run](${artifactLink}) and upload it to the release. - [ ] (Beta only) Set prerelease - [ ] Publish the release note on GitHub. @@ -332,7 +341,7 @@ The \`dist.tar.gz\` archive will be available as an artifact in the workflow run `; // Create the PR using gh CLI - const args = ["pr", "create", "--title", title, "--body", body, "--base", "master", "--head", "release", "--draft"]; + const args = ["pr", "create", "--title", title, "--body", body, "--base", "master", "--head", branchName, "--draft"]; console.log(`Creating draft PR: ${title}`);