feat: Added script for creating GH releases
This commit is contained in:
parent
6f7043d547
commit
5269660adc
6 changed files with 79 additions and 13 deletions
|
|
@ -31,7 +31,7 @@
|
||||||
"docs:generate": "pnpm --filter @prozilla-os/docs run generate",
|
"docs:generate": "pnpm --filter @prozilla-os/docs run generate",
|
||||||
"packages:build": "pnpm -r --sequential --filter prozilla-os... build",
|
"packages:build": "pnpm -r --sequential --filter prozilla-os... build",
|
||||||
"packages:update": "npx changeset && pnpm changeset version",
|
"packages:update": "npx changeset && pnpm changeset version",
|
||||||
"packages:release": "pnpm changeset publish"
|
"packages:release": "pnpm changeset publish && pnpm vite-node scripts/releasePackage.ts"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
"url": "git+https://github.com/prozilla-os/ProzillaOS.git"
|
"url": "git+https://github.com/prozilla-os/ProzillaOS.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"commander": "^12.1.0",
|
||||||
"pnpm": "^9.5.0"
|
"pnpm": "^9.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
import { UserConfig } from "vite";
|
|
||||||
/**
|
|
||||||
* Helper function for creating Vite configurations for ProzillaOS apps
|
|
||||||
* @param basePath - Path of base directory
|
|
||||||
* @param entryPath - Path of library entry
|
|
||||||
* @returns Vite configuration
|
|
||||||
* @see https://vitejs.dev/config/
|
|
||||||
*/
|
|
||||||
export declare const appViteConfig: (basePath: string, entryPath: string) => UserConfig;
|
|
||||||
1
packages/shared/src/configs/index.d.ts
vendored
1
packages/shared/src/configs/index.d.ts
vendored
|
|
@ -1 +0,0 @@
|
||||||
export { appViteConfig } from "./app.vite.config";
|
|
||||||
|
|
@ -8,6 +8,9 @@ importers:
|
||||||
|
|
||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
commander:
|
||||||
|
specifier: ^12.1.0
|
||||||
|
version: 12.1.0
|
||||||
pnpm:
|
pnpm:
|
||||||
specifier: ^9.5.0
|
specifier: ^9.5.0
|
||||||
version: 9.5.0
|
version: 9.5.0
|
||||||
|
|
@ -2014,6 +2017,10 @@ packages:
|
||||||
resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==}
|
resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==}
|
||||||
engines: {node: '>=16'}
|
engines: {node: '>=16'}
|
||||||
|
|
||||||
|
commander@12.1.0:
|
||||||
|
resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
commander@8.3.0:
|
commander@8.3.0:
|
||||||
resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==}
|
resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==}
|
||||||
engines: {node: '>= 12'}
|
engines: {node: '>= 12'}
|
||||||
|
|
@ -5567,6 +5574,8 @@ snapshots:
|
||||||
|
|
||||||
commander@11.1.0: {}
|
commander@11.1.0: {}
|
||||||
|
|
||||||
|
commander@12.1.0: {}
|
||||||
|
|
||||||
commander@8.3.0: {}
|
commander@8.3.0: {}
|
||||||
|
|
||||||
commander@9.5.0:
|
commander@9.5.0:
|
||||||
|
|
|
||||||
65
scripts/releasePackage.ts
Normal file
65
scripts/releasePackage.ts
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { execSync } from "node:child_process";
|
||||||
|
import { version, name } from "../packages/prozilla-os/package.json";
|
||||||
|
import os from "node:os";
|
||||||
|
import { ANSI } from "../packages/core/src/constants";
|
||||||
|
|
||||||
|
const getChangelog = (): string => {
|
||||||
|
const changelogPath = path.resolve(__dirname, "../packages/prozilla-os/CHANGELOG.md");
|
||||||
|
const changelog = fs.readFileSync(changelogPath, "utf-8");
|
||||||
|
|
||||||
|
const changelogEntries = changelog.split("\n## ");
|
||||||
|
|
||||||
|
const changelogEntry = changelogEntries.find((entry) => entry.startsWith(version));
|
||||||
|
|
||||||
|
if (changelogEntry) {
|
||||||
|
return changelogEntry;
|
||||||
|
} else {
|
||||||
|
return `No changelog entry found for version ${version}`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const createGitHubRelease = (): void => {
|
||||||
|
const changelogFilePath = path.join(os.tmpdir(), `CHANGELOG-${version}.md`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log(`Context: ${ANSI.decoration.bold}${name}${ANSI.reset}\n`);
|
||||||
|
|
||||||
|
const changelog = getChangelog();
|
||||||
|
const tagName = `prozilla-os@${version}`;
|
||||||
|
const releaseTitle = `Release ${version}`;
|
||||||
|
|
||||||
|
// Write changelog to a temporary file
|
||||||
|
fs.writeFileSync(changelogFilePath, changelog);
|
||||||
|
|
||||||
|
// Push all tags, not recommended
|
||||||
|
console.log(`${ANSI.fg.yellow}Pushing tags...${ANSI.reset}`);
|
||||||
|
execSync("git push --tags", {
|
||||||
|
stdio: "inherit"
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a new release
|
||||||
|
console.log(`${ANSI.fg.yellow}Creating release...${ANSI.reset}`);
|
||||||
|
execSync(`gh release create ${tagName} --title "${releaseTitle}" --notes-file "${changelogFilePath}"`, {
|
||||||
|
stdio: "inherit"
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`\n${ANSI.fg.green}✓ Release created:${ANSI.reset} ${releaseTitle}`);
|
||||||
|
} catch (error) {
|
||||||
|
if ((error as Record<string, string>).stdout) {
|
||||||
|
console.error((error as Record<string, string>).stdout.toString());
|
||||||
|
}
|
||||||
|
if ((error as Record<string, string>).stderr) {
|
||||||
|
console.error((error as Record<string, string>).stderr.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(`${ANSI.fg.red}⚠ Failed to create release:${ANSI.reset} ${(error as Error).message}`);
|
||||||
|
process.exit(1);
|
||||||
|
} finally {
|
||||||
|
// Clean up the temporary file
|
||||||
|
fs.unlinkSync(changelogFilePath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
createGitHubRelease();
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
/* Modules */
|
/* Modules */
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
"types": ["vite/client", "vite-plugin-svgr/client"],
|
"types": ["vite/client", "vite-plugin-svgr/client", "node"],
|
||||||
"allowUmdGlobalAccess": true,
|
"allowUmdGlobalAccess": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|
||||||
|
|
@ -35,7 +35,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"packages/**/*"
|
"packages/**/*",
|
||||||
|
"scripts/**/*"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"**/node_modules/**/*",
|
"**/node_modules/**/*",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue