File tree Expand file tree Collapse file tree 2 files changed +82
-0
lines changed Expand file tree Collapse file tree 2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ name : NPM Publish Beta
2+
3+ on :
4+ push :
5+ branches :
6+ - develop
7+ pull_request :
8+ branches :
9+ - master
10+
11+ jobs :
12+ publish-beta :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v3
16+
17+ - name : Setup Node.js
18+ uses : actions/setup-node@v3
19+ with :
20+ node-version : ' 18.x'
21+ registry-url : ' https://registry.npmjs.org'
22+
23+ - name : Install dependencies
24+ run : npm ci
25+
26+ - name : Build
27+ run : npm run build
28+
29+ - name : Generate beta version
30+ id : beta-version
31+ run : |
32+ # Get the current version from package.json
33+ CURRENT_VERSION=$(node -p "require('./package.json').version")
34+
35+ # For PR: use PR number in version
36+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
37+ BETA_VERSION="$CURRENT_VERSION-beta.pr.${{ github.event.pull_request.number }}"
38+ else
39+ # For develop: use commit hash
40+ SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
41+ BETA_VERSION="$CURRENT_VERSION-beta.$SHORT_SHA"
42+ fi
43+
44+ # Set output for use in next step
45+ echo "version=$BETA_VERSION" >> $GITHUB_OUTPUT
46+
47+ # Update package.json with new version
48+ npm version $BETA_VERSION --no-git-tag-version
49+
50+ - name : Publish beta to npm
51+ run : npm publish --tag beta --access public
52+ env :
53+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change 1+ name : NPM Publish
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+
8+ jobs :
9+ publish :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v3
13+
14+ - name : Setup Node.js
15+ uses : actions/setup-node@v3
16+ with :
17+ node-version : ' 18.x'
18+ registry-url : ' https://registry.npmjs.org'
19+
20+ - name : Install dependencies
21+ run : npm ci
22+
23+ - name : Build
24+ run : npm run build
25+
26+ - name : Publish to npm
27+ run : npm publish --access public
28+ env :
29+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments