Skip to content

Refactor version handling and add ReleaseSummary type#172

Open
krataratha wants to merge 1 commit intonexu-io:mainfrom
krataratha:patch-1
Open

Refactor version handling and add ReleaseSummary type#172
krataratha wants to merge 1 commit intonexu-io:mainfrom
krataratha:patch-1

Conversation

@krataratha
Copy link
Copy Markdown

Refactor version comparison and extraction functions for clarity and efficiency. Introduce ReleaseSummary type for better release data handling.

Refactor version comparison and extraction functions for clarity and efficiency. Introduce ReleaseSummary type for better release data handling.
Copilot AI review requested due to automatic review settings April 30, 2026 13:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c372b34a5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread scripts/release-beta.ts
Comment on lines +163 to +167
const releases: GitHubRelease[] = [
{ tag_name: "open-design-v1.2.0" },
{ tag_name: "open-design-v1.3.0-beta.1" },
{ tag_name: "open-design-v1.3.0-beta.2" },
{ tag_name: "open-design-v1.1.5" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Restore dynamic release metadata calculation

This script now computes metadata from a hardcoded releases array instead of querying the repository and packaged version, so the release-beta workflow no longer derives values from the actual release state. Because .github/workflows/release-beta.yml uses this script to prepare metadata for versioning and tagging, keeping sample data here will produce incorrect beta/tag decisions for real runs.

Useful? React with 👍 / 👎.

Comment thread scripts/release-beta.ts
setOutput("release_name", releaseName);
setOutput("signed", signed ? "true" : "false");
setOutput("version_tag", versionTag);
console.log(summarizeReleases(releases));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Write required workflow outputs to GITHUB_OUTPUT

The metadata job expects outputs like beta_version, version_tag, and asset_version_suffix from step beta, but this script now only logs a summary and never writes any outputs. In .github/workflows/release-beta.yml, downstream jobs consume those outputs (for example applying package version and creating tags), so this change leaves required values empty and breaks the release pipeline.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors version parsing/comparison in scripts/release-beta.ts and introduces a ReleaseSummary type intended to summarize stable/beta release metadata for the release workflow.

Changes:

  • Added ReleaseSummary and summarizeReleases() to compute latest stable/beta and totals.
  • Refactored compareVersions, extractStableVersion, and extractBetaVersion implementations.
  • Replaced the prior release-beta script entrypoint logic with a hard-coded “Example usage” block that logs a summary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/release-beta.ts
Comment on lines +162 to +170
// Example usage
const releases: GitHubRelease[] = [
{ tag_name: "open-design-v1.2.0" },
{ tag_name: "open-design-v1.3.0-beta.1" },
{ tag_name: "open-design-v1.3.0-beta.2" },
{ tag_name: "open-design-v1.1.5" },
];

const betaVersion = `${packagedVersion}-beta.${betaNumber}`;
const unsignedSuffix = signed ? "" : ".unsigned";
const versionTag = `open-design-v${betaVersion}${unsignedSuffix}`;
const branch = process.env.GITHUB_REF_NAME ?? "";
const commit = process.env.GITHUB_SHA ?? "";
const releaseName = `Open Design Beta ${betaVersion}${signed ? "" : " (unsigned)"}`;

console.log(`[release-beta] channel: beta`);
console.log(`[release-beta] base version: ${packagedVersion}`);
console.log(`[release-beta] beta version: ${betaVersion}`);
console.log(`[release-beta] signed: ${signed ? "true" : "false"}`);
console.log(`[release-beta] fixed beta tag: ${BETA_TAG}`);
console.log(`[release-beta] immutable beta tag: ${versionTag}`);
if (latestStable != null) console.log(`[release-beta] latest stable: ${latestStable.value}`);

setOutput("asset_version_suffix", unsignedSuffix);
setOutput("base_version", packagedVersion);
setOutput("beta_number", String(betaNumber));
setOutput("beta_tag", BETA_TAG);
setOutput("beta_version", betaVersion);
setOutput("branch", branch);
setOutput("commit", commit);
setOutput("latest_stable", latestStable?.value ?? "");
setOutput("release_name", releaseName);
setOutput("signed", signed ? "true" : "false");
setOutput("version_tag", versionTag);
console.log(summarizeReleases(releases));
Comment thread scripts/release-beta.ts
Comment on lines +94 to 110
function extractBetaVersion(release: GitHubRelease): ParsedBetaVersion | null {
const values = [release.tag_name, release.name].filter(
(item): item is string => typeof item === "string",
);

if (!stableVersionPattern.test(packageJson.version)) {
fail(`apps/packaged/package.json version must be a stable x.y.z base version; got ${packageJson.version}`);
}
for (const item of values) {
const found = betaTagPattern.exec(item) ?? betaVersionPattern.exec(item);

return packageJson.version;
}
if (!found) continue;

async function fetchReleases(repository: string): Promise<GitHubRelease[]> {
const releases: GitHubRelease[] = [];
for (let page = 1; ; page += 1) {
const { stdout } = await execFile("gh", ["api", `repos/${repository}/releases?per_page=100&page=${page}`]);
const batch = JSON.parse(stdout) as GitHubRelease[];
if (batch.length === 0) break;
releases.push(...batch);
return {
baseVersion: found[1],
betaNumber: Number(found[2]),
betaVersion: `${found[1]}-beta.${found[2]}`,
};
}
return releases;
}

Comment thread scripts/release-beta.ts
Comment on lines +63 to 67
for (let i = 0; i < 3; i++) {
if (left[i] > right[i]) return 1;
if (left[i] < right[i]) return -1;
}

Comment thread scripts/release-beta.ts
Comment on lines +120 to +133
for (const release of releases) {
const stable = extractStableVersion(release);
const beta = extractBetaVersion(release);

let latestStable: ParsedStableVersion | null = null;
for (const release of releases) {
if (release.draft === true || release.prerelease === true) continue;
if (stable) {
totalStable++;

const stableVersion = extractStableVersion(release);
if (stableVersion == null) continue;
if (
!latestStable ||
compareVersions(stable.parsed, latestStable.parsed) > 0
) {
latestStable = stable;
}
}
@lefarcen
Copy link
Copy Markdown
Contributor

Hi @krataratha! 🎉
Thanks for the contribution — clean refactoring of the version-handling logic and introducing the ReleaseSummary type looks like a good structural improvement.
I will run a deep review and get back to you within 24h.

Thanks for making open-design better!
— open-design team

@lefarcen lefarcen added the enhancement New feature or request label Apr 30, 2026
Copy link
Copy Markdown
Contributor

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @krataratha, thanks for looking at version handling! However, this PR removes the entire release workflow logic that was just added in #170 (1 hour ago) and replaces it with a non-functional example block.

P1 Critical Issue

Missing entrypoint: The diff deletes lines 91-256 of the original script — all the code that:

  • Reads GITHUB_REPOSITORY / GITHUB_OUTPUT env vars
  • Calls readPackagedVersion() / fetchReleases()
  • Computes the next beta number
  • Validates version constraints (packaged > latest stable)
  • Sets GitHub Actions outputs (beta_version, version_tag, signed, etc.)

Without this logic, the release workflow will fail — the script now just logs a hardcoded example and exits.

What needs to happen

If the goal is to refactor helper functions (compareVersions, extractStableVersion, extractBetaVersion) + add ReleaseSummary type:

  1. Keep the entrypoint (lines 91-256 in the original file)
  2. Refactor only the helper functions
  3. If ReleaseSummary is meant for future use, add it without removing existing logic

Or clarify: is this PR meant to be a spike / prototype that shouldn't land on main?


Let me know if you'd like help preserving the entrypoint while applying your refactorings — happy to collaborate!

Comment thread scripts/release-beta.ts
{ tag_name: "open-design-v1.3.0-beta.2" },
{ tag_name: "open-design-v1.1.5" },
];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: This replaces the entire release entrypoint with a toy example.

The original script (lines 91-256) was the CI entrypoint — it read env vars, fetched GitHub releases, computed the next beta version, validated constraints, and set Actions outputs.

Removing it breaks the release workflow. If you want to refactor, keep the entrypoint and refactor around it.

@lefarcen
Copy link
Copy Markdown
Contributor

lefarcen commented May 2, 2026

Hi @krataratha!

Just checking in — it's been about 37h since your last update, and there are still some review comments to address.

No rush if you're busy. If anything in the feedback was unclear or you'd like a specific suggestion, just reply here. If you've moved on, feel free to close the PR.

Thanks for the contribution!
— open-design team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants