Implement TODO functions: createDistTarGz and createReleasePR
Co-authored-by: louislam <1336778+louislam@users.noreply.github.com>
This commit is contained in:
parent
c0f034bb65
commit
f03b27c8c7
2
.github/workflows/beta-release.yml
vendored
2
.github/workflows/beta-release.yml
vendored
@ -69,7 +69,7 @@ jobs:
|
|||||||
- name: Run release-beta
|
- name: Run release-beta
|
||||||
env:
|
env:
|
||||||
RELEASE_BETA_VERSION: ${{ inputs.version }}
|
RELEASE_BETA_VERSION: ${{ inputs.version }}
|
||||||
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 }}
|
||||||
run: npm run release-beta
|
run: npm run release-beta
|
||||||
|
|||||||
@ -51,7 +51,7 @@ execSync("node ./extra/beta/update-version.js");
|
|||||||
// Build frontend dist
|
// Build frontend dist
|
||||||
buildDist();
|
buildDist();
|
||||||
|
|
||||||
// TODO: Create Pull Request
|
// Create Pull Request
|
||||||
await createReleasePR(version, previousVersion, dryRun);
|
await createReleasePR(version, previousVersion, dryRun);
|
||||||
|
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
@ -75,5 +75,5 @@ if (!dryRun) {
|
|||||||
console.log("Dry run mode - skipping image build and push.");
|
console.log("Dry run mode - skipping image build and push.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Create
|
// Create dist.tar.gz
|
||||||
await createDistTarGz();
|
await createDistTarGz();
|
||||||
|
|||||||
@ -24,6 +24,7 @@ export function checkDocker() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Docker Hub repository name
|
* Get Docker Hub repository name
|
||||||
|
* @returns {string[]} List of repository names
|
||||||
*/
|
*/
|
||||||
export function getRepoNames() {
|
export function getRepoNames() {
|
||||||
if (process.env.RELEASE_REPO_NAMES) {
|
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<void>}
|
||||||
*/
|
*/
|
||||||
export async function createDistTarGz() {
|
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
|
* Create a draft release PR
|
||||||
* @param version
|
* @param {string} version Version
|
||||||
* @param previousVersion
|
* @param {string} previousVersion Previous version tag
|
||||||
* @param 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
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function createReleasePR(version, previousVersion, dryRun) {
|
export async function createReleasePR(version, previousVersion, dryRun) {
|
||||||
const changelog = await generateChangelog(previousVersion);
|
const changelog = await generateChangelog(previousVersion);
|
||||||
|
|
||||||
// TODO
|
const title = dryRun ? `[DRY RUN] Update to ${version}` : `Update to ${version}`;
|
||||||
// gh pr create \
|
const body = `## Beta Release ${version}
|
||||||
// --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 }}" \
|
This PR prepares the beta release for version ${version}.
|
||||||
// --base master \
|
|
||||||
// --head release \
|
### Changelog
|
||||||
// --draft
|
|
||||||
|
${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");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user