Skip to content

Commit 2b737eb

Browse files
committed
chore: release 0.0.2
1 parent b286cb6 commit 2b737eb

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

scripts/release.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ async function main(): Promise<void> {
4646

4747
await publishTypeScriptPackages(publishableTypeScriptPackages, version);
4848
await publishRustPackages(publishableRustPackages, version);
49+
50+
await createGitHubRelease(version);
4951
}
5052

5153
function isValidVersion(version: string): boolean {
@@ -127,6 +129,7 @@ async function updateCargoToml(filePath: string, version: string): Promise<void>
127129
let inPackageSection = false;
128130
let inWorkspacePackageSection = false;
129131
let updated = false;
132+
let hasWorkspaceVersion = false;
130133

131134
const updatedLines = lines.map(line => {
132135
const trimmed = line.trim();
@@ -137,7 +140,13 @@ async function updateCargoToml(filePath: string, version: string): Promise<void>
137140
return line;
138141
}
139142

140-
if (inPackageSection || inWorkspacePackageSection) {
143+
// Check for version.workspace = true (skip these files)
144+
if (inPackageSection && trimmed === 'version.workspace = true') {
145+
hasWorkspaceVersion = true;
146+
return line;
147+
}
148+
149+
if ((inPackageSection || inWorkspacePackageSection) && !hasWorkspaceVersion) {
141150
const match = line.match(/^(\s*version\s*=\s*")([^\"]*)(".*)$/);
142151
if (match) {
143152
updated = true;
@@ -155,6 +164,12 @@ async function updateCargoToml(filePath: string, version: string): Promise<void>
155164
return line;
156165
});
157166

167+
// For workspace members, we don't update the version but might still update dependencies
168+
if (hasWorkspaceVersion && !updated) {
169+
console.log(`${relative(filePath)} uses workspace version`);
170+
return;
171+
}
172+
158173
if (!updated) {
159174
console.warn(`Skipping ${relative(filePath)} (no version field found)`);
160175
return;
@@ -502,13 +517,20 @@ async function createAndPushCommit(version: string): Promise<void> {
502517
await runCommand('git', ['add', '--all'], repoRoot);
503518
await runCommand('git', ['commit', '-m', `chore: release ${version}`], repoRoot);
504519
await runCommand('git', ['push'], repoRoot);
505-
506-
await createGitHubRelease(version);
507520
}
508521

509522
async function createGitHubRelease(version: string): Promise<void> {
510523
console.log(`Creating GitHub release for v${version}`);
511524

525+
// Check if release already exists
526+
try {
527+
await captureCommand('gh', ['release', 'view', `v${version}`], repoRoot);
528+
console.log(`GitHub release v${version} already exists, skipping`);
529+
return;
530+
} catch {
531+
// Release doesn't exist, proceed with creation
532+
}
533+
512534
const isPrerelease = version.includes('-rc.') || version.includes('-alpha.') || version.includes('-beta.');
513535
const releaseArgs = ['release', 'create', `v${version}`, '--title', `v${version}`, '--generate-notes'];
514536

0 commit comments

Comments
 (0)