Skip to content

Commit

Permalink
🐎 ci: release workflow test
Browse files Browse the repository at this point in the history
  • Loading branch information
kiccer committed Apr 7, 2024
1 parent 5cc12b8 commit 23cbab6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/master_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,23 @@ jobs:
# 暂存 contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') 结果
- name: 判断 tag 是否存在
id: tag-exists
run: echo ::set-output name=tag-exists::${{ contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') }}
run: echo ::set-output name=hasTag::${{ contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') }}

- name: 创建 tag
if: steps.tag-exists.outputs.hasTag == 'false'
run: git tag v${{ steps.package-version.outputs.version }} && git push --tags
if: steps.tag-exists.outputs.tag-exists == 'false'

- name: 发布 Release
# 判断是否已经发布过此版本
if: steps.tag-exists.outputs.hasTag == 'false'
uses: softprops/action-gh-release@v2
if: steps.tag-exists.outputs.tag-exists == 'false'
with:
name: v${{ steps.package-version.outputs.version }}
tag_name: v${{ steps.package-version.outputs.version }}

- name: 发布到 NPM
if: steps.tag-exists.outputs.hasTag == 'false'
# 根据 version 判断是否需要加 --tag [alpha|beta]
run: npm publish --tag ${{ contains(steps.package-version.outputs.version, 'alpha') && 'alpha' || contains(steps.package-version.outputs.version, 'beta') && 'beta' || 'latest' }}
if: steps.tag-exists.outputs.tag-exists == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 23cbab6

Please sign in to comment.