@@ -20,27 +20,23 @@ permissions:
2020  id-token : write 
2121
2222jobs :
23-   release :
24-     name : Release 
23+   check_release :
24+     name : Check for release tag 
2525    runs-on : ubuntu-latest 
26-     environment : npm 
26+     outputs :
27+       proceed : ${{ github.event_name == 'workflow_dispatch' && 'true' || steps.check_tag.outputs.proceed }} 
28+       release_tag : ${{ github.event_name == 'workflow_dispatch' && inputs.tag || steps.check_tag.outputs.release_tag }} 
2729    steps :
2830      - name : Checkout 
31+         if : github.event_name != 'workflow_dispatch' 
2932        uses : actions/checkout@v4 
3033        with :
31-           ref : ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }} 
3234          fetch-depth : 0 
3335
3436      - name : Check if release tag exists for this commit 
37+         if : github.event_name != 'workflow_dispatch' 
3538        id : check_tag 
3639        run : | 
37-           # For manual dispatch, we already know we should proceed 
38-           if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then 
39-             echo "proceed=true" >> $GITHUB_OUTPUT 
40-             echo "release_tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT 
41-             exit 0 
42-           fi 
43- 
4440          # For push to main branch, check if a release tag points to this commit 
4541          TAGS=$(git tag --points-at ${{ github.sha }} | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$' || true) 
4642
6460          echo "proceed=true" >> $GITHUB_OUTPUT 
6561          echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT 
6662
63+ release :
64+     name : Release 
65+     runs-on : ubuntu-latest 
66+     needs : check_release 
67+     if : needs.check_release.outputs.proceed == 'true' 
68+     environment : npm 
69+     steps :
70+       - name : Checkout 
71+         uses : actions/checkout@v4 
72+         with :
73+           ref : ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }} 
74+           fetch-depth : 0 
75+ 
6776      - name : Verify tag matches package.json version 
68-         if : steps.check_tag.outputs.proceed == 'true' 
6977        run : | 
7078          jq --raw-output --exit-status --arg tag "$RELEASE_TAG" ' 
7179            if (.version == ($tag | ltrimstr("v"))) then 
@@ -74,10 +82,10 @@ jobs:
7482              "Package version (\(.version)) does not match tag version (\($tag | ltrimstr("v")))" | halt_error(1) 
7583            end' package.json 
7684env :
77-           RELEASE_TAG : ${{ steps.check_tag .outputs.release_tag }} 
85+           RELEASE_TAG : ${{ needs.check_release .outputs.release_tag }} 
7886
7987      - name : Check CI status 
80-         if : ${{ steps.check_tag.outputs.proceed == 'true' &&  !inputs.skip_ci_check }} 
88+         if : ${{ github.event_name != 'workflow_dispatch' ||  !inputs.skip_ci_check }} 
8189        run : | 
8290          # Check if CI has completed successfully for this commit 
8391          gh run list --commit ${{ github.sha }} --status success --json workflowName | jq --raw-output --exit-status ' 
@@ -90,26 +98,23 @@ jobs:
9098          GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
9199
92100      - name : Setup Node.js 
93-         if : steps.check_tag.outputs.proceed == 'true' 
94101        uses : actions/setup-node@v4 
95102        with :
96103          node-version-file : package.json 
97104          cache : npm 
98105          registry-url : https://registry.npmjs.org 
99106
100107      - name : Publish to npm with provenance 
101-         if : steps.check_tag.outputs.proceed == 'true' 
102108        run : npm publish --provenance 
103109        env :
104110          NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }} 
105111
106112      - name : Create GitHub Release 
107-         if : steps.check_tag.outputs.proceed == 'true' 
108113        run : | 
109114          gh release create "$RELEASE_TAG" \ 
110115            --title "$RELEASE_TAG" \ 
111116            --draft \ 
112117            --generate-notes 
113118env :
114-           RELEASE_TAG : ${{ steps.check_tag .outputs.release_tag }} 
119+           RELEASE_TAG : ${{ needs.check_release .outputs.release_tag }} 
115120          GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
0 commit comments