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 23cbab6 commit 8dbdcba
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/master_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,30 @@ jobs:

# 暂存 contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') 结果
- name: 判断 tag 是否存在
id: tag-exists
run: echo ::set-output name=hasTag::${{ contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') }}
# id: tag-exists
# run: echo ::set-output name=hasTag::${{ contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') }}
id: check-tag
run: |
if git rev-parse "v${{ steps.package-version.outputs.version }}" >/dev/null 2>&1; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: 创建 tag
if: steps.tag-exists.outputs.hasTag == 'false'
if: steps.check-tag.outputs.exists == 'false'
run: git tag v${{ steps.package-version.outputs.version }} && git push --tags

- name: 发布 Release
# 判断是否已经发布过此版本
if: steps.tag-exists.outputs.hasTag == 'false'
if: steps.check-tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
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'
if: steps.check-tag.outputs.exists == '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' }}
env:
Expand Down

0 comments on commit 8dbdcba

Please sign in to comment.