From f03b27c8c7ab2b1ec293036bb90ac0acf56da9c8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 02:23:16 +0000 Subject: [PATCH] Implement TODO functions: createDistTarGz and createReleasePR Co-authored-by: louislam <1336778+louislam@users.noreply.github.com> --- .github/workflows/beta-release.yml | 2 +- extra/release/beta.mjs | 4 +- extra/release/lib.mjs | 94 +++++++++++++++++++++++++----- 3 files changed, 84 insertions(+), 16 deletions(-) diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index b48c1620d..b9522c5be 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -69,7 +69,7 @@ jobs: - name: Run release-beta env: RELEASE_BETA_VERSION: ${{ inputs.version }} - PREVIOUS_VERSION: ${{ inputs.previous_version }} + RELEASE_PREVIOUS_VERSION: ${{ inputs.previous_version }} DRY_RUN: ${{ inputs.dry_run }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npm run release-beta diff --git a/extra/release/beta.mjs b/extra/release/beta.mjs index 7072f44a0..3a11c4af0 100644 --- a/extra/release/beta.mjs +++ b/extra/release/beta.mjs @@ -51,7 +51,7 @@ execSync("node ./extra/beta/update-version.js"); // Build frontend dist buildDist(); -// TODO: Create Pull Request +// Create Pull Request await createReleasePR(version, previousVersion, dryRun); if (!dryRun) { @@ -75,5 +75,5 @@ if (!dryRun) { console.log("Dry run mode - skipping image build and push."); } -// TODO: Create +// Create dist.tar.gz await createDistTarGz(); diff --git a/extra/release/lib.mjs b/extra/release/lib.mjs index f0294b299..ade7e3765 100644 --- a/extra/release/lib.mjs +++ b/extra/release/lib.mjs @@ -24,6 +24,7 @@ export function checkDocker() { /** * Get Docker Hub repository name + * @returns {string[]} List of repository names */ export function getRepoNames() { if (process.env.RELEASE_REPO_NAMES) { @@ -266,26 +267,93 @@ export function checkReleaseBranch() { } /** - * TODO: similar to "tar -zcvf dist.tar.gz dist", but using nodejs + * Create dist.tar.gz from the dist directory + * Similar to "tar -zcvf dist.tar.gz dist", but using nodejs + * @returns {Promise} */ export async function createDistTarGz() { - // TODO + const fs = await import("fs"); + const tar = await import("tar"); + + const distPath = "dist"; + const outputPath = "dist.tar.gz"; + + // Check if dist directory exists + if (!fs.existsSync(distPath)) { + console.error("Error: dist directory not found"); + process.exit(1); + } + + console.log(`Creating ${outputPath} from ${distPath}...`); + + try { + await tar.create( + { + gzip: true, + file: outputPath, + }, + [ distPath ] + ); + console.log(`Successfully created ${outputPath}`); + } catch (error) { + console.error(`Failed to create tarball: ${error.message}`); + process.exit(1); + } } /** - * TODO: Create a draft release PR - * @param version - * @param previousVersion - * @param dryRun Still create the PR, but add "[DRY RUN]" to the title + * Create a draft release PR + * @param {string} version Version + * @param {string} previousVersion Previous version tag + * @param {boolean} dryRun Still create the PR, but add "[DRY RUN]" to the title + * @returns {Promise} */ export async function createReleasePR(version, previousVersion, dryRun) { const changelog = await generateChangelog(previousVersion); - // TODO - // gh pr create \ - // --title "Beta Release: ${{ inputs.version }}" \ - // --body "This PR prepares the beta release version ${{ inputs.version }}. \`dist.tar.gz\` : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ - // --base master \ - // --head release \ - // --draft + const title = dryRun ? `[DRY RUN] Update to ${version}` : `Update to ${version}`; + const body = `## Beta Release ${version} + +This PR prepares the beta release for version ${version}. + +### Changelog + +${changelog} + +### Release Artifacts + +The \`dist.tar.gz\` archive will be available as an artifact in the workflow run. + +--- + +**Note:** This PR was automatically created by the beta release workflow.`; + + // Create the PR using gh CLI + const args = [ + "pr", + "create", + "--title", title, + "--body", body, + "--base", "master", + "--head", "release", + "--draft" + ]; + + console.log(`Creating draft PR: ${title}`); + + const result = childProcess.spawnSync("gh", args, { + encoding: "utf-8", + stdio: "inherit", + env: { + ...process.env, + GH_TOKEN: process.env.GH_TOKEN || process.env.GITHUB_TOKEN, + } + }); + + if (result.status !== 0) { + console.error("Failed to create pull request"); + process.exit(1); + } + + console.log("Successfully created draft pull request"); }