From 9155b5f2a04080ca0df5190aa776e581522cb809 Mon Sep 17 00:00:00 2001 From: Steven Petryk Date: Sun, 24 Mar 2024 21:59:26 -0700 Subject: [PATCH] Publish "canary" for main, "experimental" for PRs --- scripts/publish-branch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/publish-branch.ts b/scripts/publish-branch.ts index bbf2988e..dcb5e82b 100644 --- a/scripts/publish-branch.ts +++ b/scripts/publish-branch.ts @@ -2,13 +2,13 @@ import childProcess from "node:child_process" import fs from "node:fs" const shortCommit = childProcess.execSync("git rev-parse --short HEAD", { encoding: "utf8" }).trim() +const branch = childProcess.execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" }).trim() +const tag = branch === "main" ? "canary" : "experimental" const version = `0.0.0-${shortCommit}` console.log(`Publishing ${version} to npm...`) -console.log("NPM_TOKEN", process.env.NPM_TOKEN?.length) - const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8")) packageJson.version = version fs.writeFileSync("package.json", JSON.stringify(packageJson, null, 2)) @@ -16,7 +16,7 @@ fs.writeFileSync("package.json", JSON.stringify(packageJson, null, 2)) fs.writeFileSync(".npmrc", "//registry.npmjs.org/:_authToken=${NPM_TOKEN}") childProcess.execSync("pnpm build", { stdio: "inherit" }) -childProcess.execSync("npm publish --ignore-scripts --access public --tag experimental", { +childProcess.execSync(`npm publish --ignore-scripts --access public --tag ${tag}`, { stdio: "inherit", env: { ...process.env }, })