Skip to content

Commit

Permalink
Publish "canary" for main, "experimental" for PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpetryk committed Mar 25, 2024
1 parent 2caa922 commit 9155b5f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/publish-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ 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))

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 },
})

0 comments on commit 9155b5f

Please sign in to comment.