-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8fe25f
commit 3916d5b
Showing
8 changed files
with
99 additions
and
54 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
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
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
#! /usr/bin/env node | ||
const { spawn } = require("child_process"); | ||
const { lernaScopeArgs } = require("./github.js"); | ||
|
||
spawn("lerna", ["run", "build", ...lernaScopeArgs], { stdio: "inherit" }); |
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,36 @@ | ||
#! /usr/bin/env node | ||
const { execSync } = require("child_process"); | ||
const { basename } = require("path"); | ||
|
||
const [, packageFromRef, versionFromRef, , prerelease] = | ||
/^refs\/tags\/(.+)-v(\d\d*\.\d\d*(\.\d\d*)?(-.+)?)$/.exec(process.env.GITHUB_REF ?? "") ?? []; | ||
|
||
const lernaList = JSON.parse( | ||
execSync(`lerna list --json ${packageFromRef ? "" : "--since"}`, { | ||
stdio: ["ignore", "pipe", "ignore"], | ||
}).toString(), | ||
); | ||
|
||
const ref = process.env.GITHUB_SHA ?? "HEAD"; | ||
const shortSHA = execSync(`git rev-parse --short ${ref}`).toString().trim(); | ||
|
||
const filteredLernaList = lernaList.filter((lerna) => { | ||
if (lerna.private) return false; | ||
if (packageFromRef && packageFromRef !== basename(lerna.location)) return false; | ||
return true; | ||
}); | ||
|
||
if (packageFromRef && filteredLernaList.length === 0) { | ||
throw new Error(`Lerna didn't find ${packageFromRef} in this workspace`); | ||
} | ||
|
||
const lernaScopeArgs = filteredLernaList.map(({ name }) => ["--scope", name]).flat(); | ||
|
||
module.exports = { | ||
packageFromRef, | ||
versionFromRef, | ||
prerelease: !packageFromRef || !!prerelease, | ||
filteredLernaList, | ||
shortSHA, | ||
lernaScopeArgs, | ||
}; |
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,36 @@ | ||
#! /usr/bin/env node | ||
const { execSync } = require("child_process"); | ||
const { writeFileSync, readFileSync } = require("fs"); | ||
const { join } = require("path"); | ||
const { filteredLernaList, versionFromRef, shortSHA, prerelease } = require("./github.js"); | ||
|
||
const wombatDressingRoomTokens = new Map([ | ||
// Disabling this until I can get wombat access to this org | ||
// ['firebase-frameworks', process.env.FIREBASE_FRAMEWORKS_NPM_TOKEN], | ||
// ['@apphosting/adapter-nextjs', process.env.ADAPTER_NEXTJS_NPM_TOKEN], | ||
]); | ||
|
||
wombatDressingRoomTokens.forEach((token, pkg) => { | ||
writeFileSync(".npmrc", `//wombat-dressing-room.appspot.com/${pkg}/:_authToken=${token}\n`, { | ||
flag: "a+", | ||
}); | ||
}); | ||
|
||
for (const lerna of filteredLernaList) { | ||
if (versionFromRef && versionFromRef.split("-")[0] !== lerna.version) { | ||
throw new Error( | ||
`Cowardly refusing to publish ${lerna.name}@${versionFromRef} from ${lerna.version}, version needs to be bumped in source.`, | ||
); | ||
} | ||
const version = versionFromRef || `${lerna.version}-canary.${shortSHA}`; | ||
const cwd = lerna.location; | ||
const tag = versionFromRef ? (prerelease ? "next" : "latest") : "canary"; | ||
const packageJsonPath = join(lerna.location, "package.json"); | ||
const packageJson = JSON.parse(readFileSync(packageJsonPath).toString()); | ||
packageJson.version = version; | ||
writeFileSync(packageJsonPath, JSON.stringify(packageJson, undefined, 2)); | ||
const registry = wombatDressingRoomTokens.get(lerna.name) | ||
? `https://wombat-dressing-room.appspot.com/${lerna.name}/_ns` | ||
: "https://registry.npmjs.org"; | ||
execSync(`npm publish --registry ${registry} --access public --tag ${tag} --provenance`, { cwd }); | ||
} |
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,5 @@ | ||
#! /usr/bin/env node | ||
const { spawn } = require("child_process"); | ||
const { lernaScopeArgs } = require("./github.js"); | ||
|
||
spawn("lerna", ["run", "test", "--verbose", "--no-bail", ...lernaScopeArgs], { stdio: "inherit" }); |