diff --git a/.github/workflows/es-yearly-globals.yml b/.github/workflows/es-yearly-globals.yml new file mode 100644 index 0000000..8cdf329 --- /dev/null +++ b/.github/workflows/es-yearly-globals.yml @@ -0,0 +1,24 @@ +name: Create ES yearly globals + +on: + workflow_dispatch: + schedule: + # β€œAt 00:00 on day-of-month 1 in July.” https://crontab.guru/#0_0_1_7_* + - cron: "0 0 1 7 *" + +jobs: + update: + if: github.event_name != 'schedule' || github.repository == 'sindresorhus/globals' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - run: npm install + - run: node scripts/create-yearly-es-globals.mjs + - run: npm run build + - uses: peter-evans/create-pull-request@v6 + with: + commit-message: Add `es2026` globals + branch: automated-es-yearly-globals + branch-suffix: timestamp + title: Add `es2026` globals diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index beaef7d..d62f4aa 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -20,7 +20,7 @@ jobs: - run: npm run update - uses: peter-evans/create-pull-request@v6 with: - commit-message: Update + commit-message: Update globals branch: automated-update branch-suffix: timestamp title: Update globals diff --git a/scripts/create-yearly-es-globals.mjs b/scripts/create-yearly-es-globals.mjs new file mode 100644 index 0000000..828c1b7 --- /dev/null +++ b/scripts/create-yearly-es-globals.mjs @@ -0,0 +1,21 @@ +import fs from 'node:fs'; + +const year = new Date().getFullYear(); +const dataFile = new URL(`../data/es${year + 1}.mjs`, import.meta.url); +const workflowFile = new URL('../.github/workflows/es-yearly-globals.yml', import.meta.url); + +fs.writeFileSync( + dataFile, + `export {default} from './es${year}.mjs';\n`, +); + +fs.writeFileSync( + workflowFile, + fs.readFileSync(workflowFile, 'utf8') + .replaceAll( + `Add \`es${year + 1}\` globals`, + `Add \`es${year + 2}\` globals`, + ), +); + +console.log(`βœ… es${year + 1} globals added, see you next year.`);