Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 62 additions & 58 deletions scripts/nx-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ const VALID_AUTHORS_FOR_LATEST = [
});
};

const packagesToReset = [
'packages/angular-rspack',
'packages/angular-rspack-compiler',
'packages/dotnet',
'packages/maven',
];

const packageSnapshots: { [key: string]: string } = {};
for (const packagePath of packagesToReset) {
const packageJsonPath = join(workspaceRoot, packagePath, 'package.json');
const packageJson = readFileSync(packageJsonPath, 'utf-8');
packageSnapshots[packagePath] = packageJson;
}

const resetPackageJsons = () => {
for (const packagePath of packagesToReset) {
const packageJsonPath = join(workspaceRoot, packagePath, 'package.json');
writeFileSync(packageJsonPath, packageSnapshots[packagePath]);
}
};

// Reset package.json files even on ctrl+C
process.on('SIGINT', () => {
console.log('\nReceived SIGINT, restoring package.json files...');
resetPackageJsons();
process.exit(1);
});

// Intended for creating a github release which triggers the publishing workflow
// This runs locally (not in CI) to create the GitHub release that triggers the actual publish workflow
if (!options.local && !process.env.GITHUB_ACTIONS) {
Expand All @@ -84,59 +112,50 @@ const VALID_AUTHORS_FOR_LATEST = [
});

if (isRelativeVersionKeyword(options.version)) {
resetPackageJsons();
throw new Error(
'When creating actual releases, you must use an exact semver version'
);
}

runNxReleaseVersion();
try {
runNxReleaseVersion();

execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER,
windowsHide: false,
});
execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER,
windowsHide: false,
});

let changelogCommand = `pnpm nx release changelog ${options.version} --interactive workspace`;
if (options.from) {
changelogCommand += ` --from ${options.from}`;
}
if (options.gitRemote) {
changelogCommand += ` --git-remote ${options.gitRemote}`;
}
if (options.dryRun) {
changelogCommand += ' --dry-run';
}
if (isVerboseLogging) {
changelogCommand += ' --verbose';
}
console.log(`> ${changelogCommand}`);
execSync(changelogCommand, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER,
windowsHide: false,
});
let changelogCommand = `pnpm nx release changelog ${options.version} --interactive workspace`;
if (options.from) {
changelogCommand += ` --from ${options.from}`;
}
if (options.gitRemote) {
changelogCommand += ` --git-remote ${options.gitRemote}`;
}
if (options.dryRun) {
changelogCommand += ' --dry-run';
}
if (isVerboseLogging) {
changelogCommand += ' --verbose';
}
console.log(`> ${changelogCommand}`);
execSync(changelogCommand, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER,
windowsHide: false,
});

console.log(
'Check github: https://github.com/nrwl/nx/actions/workflows/publish.yml'
);
console.log(
'Check github: https://github.com/nrwl/nx/actions/workflows/publish.yml'
);
} finally {
resetPackageJsons();
}
process.exit(0);
}

const packagesToReset = [
'packages/angular-rspack',
'packages/angular-rspack-compiler',
'packages/dotnet',
'packages/maven',
];

const packageSnapshots: { [key: string]: string } = {};
for (const packagePath of packagesToReset) {
const packageJsonPath = join(workspaceRoot, packagePath, 'package.json');
const packageJson = readFileSync(packageJsonPath, 'utf-8');
packageSnapshots[packagePath] = packageJson;
}

runNxReleaseVersion();

execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, {
Expand Down Expand Up @@ -228,22 +247,7 @@ const VALID_AUTHORS_FOR_LATEST = [
}

// TODO(colum): Remove when we have a better way to handle this

console.log(
'Resetting angular-rspack package.json versions to previous versions'
);

for (const packagePath of packagesToReset) {
const packageJsonPath = join(workspaceRoot, packagePath, 'package.json');
writeFileSync(packageJsonPath, packageSnapshots[packagePath]);
}

execSync(
`npx prettier --write packages/angular-rspack/package.json packages/angular-rspack-compiler/package.json`,
{
cwd: workspaceRoot,
}
);
resetPackageJsons();

process.exit(0);
})();
Expand Down
Loading