Skip to content

Commit

Permalink
[code-infra] Automate canary releases (mui#43066)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored Jul 31, 2024
1 parent 4a82b6b commit 9b04e74
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
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

0 comments on commit 9b04e74

Please sign in to comment.