summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json2
-rw-r--r--packages/cli/src/ui/hooks/useLoadingIndicator.test.ts2
-rw-r--r--scripts/tag-release.js58
3 files changed, 60 insertions, 2 deletions
diff --git a/package.json b/package.json
index 128c74a6..57d57b68 100644
--- a/package.json
+++ b/package.json
@@ -51,7 +51,7 @@
"publish:release": "npm run prepare:package && npm run build:packages && npm run build:sandbox:fast && npm run publish:sandbox && npm run publish:npm",
"prepublishOnly": "node scripts/check-versions.js && node scripts/prepublish.js",
"release:version": "node scripts/version.js",
- "tag:release:nightly": "TAG_NAME=\"v$(node -p \"require('./package.json').version\")-nightly.$(date -u +%y%m%d).$(git rev-parse --short HEAD)\"; git tag -a $TAG_NAME -m '' && git push origin $TAG_NAME",
+ "tag:release:nightly": "node scripts/tag-release.js",
"check:versions": "node scripts/check-versions.js",
"publish:actions-release": "npm run prepare:package && npm run build:packages && npm run publish:npm"
},
diff --git a/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts b/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
index 7a2027f3..5c1d44ef 100644
--- a/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
+++ b/packages/cli/src/ui/hooks/useLoadingIndicator.test.ts
@@ -44,7 +44,7 @@ describe('useLoadingIndicator', () => {
const initialPhrase = result.current.currentLoadingPhrase;
await act(async () => {
- await vi.advanceTimersByTimeAsync(PHRASE_CHANGE_INTERVAL_MS);
+ await vi.advanceTimersByTimeAsync(PHRASE_CHANGE_INTERVAL_MS + 1);
});
// Phrase should cycle if PHRASE_CHANGE_INTERVAL_MS has passed
diff --git a/scripts/tag-release.js b/scripts/tag-release.js
new file mode 100644
index 00000000..40385264
--- /dev/null
+++ b/scripts/tag-release.js
@@ -0,0 +1,58 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { execSync } from 'child_process';
+import { readFileSync } from 'fs';
+import path from 'path';
+
+function getVersion() {
+ const packageJsonPath = path.resolve(process.cwd(), 'package.json');
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
+ return packageJson.version;
+}
+
+function getShortSha() {
+ return execSync('git rev-parse --short HEAD').toString().trim();
+}
+
+function getNightlyTagName() {
+ const version = getVersion();
+ const now = new Date();
+ const year = now.getUTCFullYear().toString().slice(-2);
+ const month = (now.getUTCMonth() + 1).toString().padStart(2, '0');
+ const day = now.getUTCDate().toString().padStart(2, '0');
+ const date = `${year}${month}${day}`;
+
+ const sha = getShortSha();
+ return `v${version}-nightly.${date}.${sha}`;
+}
+
+function createAndPushTag(tagName, isSigned) {
+ const command = isSigned
+ ? `git tag -s -a ${tagName} -m ''`
+ : `git tag ${tagName}`;
+
+ try {
+ console.log(`Executing: ${command}`);
+ execSync(command, { stdio: 'inherit' });
+ console.log(`Successfully created tag: ${tagName}`);
+
+ console.log(`Pushing tag to origin...`);
+ execSync(`git push origin ${tagName}`, { stdio: 'inherit' });
+ console.log(`Successfully pushed tag: ${tagName}`);
+ } catch (error) {
+ console.error(`Failed to create or push tag: ${tagName}`);
+ console.error(error);
+ process.exit(1);
+ }
+}
+
+const tagName = getNightlyTagName();
+// In GitHub Actions, the CI variable is set to true.
+// We will create a signed commit if not in a CI environment.
+const shouldSign = !process.env.CI;
+
+createAndPushTag(tagName, shouldSign);