Skip to content

Commit e76b981

Browse files
committed
add publish action
1 parent 7d5493c commit e76b981

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

Diff for: .github/workflows/publish-to-npm-on-new-release.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish to npm and GitHub
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version: 16
15+
registry-url: https://registry.npmjs.org
16+
- name: Update version
17+
run: |
18+
git config --global user.name "mayank1513"
19+
git config --global user.email "[email protected]"
20+
git fetch
21+
git checkout main
22+
npm i && npm version patch
23+
npm -v
24+
git push origin main
25+
- run: npm run publish-package
26+
env:
27+
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
28+
29+
- uses: actions/setup-node@v3
30+
with:
31+
registry-url: https://npm.pkg.github.com/
32+
- run: npm run publish-gpr
33+
env:
34+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
},
1111
"scripts": {
1212
"build": "tsup src --dts && node createPackageJSON.js",
13-
"publish-package": "npm run build && cp README.md dist/README.md"
13+
"publish-package": "npm run build && cp README.md dist/README.md && cd dist && npm publish && cd ..",
14+
"publish-gpr": "node prepGPR.js && cd dist && npm publish"
1415
},
1516
"keywords": [
1617
"react",

Diff for: prepGPR.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
const packageJson = require(path.resolve(__dirname, "dist", "package.json"));
6+
7+
packageJson.name = "@mayank1513/esbuild-react18-useclient";
8+
packageJson.publishConfig = {
9+
"@mayank1513:registry": "https://npm.pkg.github.com",
10+
};
11+
12+
fs.writeFileSync(
13+
path.resolve(__dirname, "dist", "package.json"),
14+
JSON.stringify(packageJson, null, 2)
15+
);

0 commit comments

Comments
 (0)