Nightly MCU release #253
This file contains hidden or 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
| name: Nightly MCU release | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| nightly-mcu: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout upstream | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: material-foundation/material-color-utilities | |
| path: upstream | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: latest | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| working-directory: upstream/typescript | |
| run: npm install | |
| - name: Add missing export | |
| working-directory: upstream/typescript | |
| run: | | |
| echo >> index.ts | |
| echo "export * from './dynamiccolor/contrast_curve.js';" >> index.ts | |
| - name: Fix TypeScript config for nightly | |
| working-directory: upstream/typescript | |
| run: | | |
| node -p " | |
| const config = require('./tsconfig.json'); | |
| config.compilerOptions.noUnusedLocals = false; | |
| config.compilerOptions.noUnusedParameters = false; | |
| JSON.stringify(config, null, 2); | |
| " > tsconfig.tmp.json | |
| mv tsconfig.tmp.json tsconfig.json | |
| - name: Build package | |
| working-directory: upstream/typescript | |
| run: npm run build | |
| - name: Fix import extensions for Node.js compatibility | |
| working-directory: upstream/typescript | |
| run: | | |
| # Add .js extensions to relative imports that don't already have them | |
| find . -name "*.js" -not -path "./node_modules/*" -exec sed -i "s|from '\(\.\.*/[^']*\)';|from '\1.js';|g" {} + | |
| # Clean up any double .js.js that resulted | |
| find . -name "*.js" -not -path "./node_modules/*" -exec sed -i "s|\.js\.js';|.js';|g" {} + | |
| - name: Update package.json for nightly | |
| working-directory: upstream/typescript | |
| run: | | |
| LAST_COMMIT_TIMESTAMP=$(git log -1 --format="%ct") node -p " | |
| const pkg = require('./package.json'); | |
| pkg.name = '@ktibow/material-color-utilities-nightly'; | |
| const lastCommit = parseInt(process.env.LAST_COMMIT_TIMESTAMP) * 1000; | |
| if (!lastCommit) throw new Error(`${process.env.LAST_COMMIT_TIMESTAMP} is not a valid timestamp`); | |
| pkg.version += lastCommit.toString(); | |
| pkg.sideEffects = false; | |
| delete pkg.scripts.prepublishOnly; | |
| JSON.stringify(pkg, null, 2); | |
| " > package.tmp.json | |
| mv package.tmp.json package.json | |
| env: | |
| NIGHTLY_VERSION: ${{ env.NIGHTLY_VERSION }} | |
| - name: Publish to npm | |
| working-directory: upstream/typescript | |
| run: npm publish --access public --tag latest || exit 0 | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |