Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@ jobs:
run: npm ci --legacy-peer-deps
- name: Build
run: npm run build:all
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
EOF
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create alpha release artifacts
run: node release-tools/pre-release.js
- name: Release alpha artifacts
run: npm publish --workspaces --tag alpha
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
27 changes: 26 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
},
"private": true,
"devDependencies": {
"@types/node": "22.19.3"
"@types/node": "22.19.3",
"commander": "14.0.0",
"zx": "8.5.4"
},
"workspaces": [
"packages/*"
Expand Down
42 changes: 42 additions & 0 deletions release-tools/pre-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* For every commit made, GitHub actions will release an alpha version to npm
* for each package in the yarn workspace.
*/
const { $, cd, glob } = require("zx");
const { readFileSync, writeFileSync } = require("fs");

async function main() {
const pathPrefix = ".";
const packages = await glob(`${pathPrefix}/packages/*`, {
deep: 1,
onlyDirectories: true,
});
$.verbose = true;
for (const dir of packages) {
const before = process.cwd();
cd(dir);
const packageJsonStr = readFileSync("package.json", {
encoding: "utf8",
});
const packageJson = JSON.parse(packageJsonStr);
const hash = new Date().getTime();
const newVersion = `${packageJson.version}-alpha-${hash}`;
packageJson.version = newVersion;
console.log(packageJson);
await writeFileSync("package.json", JSON.stringify(packageJson));
const output = await $({ nothrow: true })`yarn npm publish --tag alpha`;
console.log(output);
cd(before);
}
}

/**
* This script should only be run on GitHub actions. There is an explicit
* check for the GitHub actions environment to prevent this script from publishing
* versions from local environments.
*
* More info: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
*/
if (process.env.CI) {
main();
}