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 aa81ca4 commit 00191a1
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions .github/workflows/master_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,23 @@ jobs:
uses: tyankatsu0105/read-package-version-actions@v1
id: package-version

- name: 创建 tag
run: git tag v${{ steps.package-version.outputs.version }}
# 判断 version 是否已存在
if: contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') == false
# 暂存 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 }}'))

- name: 推送 tag
uses: ad-m/[email protected]
if: contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') == false
- name: 发布 Release
uses: softprops/action-gh-release@v2
if: steps.tag-exists.outputs.tag-exists == 'false'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: v${{ steps.package-version.outputs.version }}
name: v${{ steps.package-version.outputs.version }}
tag_name: v${{ steps.package-version.outputs.version }}

- name: 发布到 NPM
# 根据 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'

- name: 发布 Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: v${{ steps.package-version.outputs.version }}
tag_name: v${{ steps.package-version.outputs.version }}
- name: 创建 tag
run: git tag v${{ steps.package-version.outputs.version }} && git push --tags
if: steps.tag-exists.outputs.tag-exists == 'false'

0 comments on commit 00191a1

Please sign in to comment.