diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index 7d6792425..7729fb66e 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -42,9 +42,12 @@ jobs: 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-${{ inputs.version }} || true + # Delete local branch if it exists + git branch -D release-${{ inputs.version }} || true + # Create new branch from master + git checkout -b release-${{ inputs.version }} - name: Install dependencies run: npm clean-install --no-fund diff --git a/extra/release/beta.mjs b/extra/release/beta.mjs index caa3fd387..55c736989 100644 --- a/extra/release/beta.mjs +++ b/extra/release/beta.mjs @@ -18,6 +18,7 @@ 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}`; if (dryRun) { console.log("Dry run mode enabled. No images will be pushed."); @@ -25,8 +26,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 +50,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); // Build frontend dist buildDist(); diff --git a/extra/release/lib.mjs b/extra/release/lib.mjs index 6cb0a97a2..7cdf885a5 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,9 +303,10 @@ 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") * @returns {Promise} */ -export async function createReleasePR(version, previousVersion, dryRun) { +export async function createReleasePR(version, previousVersion, dryRun, branchName = "release") { const changelog = await generateChangelog(previousVersion); const title = dryRun ? `chore: update to ${version} (dry run)` : `chore: update to ${version}`; @@ -317,7 +319,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](https://github.com/louislam/uptime-kuma/actions/workflows/beta-release.yml) and upload it to the release. - [ ] (Beta only) Set prerelease - [ ] Publish the release note on GitHub. @@ -332,7 +334,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}`);