diff --git a/.github/workflows/master_push.yml b/.github/workflows/master_push.yml index 3c98546..37753c0 100644 --- a/.github/workflows/master_push.yml +++ b/.github/workflows/master_push.yml @@ -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/github-push-action@v0.7.0 - 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'