File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Publish to NPM
2+
3+ on :
4+ release :
5+ types : [published]
6+
7+ jobs :
8+ build-and-publish :
9+ runs-on : ubuntu-latest
10+ permissions :
11+ contents : read
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : Setup Node.js
18+ uses : actions/setup-node@v4
19+ with :
20+ node-version : ' 20.x'
21+ registry-url : ' https://registry.npmjs.org'
22+
23+ - name : Generate JS Modules
24+ run : |
25+ # 1. Generate CommonJS file (index.cjs)
26+ cat bundle.js > index.cjs
27+ echo -e "\nmodule.exports = PhonePe;" >> index.cjs
28+
29+ # 2. Generate ES Module file (index.mjs)
30+ cat bundle.js > index.mjs
31+ echo -e "\nexport default PhonePe;" >> index.mjs
32+
33+ - name : Generate package.json
34+ run : |
35+ # Extract version from GitHub release tag (e.g., 'v1.2.3' becomes '1.2.3')
36+ VERSION=${GITHUB_REF_NAME#v}
37+
38+ # Dynamically create the package.json file
39+ cat <<EOF > package.json
40+ {
41+ "name": "@phonepe-limited-official/phonepe-js-sdk",
42+ "version": "$VERSION",
43+ "description": "PhonePe JS SDK",
44+ "main": "index.cjs",
45+ "module": "index.mjs",
46+ "unpkg": "bundle.js",
47+ "exports": {
48+ ".": {
49+ "import": "./index.mjs",
50+ "require": "./index.cjs",
51+ "default": "./bundle.js"
52+ }
53+ },
54+ "files": [
55+ "bundle.js",
56+ "index.cjs",
57+ "index.mjs",
58+ "README.md"
59+ ]
60+ }
61+ EOF
62+
63+ - name : Publish package to NPM
64+ run : npm publish --access public
65+ env :
66+ NODE_AUTH_TOKEN : ${{ secrets.NPMJS_PUBLISH_TOKEN }}
You can’t perform that action at this time.
0 commit comments