Skip to content

Commit c3edad5

Browse files
authored
[code-infra] Add publishing (#328)
1 parent b7c613b commit c3edad5

File tree

9 files changed

+2736
-94
lines changed

9 files changed

+2736
-94
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
# Renovate branches are always Pull Requests.
7+
# We don't need to run CI twice (push+pull_request)
8+
- 'renovate/**'
9+
- 'dependabot/**'
10+
11+
permissions: {}
12+
13+
jobs:
14+
continuous-releases:
15+
runs-on: ubuntu-latest
16+
# do not run on forks
17+
if: github.repository == 'mui/mui-public'
18+
steps:
19+
- run: echo "${{ github.actor }}"
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
fetch-depth: 0
23+
- name: Set up pnpm
24+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
25+
- name: Use Node.js 20.x
26+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
27+
with:
28+
node-version: 20
29+
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
30+
- run: pnpm release:prepare
31+
- run: pnpm release:build
32+
- run: pnpm pkg-pr-new-release

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,21 @@ Internal public Toolpad apps that run the operations of MUI, built using https:/
1818
- Folder: `/apps/code-infra-dashboard/`
1919
- Hosting: https://app.netlify.com/sites/mui-frontend-public/overview
2020
- [Docs](./apps/code-infra-dashboard/#readme)
21+
22+
## Versioning
23+
24+
Steps:
25+
26+
1. Checkout latest master
27+
1. Run `pnpm release:prepare`
28+
1. Run `pnpm release:version`
29+
1. Open PR with the changes
30+
31+
## Publishing
32+
33+
Steps:
34+
35+
1. Merge versioning PR
36+
1. Checkout release commit on master
37+
1. Run `pnpm release:prepare`
38+
1. Run `pnpm release:publish`

lerna.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3+
"version": "independent",
4+
"npmClient": "pnpm"
5+
}

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
"eslint:ci": "eslint . --report-unused-disable-directives --ext .js,.ts,.tsx --max-warnings 0",
88
"prettier": "pretty-quick --ignore-path .eslintignore",
99
"prettier:all": "prettier --write . --ignore-path .eslintignore",
10-
"update-netlify-ignore": "node ./update-netlify-ignore.js code-infra-dashboard"
10+
"update-netlify-ignore": "node ./update-netlify-ignore.js code-infra-dashboard",
11+
"release:prepare": "pnpm install && pnpm release:build",
12+
"release:version": "lerna version --no-changelog --no-push --no-git-tag-version --no-private",
13+
"release:build": "pnpm --filter \"./packages/**\" run build",
14+
"release:publish": "pnpm publish --recursive --tag latest",
15+
"pkg-pr-new-packages": "pnpm ls -r --parseable --depth -1 -F \"./packages/**\"",
16+
"pkg-pr-new-release": "pnpm dlx pkg-pr-new publish $(pnpm -s pkg-pr-new-packages) --pnpm --comment=off --peerDeps --compact"
1117
},
1218
"devDependencies": {
1319
"@actions/core": "^1.10.1",
@@ -32,6 +38,7 @@
3238
"eslint-plugin-react-hooks": "4.6.2",
3339
"eslint-plugin-testing-library": "^6.2.2",
3440
"eslint-plugin-typescript-enum": "2.1.0",
41+
"lerna": "^8.2.2",
3542
"prettier": "^3.3.3",
3643
"pretty-quick": "^4.0.0",
3744
"typescript": "^4.6.4"

packages/bundle-size-checker/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{
22
"name": "@mui/internal-bundle-size-checker",
3-
"version": "1.0.0",
4-
"private": true,
3+
"version": "1.0.2",
54
"description": "Bundle size checker for MUI packages.",
65
"type": "module",
76
"main": "./src/index.js",
87
"bin": {
98
"bundle-size-checker": "./bin/bundle-size-checker.js"
109
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/mui/mui-public.git",
13+
"directory": "packages/bundle-size-checker"
14+
},
1115
"scripts": {
1216
"typescript": "tsc -p tsconfig.json"
1317
},

packages/bundle-size-checker/src/configLoader.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import envCi from 'env-ci';
99
/**
1010
* Attempts to load and parse a single config file
1111
* @param {string} configPath - Path to the configuration file
12-
* @returns {Promise<BundleSizeCheckerConfig | null>} The parsed config or null if file doesn't exist
12+
* @returns {Promise<BundleSizeCheckerConfigObject | null>} The parsed config or null if file doesn't exist
1313
* @throws {Error} If the file exists but has invalid format
1414
*/
1515
async function loadConfigFile(configPath) {
@@ -20,20 +20,18 @@ async function loadConfigFile(configPath) {
2020

2121
// Dynamic import for ESM
2222
const configUrl = new URL(`file://${configPath}`);
23-
let { default: config } = await import(configUrl.href);
23+
const { default: config } = await import(configUrl.href);
2424

25+
/** @type {BundleSizeCheckerConfigObject | null} */
26+
let resolvedConfig = null;
2527
// Handle configs that might be Promise-returning functions
2628
if (config instanceof Promise) {
27-
config = await config;
29+
resolvedConfig = await config;
2830
} else if (typeof config === 'function') {
29-
config = await config();
31+
resolvedConfig = await config();
3032
}
3133

32-
if (!config.entrypoints || !Array.isArray(config.entrypoints)) {
33-
throw new Error('Configuration must include an entrypoints array');
34-
}
35-
36-
return config;
34+
return resolvedConfig;
3735
} catch (error) {
3836
console.error(`Error loading config from ${configPath}:`, error);
3937
throw error; // Re-throw to indicate failure
@@ -81,7 +79,7 @@ export function applyUploadConfigDefaults(uploadConfig, ciInfo) {
8179

8280
/**
8381
* Apply default values to the configuration using CI environment
84-
* @param {BundleSizeCheckerConfig} config - The loaded configuration
82+
* @param {BundleSizeCheckerConfigObject} config - The loaded configuration
8583
* @returns {NormalizedBundleSizeCheckerConfig} Configuration with defaults applied
8684
* @throws {Error} If required fields are missing
8785
*/

packages/bundle-size-checker/src/defineConfig.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* @typedef {Object} BundleSizeCheckerConfig
3-
* @property {string[]} entrypoints - Array of entrypoints to check size for
4-
*/
5-
61
/**
72
* Define a configuration for the bundle size checker.
83
* This is just a pass-through function for better TypeScript typing.

packages/bundle-size-checker/src/types.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ interface ObjectEntry {
5555
type EntryPoint = StringEntry | ObjectEntry;
5656

5757
// Bundle size checker config with optional upload config
58-
interface BundleSizeCheckerConfig {
58+
interface BundleSizeCheckerConfigObject {
5959
entrypoints: EntryPoint[];
6060
upload?: UploadConfig | boolean | null;
6161
}
6262

63+
type BundleSizeCheckerConfig =
64+
| BundleSizeCheckerConfigObject
65+
| Promise<BundleSizeCheckerConfigObject>
66+
| (() => BundleSizeCheckerConfigObject | Promise<BundleSizeCheckerConfigObject>);
67+
6368
// Normalized bundle size checker config with all properties defined
6469
interface NormalizedBundleSizeCheckerConfig {
6570
entrypoints: ObjectEntry[];

0 commit comments

Comments
 (0)