77 description : " Version to publish (patch, minor, major, or specific version)"
88 required : true
99 default : " patch"
10+ beta :
11+ description : " Publish beta version (true or false)"
12+ required : false
13+ default : " false"
14+ preid :
15+ description : " Prefix identifier for beta version (e.g., beta, alpha, rc)"
16+ required : false
17+ default : " beta"
1018
1119jobs :
1220 publish :
1523 steps :
1624 - uses : actions/checkout@v4
1725 with :
18- # 确保获取完整的git历史以进行版本控制
26+ # Ensure to fetch the complete git history for version control
1927 fetch-depth : 0
2028
2129 - name : Use Node.js 18.x
@@ -35,16 +43,34 @@ jobs:
3543 git config --global user.name "GitHub Actions"
3644 git config --global user.email "actions@github.com"
3745
38- if [[ "${{ github.event.inputs.version }}" =~ ^(patch|minor|major)$ ]]; then
39- npm version ${{ github.event.inputs.version }}
46+ if [[ "${{ github.event.inputs.beta }}" == "true" ]]; then
47+ # Publish beta version
48+ if [[ "${{ github.event.inputs.version }}" =~ ^(patch|minor|major)$ ]]; then
49+ npm version pre${{ github.event.inputs.version }} --preid=${{ github.event.inputs.preid }}
50+ else
51+ # Specific version number for beta version
52+ npm version ${{ github.event.inputs.version }}-${{ github.event.inputs.preid }}.0 --no-git-tag-version
53+ git add package.json
54+ git commit -m "chore: bump version to ${{ github.event.inputs.version }}-${{ github.event.inputs.preid }}.0"
55+ git tag "v${{ github.event.inputs.version }}-${{ github.event.inputs.preid }}.0"
56+ fi
57+
58+ # Publish to NPM, marked as beta version
59+ npm publish --tag ${{ github.event.inputs.preid }}
4060 else
41- npm version ${{ github.event.inputs.version }} --no-git-tag-version
42- git add package.json
43- git commit -m "chore: bump version to ${{ github.event.inputs.version }}"
44- git tag "v${{ github.event.inputs.version }}"
61+ # Normal version publishing process
62+ if [[ "${{ github.event.inputs.version }}" =~ ^(patch|minor|major)$ ]]; then
63+ npm version ${{ github.event.inputs.version }}
64+ else
65+ npm version ${{ github.event.inputs.version }} --no-git-tag-version
66+ git add package.json
67+ git commit -m "chore: bump version to ${{ github.event.inputs.version }}"
68+ git tag "v${{ github.event.inputs.version }}"
69+ fi
70+
71+ npm publish
4572 fi
4673
47- npm publish
4874 git push
4975 git push --tags
5076 env :
0 commit comments