diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2183180..f17a41d 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -36,22 +36,32 @@ jobs: run: | CURRENT_VERSION=$(node -p 'require("./lerna.json").version') echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV - - name: Publish to dGithub Registry + - name: Tag Check + id: tag_check + run: | + GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}" + http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \ + -H "Authorization: token ${GITHUB_TOKEN}") + if [ "$http_status_code" -ne "404" ] ; then + echo "::set-output name=exists_tag::true" + else + echo "::set-output name=exists_tag::false" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Git Tag + if: steps.tag_check.outputs.exists_tag == 'false' + uses: pkgdeps/git-tag-action@v2 + with: + version: ${{ env.CURRENT_VERSION }} + github_token: ${{ secrets.GITHUB_TOKEN }} + github_repo: ${{ github.repository }} + git_commit_sha: ${{ github.sha }} + git_tag_prefix: "v" + - name: Publish to Github Registry run: pnpm run publish from-package --yes env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 with: persist-credentials: false - - uses: actions/github-script@v4 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'https://github.com/${{ github.repository }}/releases/tag/v${{ env.CURRENT_VERSION }} is released 🎉' - })