diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5da95d2..d136433 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,31 +3,18 @@ name: Release Full on: workflow_dispatch: inputs: - version: - type: choice - description: "Release Version Type" - required: true - default: "patch" - options: - - major - - premajor - - minor - - preminor - - patch - - prepatch - - prerelease - tag: type: choice description: "Release Npm Tag" required: true - default: "latest" + default: "nightly" options: + - alpha + - beta - canary - - nightly - latest - - beta - - alpha + - nightly + - rc dry_run: type: boolean @@ -71,9 +58,10 @@ jobs: - name: Run Test run: pnpm run test - - name: Try release to npm - run: pnpm run release - env: - DRY_RUN: ${{ inputs.dry_run }} - TAG: ${{ inputs.tag }} - VERSION: ${{ inputs.version }} + - name: Dry run release to npm + if: inputs.dry_run + run: node scripts/release.mjs --dry-run --tag ${{ inputs.tag }} + + - name: Release to npm + if: ${{ !inputs.dry_run }} + run: node scripts/release.mjs --tag ${{ inputs.tag }} diff --git a/package.json b/package.json index 4ec251d..d68a43b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "lint:write": "biome check . --write", "prepare": "simple-git-hooks && npm run build", "test": "jest --colors", - "release": "node ./scripts/release.mjs" + "release": "node ./scripts/release.mjs", + "bump": "npx bumpp" }, "files": ["client", "dist", "exports"], "simple-git-hooks": { @@ -41,6 +42,8 @@ "@rspack/core": "1.4.11", "@types/jest": "29.5.14", "@types/node": "^22.17.0", + "bumpp": "^10.2.3", + "cac": "^6.7.14", "cross-env": "^10.0.0", "execa": "9.6.0", "fs-extra": "11.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec78c73..ac2212f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,6 +33,12 @@ importers: '@types/node': specifier: ^22.17.0 version: 22.17.0 + bumpp: + specifier: ^10.2.3 + version: 10.2.3 + cac: + specifier: ^6.7.14 + version: 6.7.14 cross-env: specifier: ^10.0.0 version: 10.0.0 @@ -671,6 +677,10 @@ packages: resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} engines: {node: '>=10'} + ansis@4.1.0: + resolution: {integrity: sha512-BGcItUBWSMRgOCe+SVZJ+S7yTRG0eGt9cXAHev72yuGcY23hnLA7Bky5L/xLyPINoSN95geovfBkqoTlNZYa7w==} + engines: {node: '>=14'} + anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} @@ -681,6 +691,9 @@ packages: argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + args-tokenizer@0.3.0: + resolution: {integrity: sha512-xXAd7G2Mll5W8uo37GETpQ2VrE84M181Z7ugHFGQnJZ50M2mbOv0osSZ9VsSgPfJQ+LVG0prSi0th+ELMsno7Q==} + async@3.2.6: resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} @@ -737,6 +750,23 @@ packages: buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + bumpp@10.2.3: + resolution: {integrity: sha512-nsFBZACxuBVu6yzDSaZZaWpX5hTQ+++9WtYkmO+0Bd3cpSq0Mzvqw5V83n+fOyRj3dYuZRFCQf5Z9NNfZj+Rnw==} + engines: {node: '>=18'} + hasBin: true + + c12@3.2.0: + resolution: {integrity: sha512-ixkEtbYafL56E6HiFuonMm1ZjoKtIo7TH68/uiEq4DAwv9NcUX2nJ95F8TrbMeNjqIkZpruo3ojXQJ+MGG5gcQ==} + peerDependencies: + magicast: ^0.3.5 + peerDependenciesMeta: + magicast: + optional: true + + cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -764,10 +794,17 @@ packages: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} engines: {node: '>=10'} + chokidar@4.0.3: + resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} + engines: {node: '>= 14.16.0'} + ci-info@3.9.0: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} + citty@0.1.6: + resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==} + cjs-module-lexer@1.3.1: resolution: {integrity: sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==} @@ -798,6 +835,13 @@ packages: concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + confbox@0.2.2: + resolution: {integrity: sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==} + + consola@3.4.2: + resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==} + engines: {node: ^14.18.0 || >=16.10.0} + convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -842,6 +886,12 @@ packages: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} + defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} + + destr@2.0.5: + resolution: {integrity: sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==} + detect-newline@3.1.0: resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} engines: {node: '>=8'} @@ -854,6 +904,10 @@ packages: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} + dotenv@17.2.2: + resolution: {integrity: sha512-Sf2LSQP+bOlhKWWyhFsn0UsfdK/kCWRv1iuA2gXAwt3dyNabr6QSj00I2V10pidqz69soatm9ZwZvpQMTIOd5Q==} + engines: {node: '>=12'} + ejs@3.1.10: resolution: {integrity: sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==} engines: {node: '>=0.10.0'} @@ -879,6 +933,10 @@ packages: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + engines: {node: '>=6'} + escape-string-regexp@1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} @@ -908,6 +966,9 @@ packages: resolution: {integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + exsolve@1.0.7: + resolution: {integrity: sha512-VO5fQUzZtI6C+vx4w/4BWJpg3s/5l+6pRQEHzFRM8WFi4XffSP1Z+4qi7GbjWbvRQEbdIco5mIMq+zX4rPuLrw==} + fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} @@ -972,6 +1033,10 @@ packages: resolution: {integrity: sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==} engines: {node: '>=18'} + giget@2.0.0: + resolution: {integrity: sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==} + hasBin: true + glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} deprecated: Glob versions prior to v9 are no longer supported @@ -1245,6 +1310,9 @@ packages: engines: {node: '>=6'} hasBin: true + jsonc-parser@3.3.1: + resolution: {integrity: sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==} + jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} @@ -1314,6 +1382,9 @@ packages: natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + node-fetch-native@1.6.7: + resolution: {integrity: sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==} + node-int64@0.4.0: resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} @@ -1332,6 +1403,14 @@ packages: resolution: {integrity: sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA==} engines: {node: '>=18'} + nypm@0.6.1: + resolution: {integrity: sha512-hlacBiRiv1k9hZFiphPUkfSQ/ZfQzZDzC+8z0wL3lvDAOUu/2NnChkKuMoMjNur/9OpKuz2QsIeiPVN0xM5Q0w==} + engines: {node: ^14.16.0 || >=16.10.0} + hasBin: true + + ohash@2.0.11: + resolution: {integrity: sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==} + once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} @@ -1355,6 +1434,9 @@ packages: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} + package-manager-detector@1.3.0: + resolution: {integrity: sha512-ZsEbbZORsyHuO00lY1kV3/t72yp6Ysay6Pd17ZAlNGuGwmWDLCJxFpRs0IzfXfj1o4icJOkUEioexFHzyPurSQ==} + parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -1382,6 +1464,12 @@ packages: path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + + perfect-debounce@1.0.0: + resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==} + picocolors@1.0.1: resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} @@ -1404,6 +1492,9 @@ packages: resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} engines: {node: '>=8'} + pkg-types@2.3.0: + resolution: {integrity: sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig==} + pretty-format@29.7.0: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -1419,6 +1510,9 @@ packages: pure-rand@6.1.0: resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==} + rc9@2.1.2: + resolution: {integrity: sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==} + react-is@18.3.1: resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} @@ -1426,6 +1520,10 @@ packages: resolution: {integrity: sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==} engines: {node: '>=0.10.0'} + readdirp@4.1.2: + resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} + engines: {node: '>= 14.18.0'} + require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -1563,6 +1661,9 @@ packages: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} + tinyexec@1.0.1: + resolution: {integrity: sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw==} + tinyglobby@0.2.14: resolution: {integrity: sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==} engines: {node: '>=12.0.0'} @@ -1696,6 +1797,11 @@ packages: yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} + yaml@2.8.1: + resolution: {integrity: sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==} + engines: {node: '>= 14.6'} + hasBin: true + yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -2422,6 +2528,8 @@ snapshots: ansi-styles@5.2.0: {} + ansis@4.1.0: {} + anymatch@3.1.3: dependencies: normalize-path: 3.0.0 @@ -2433,6 +2541,8 @@ snapshots: dependencies: sprintf-js: 1.0.3 + args-tokenizer@0.3.0: {} + async@3.2.6: {} babel-jest@29.7.0(@babel/core@7.25.2): @@ -2519,6 +2629,39 @@ snapshots: buffer-from@1.1.2: {} + bumpp@10.2.3: + dependencies: + ansis: 4.1.0 + args-tokenizer: 0.3.0 + c12: 3.2.0 + cac: 6.7.14 + escalade: 3.2.0 + jsonc-parser: 3.3.1 + package-manager-detector: 1.3.0 + semver: 7.7.2 + tinyexec: 1.0.1 + tinyglobby: 0.2.14 + yaml: 2.8.1 + transitivePeerDependencies: + - magicast + + c12@3.2.0: + dependencies: + chokidar: 4.0.3 + confbox: 0.2.2 + defu: 6.1.4 + dotenv: 17.2.2 + exsolve: 1.0.7 + giget: 2.0.0 + jiti: 2.5.1 + ohash: 2.0.11 + pathe: 2.0.3 + perfect-debounce: 1.0.0 + pkg-types: 2.3.0 + rc9: 2.1.2 + + cac@6.7.14: {} + callsites@3.1.0: {} camelcase@5.3.1: {} @@ -2540,8 +2683,16 @@ snapshots: char-regex@1.0.2: {} + chokidar@4.0.3: + dependencies: + readdirp: 4.1.2 + ci-info@3.9.0: {} + citty@0.1.6: + dependencies: + consola: 3.4.2 + cjs-module-lexer@1.3.1: {} cliui@8.0.1: @@ -2568,6 +2719,10 @@ snapshots: concat-map@0.0.1: {} + confbox@0.2.2: {} + + consola@3.4.2: {} + convert-source-map@2.0.0: {} core-js@3.44.0: {} @@ -2608,12 +2763,18 @@ snapshots: deepmerge@4.3.1: {} + defu@6.1.4: {} + + destr@2.0.5: {} + detect-newline@3.1.0: {} diff-sequences@29.6.3: {} diff@4.0.2: {} + dotenv@17.2.2: {} + ejs@3.1.10: dependencies: jake: 10.9.2 @@ -2634,6 +2795,8 @@ snapshots: escalade@3.1.2: {} + escalade@3.2.0: {} + escape-string-regexp@1.0.5: {} escape-string-regexp@2.0.0: {} @@ -2677,6 +2840,8 @@ snapshots: jest-message-util: 29.7.0 jest-util: 29.7.0 + exsolve@1.0.7: {} + fast-json-stable-stringify@2.1.0: {} fb-watchman@2.0.2: @@ -2730,6 +2895,15 @@ snapshots: '@sec-ant/readable-stream': 0.4.1 is-stream: 4.0.1 + giget@2.0.0: + dependencies: + citty: 0.1.6 + consola: 3.4.2 + defu: 6.1.4 + node-fetch-native: 1.6.7 + nypm: 0.6.1 + pathe: 2.0.3 + glob@7.2.3: dependencies: fs.realpath: 1.0.0 @@ -3167,6 +3341,8 @@ snapshots: json5@2.2.3: {} + jsonc-parser@3.3.1: {} + jsonfile@6.1.0: dependencies: universalify: 2.0.1 @@ -3230,6 +3406,8 @@ snapshots: natural-compare@1.4.0: {} + node-fetch-native@1.6.7: {} + node-int64@0.4.0: {} node-releases@2.0.18: {} @@ -3245,6 +3423,16 @@ snapshots: path-key: 4.0.0 unicorn-magic: 0.3.0 + nypm@0.6.1: + dependencies: + citty: 0.1.6 + consola: 3.4.2 + pathe: 2.0.3 + pkg-types: 2.3.0 + tinyexec: 1.0.1 + + ohash@2.0.11: {} + once@1.4.0: dependencies: wrappy: 1.0.2 @@ -3267,6 +3455,8 @@ snapshots: p-try@2.2.0: {} + package-manager-detector@1.3.0: {} + parse-json@5.2.0: dependencies: '@babel/code-frame': 7.24.7 @@ -3286,6 +3476,10 @@ snapshots: path-parse@1.0.7: {} + pathe@2.0.3: {} + + perfect-debounce@1.0.0: {} + picocolors@1.0.1: {} picocolors@1.1.1: {} @@ -3300,6 +3494,12 @@ snapshots: dependencies: find-up: 4.1.0 + pkg-types@2.3.0: + dependencies: + confbox: 0.2.2 + exsolve: 1.0.7 + pathe: 2.0.3 + pretty-format@29.7.0: dependencies: '@jest/schemas': 29.6.3 @@ -3317,10 +3517,17 @@ snapshots: pure-rand@6.1.0: {} + rc9@2.1.2: + dependencies: + defu: 6.1.4 + destr: 2.0.5 + react-is@18.3.1: {} react-refresh@0.17.0: {} + readdirp@4.1.2: {} + require-directory@2.1.1: {} resolve-cwd@3.0.0: @@ -3428,6 +3635,8 @@ snapshots: glob: 7.2.3 minimatch: 3.1.2 + tinyexec@1.0.1: {} + tinyglobby@0.2.14: dependencies: fdir: 6.4.4(picomatch@4.0.2) @@ -3546,6 +3755,8 @@ snapshots: yallist@3.1.1: {} + yaml@2.8.1: {} + yargs-parser@21.1.1: {} yargs@17.7.2: diff --git a/scripts/release.mjs b/scripts/release.mjs index bcdff49..f7cdf6e 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -1,47 +1,64 @@ import path from 'path'; import * as url from 'url'; +import cac from 'cac'; import { $ } from 'execa'; import fs from 'fs-extra'; -import { inc } from 'semver'; -const RELEASE_TAG = process.env.TAG || 'beta'; -const RELEASE_DRY_RUN = process.env.DRY_RUN || 'true'; -const RELEASE_VERSION_TYPE = process.env.VERSION || 'prerelease'; +let cli = cac('release'); +cli.option( + '--dry-run ', + 'Perform a dry run without publishing or pushing tags', + { + default: 'false', + }, +); +cli.option('--tag ', 'The npm tag to publish under (default: canary)', { + default: 'canary', +}); const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); const PKG_PATH = path.resolve(__dirname, '../package.json'); const pkg = fs.readJsonSync(PKG_PATH); -const currentVersion = pkg.version; -const nextVersion = inc(currentVersion, RELEASE_VERSION_TYPE); -if (!nextVersion) { +const publishVersion = pkg.version; + +const parsed = cli.parse(); +const npmTag = parsed.options.tag; +const isDryRun = parsed.options.dryRun; + +const allowedTags = ['latest', 'canary', 'alpha', 'beta', 'rc', 'nightly']; +if (!allowedTags.includes(npmTag)) { throw new Error( - `Failed to generate next version from "${currentVersion}" with type "${RELEASE_VERSION_TYPE}"`, + `Invalid npm tag: ${npmTag}. Allowed tags: ${allowedTags.join(', ')}`, ); } -console.info(`Release ${RELEASE_TAG} version ${nextVersion}`); - -// Update pkg version -console.info(`Updating version from ${currentVersion} to ${nextVersion}`); -pkg.version = nextVersion; -fs.writeJsonSync(PKG_PATH, pkg, { spaces: 2 }); +const prereleaseTags = ['alpha', 'beta', 'rc', 'canary', 'nightly']; +if ( + npmTag === 'latest' && + prereleaseTags.some((tag) => publishVersion.includes(tag)) +) { + throw Error(`Can't release ${publishVersion} to latest tag`); +} -// Publish to npm -console.info(`Publishing to npm with tag ${RELEASE_TAG}`); -const dryRun = RELEASE_DRY_RUN === 'true' ? ['--dry-run'] : []; +console.info( + `Release ${npmTag} version ${publishVersion}${isDryRun ? '(dry-run)' : ''}`, +); try { - await $`pnpm publish ${dryRun} --tag ${RELEASE_TAG} --no-git-checks`; + const flags = isDryRun + ? ['--dry-run', `--tag`, npmTag, `--no-git-checks`] + : [`--tag`, npmTag, `--no-git-checks`]; + await $`pnpm publish ${flags}`; console.info(`Published successfully`); } catch (e) { console.error(`Publish failed: ${e.message}`); process.exit(1); } -// Push tag to github -if (RELEASE_DRY_RUN !== 'true') { +// Push tag to GitHub +if (!isDryRun) { console.info(`Pushing tag to github`); - const tagName = `v${nextVersion}`; + const tagName = `v${publishVersion}`; try { await $`git config --global --add safe.directory /github/workspace`; await $`git config --global user.name "github-actions[bot]"`; @@ -54,17 +71,6 @@ if (RELEASE_DRY_RUN !== 'true') { console.error(`Push tag failed: ${e.message}`); process.exit(1); } - - try { - await $`git add --all`; - const commitMsg = `release ${tagName}`; - await $`git commit -m ${commitMsg}`; - await $`git push`; - console.info(`Pushed branch successfully`); - } catch (e) { - console.error(`Update branch failed: ${e.message}`); - process.exit(1); - } } console.info(`Release completed`);