Skip to content

Commit d023157

Browse files
committed
Update publish script
1 parent c4f4a93 commit d023157

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ on:
88

99
jobs:
1010
publish:
11-
# Don't run just after creating repo from template
12-
# Also avoid running after merging set-up PR
13-
if: github.run_number > 2 && github.event.repository.owner.login == 'react18-tools'
11+
if: github.event.repository.owner.login == 'react18-tools'
1412
runs-on: ubuntu-latest
1513
permissions:
1614
contents: write
@@ -35,7 +33,7 @@ jobs:
3533
- name: Test
3634
run: pnpm test
3735
- name: Copy Readme file
38-
run: cp ./README.md ./lib # will be uncommented while rebranding
36+
run: cp ./README.md ./lib
3937
- name: Apply changesets, publish and create release, branches and tags
4038
run: node ./scripts/publish.js
4139
env:

scripts/publish.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/** It is assumed that this is called only from the default branch. */
2-
const { execSync } = require("child_process");
2+
const { execSync, exec } = require("child_process");
3+
const fs = require("fs");
4+
const path = require("path");
35

46
// Apply changesets if any -- e.g., coming from pre-release branches
57
try {
@@ -16,7 +18,8 @@ try {
1618
// no changesets to be applied
1719
}
1820

19-
const { version: VERSION, name } = require("../lib/package.json");
21+
const packageJSON = require("../lib/package.json");
22+
const { version: VERSION, name } = packageJSON;
2023
const LATEST_VERSION = execSync(`npm view ${name} version`).toString();
2124

2225
console.log({ VERSION, LATEST_VERSION });
@@ -39,3 +42,27 @@ execSync("cd lib && pnpm build && npm publish --provenance --access public");
3942
execSync(
4043
`gh release create ${VERSION} --generate-notes --latest -n "$(sed '1,/^## /d;/^## /,$d' CHANGELOG.md)" --title "Release v${VERSION}"`,
4144
);
45+
46+
// update canonicals
47+
48+
const publishCanonical = (canonical) => {
49+
packageJSON.name = canonical;
50+
fs.writeFileSync(pkgPath, JSON.stringify(packageJSON, null, 2));
51+
exec("cd lib && pnpm build && npm publish --provenance --access public");
52+
}
53+
54+
const canonicals = [`@mayank1513/${name}`, 'nextjs-themes-ultra']
55+
const pkgPath = path.join(__dirname, "../lib/package.json");
56+
canonicals.forEach(publishCanonical);
57+
58+
// lite version
59+
packageJson.peerDependencies.r18gs = "^1";
60+
delete packageJson.dependencies;
61+
62+
const liteCanonicals = ['nthul-lite', '@mayank1513/nthul-lite', 'nextjs-themes-ultralite'];
63+
64+
liteCanonicals.forEach(publishCanonical);
65+
66+
const toDeprecate = ['@mayank1513/nthul', '@mayank1513/nthul-lite']
67+
68+
toDeprecate.forEach(pkg => exec(`npm deprecate ${pkg} "Please use <https://www.npmjs.com/package/${pkg.slice('/')[1]}> instead. We initially created scoped packages to have similarities with the GitHub Public Repository (which requires packages to be scoped). We are no longer using GPR and thus deprecating all scoped packages for which corresponding un-scoped packages exist.`))

0 commit comments

Comments
 (0)