Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code-infra] Automate canary releases #43066

Merged
merged 10 commits into from
Jul 31, 2024
23 changes: 23 additions & 0 deletions .github/workflows/publish-canaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish canary packages to npm

on:
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Set up pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
- name: Use Node.js 18.x
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 18
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
- run: pnpm install
- run: pnpm canary:release --ignore @mui/icons-material --yes
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
11 changes: 1 addition & 10 deletions scripts/canaryRelease.mts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,7 @@ async function setVersion(packages: PackageInfo[]) {
const packageJsonPath = resolve(pkg.path, './package.json');
try {
const packageJson = JSON.parse(await readFile(packageJsonPath, { encoding: 'utf8' }));
const version = packageJson.version;
const dashIndex = version.indexOf('-');
let newVersion = version;
if (dashIndex !== -1) {
newVersion = version.slice(0, dashIndex);
}

newVersion = `${newVersion}-dev.${timestamp}-${currentRevisionSha}`;
packageJson.version = newVersion;

packageJson.version = `${packageJson.version}-dev.${timestamp}-${currentRevisionSha}`;
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
} catch (error) {
console.error(`${chalk.red(`❌ ${packageJsonPath}`)}`, error);
Expand Down