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>
This commit is contained in:
parent
70d541a11c
commit
7b284c04ed
12
.github/workflows/beta-release.yml
vendored
12
.github/workflows/beta-release.yml
vendored
@ -39,12 +39,17 @@ jobs:
|
|||||||
node-version: 24
|
node-version: 24
|
||||||
|
|
||||||
- name: Create release branch
|
- name: Create release branch
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
# Delete local release branch if it exists
|
# Delete remote branch if it exists
|
||||||
git branch -D release || true
|
git push origin --delete "release-${VERSION}" || true
|
||||||
git checkout -b release
|
# 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
|
- name: Install dependencies
|
||||||
run: npm clean-install --no-fund
|
run: npm clean-install --no-fund
|
||||||
@ -74,6 +79,7 @@ jobs:
|
|||||||
RELEASE_PREVIOUS_VERSION: ${{ inputs.previous_version }}
|
RELEASE_PREVIOUS_VERSION: ${{ inputs.previous_version }}
|
||||||
DRY_RUN: ${{ inputs.dry_run }}
|
DRY_RUN: ${{ inputs.dry_run }}
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GITHUB_RUN_ID: ${{ github.run_id }}
|
||||||
run: npm run release-beta
|
run: npm run release-beta
|
||||||
|
|
||||||
- name: Upload dist.tar.gz as artifact
|
- name: Upload dist.tar.gz as artifact
|
||||||
|
|||||||
@ -18,6 +18,8 @@ const repoNames = getRepoNames();
|
|||||||
const version = process.env.RELEASE_BETA_VERSION;
|
const version = process.env.RELEASE_BETA_VERSION;
|
||||||
const dryRun = process.env.DRY_RUN === "true";
|
const dryRun = process.env.DRY_RUN === "true";
|
||||||
const previousVersion = process.env.RELEASE_PREVIOUS_VERSION;
|
const previousVersion = process.env.RELEASE_PREVIOUS_VERSION;
|
||||||
|
const branchName = `release-${version}`;
|
||||||
|
const githubRunId = process.env.GITHUB_RUN_ID;
|
||||||
|
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
console.log("Dry run mode enabled. No images will be pushed.");
|
console.log("Dry run mode enabled. No images will be pushed.");
|
||||||
@ -25,8 +27,8 @@ if (dryRun) {
|
|||||||
|
|
||||||
console.log("RELEASE_BETA_VERSION:", version);
|
console.log("RELEASE_BETA_VERSION:", version);
|
||||||
|
|
||||||
// Check if the current branch is "release"
|
// Check if the current branch is "release-{version}"
|
||||||
checkReleaseBranch();
|
checkReleaseBranch(branchName);
|
||||||
|
|
||||||
// Check if the version is a valid semver
|
// Check if the version is a valid semver
|
||||||
checkVersionFormat(version);
|
checkVersionFormat(version);
|
||||||
@ -49,7 +51,7 @@ await checkTagExists(repoNames, version);
|
|||||||
execSync("node ./extra/beta/update-version.js");
|
execSync("node ./extra/beta/update-version.js");
|
||||||
|
|
||||||
// Create Pull Request
|
// Create Pull Request
|
||||||
await createReleasePR(version, previousVersion, dryRun);
|
await createReleasePR(version, previousVersion, dryRun, branchName, githubRunId);
|
||||||
|
|
||||||
// Build frontend dist
|
// Build frontend dist
|
||||||
buildDist();
|
buildDist();
|
||||||
|
|||||||
@ -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}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
export function checkReleaseBranch() {
|
export function checkReleaseBranch(expectedBranch = "release") {
|
||||||
const res = childProcess.spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
const res = childProcess.spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||||
const branch = res.stdout.toString().trim();
|
const branch = res.stdout.toString().trim();
|
||||||
if (branch !== "release") {
|
if (branch !== expectedBranch) {
|
||||||
console.error(`Current branch is ${branch}, please switch to "release" branch`);
|
console.error(`Current branch is ${branch}, please switch to "${expectedBranch}" branch`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,12 +303,20 @@ export async function createDistTarGz() {
|
|||||||
* @param {string} version Version
|
* @param {string} version Version
|
||||||
* @param {string} previousVersion Previous version tag
|
* @param {string} previousVersion Previous version tag
|
||||||
* @param {boolean} dryRun Still create the PR, but add "[DRY RUN]" to the title
|
* @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<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function createReleasePR(version, previousVersion, dryRun) {
|
export async function createReleasePR(version, previousVersion, dryRun, branchName = "release", githubRunId = null) {
|
||||||
const changelog = await generateChangelog(previousVersion);
|
const changelog = await generateChangelog(previousVersion);
|
||||||
|
|
||||||
const title = dryRun ? `chore: update to ${version} (dry run)` : `chore: update to ${version}`;
|
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}
|
const body = `## Release ${version}
|
||||||
|
|
||||||
This PR prepares the release for version ${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}\`.
|
- [ ] Create a new release on GitHub with the tag \`${version}\`.
|
||||||
- [ ] Ask any LLM to categorize the changelog into sections.
|
- [ ] Ask any LLM to categorize the changelog into sections.
|
||||||
- [ ] Place the changelog in the release note.
|
- [ ] 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
|
- [ ] (Beta only) Set prerelease
|
||||||
- [ ] Publish the release note on GitHub.
|
- [ ] 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
|
// 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}`);
|
console.log(`Creating draft PR: ${title}`);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user