-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically publish PRs from non-forks (#148)
Collaborators can get a published npm package, as a treat.
- Loading branch information
1 parent
143bbca
commit 2caa922
Showing
5 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
"main": "build/index.js", | ||
"module": "build/index.mjs", | ||
"types": "build/index.d.ts", | ||
"type": "module", | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=18.0.0" | ||
|
@@ -31,7 +30,8 @@ | |
"lint": "eslint . --ext .js,.jsx,.ts,.tsx", | ||
"format": "prettier --write .", | ||
"format:check": "prettier --check .", | ||
"prepublishOnly": "pnpm test && pnpm lint && pnpm build" | ||
"prepublishOnly": "pnpm test && pnpm lint && pnpm build", | ||
"publish-branch": "tsx scripts/publish-branch.ts" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "7.40.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import childProcess from "node:child_process" | ||
import fs from "node:fs" | ||
|
||
const shortCommit = childProcess.execSync("git rev-parse --short HEAD", { encoding: "utf8" }).trim() | ||
|
||
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", { | ||
stdio: "inherit", | ||
env: { ...process.env }, | ||
}) |