44 push :
55 tags :
66 - " v*"
7- workflow_dispatch : {}
7+ workflow_dispatch :
8+ inputs :
9+ tag :
10+ description : " Tag name to release (e.g. v1.2.3). If empty, skip release/publish steps."
11+ required : false
12+ type : string
813
914permissions :
1015 contents : write
@@ -13,9 +18,17 @@ permissions:
1318jobs :
1419 build-and-publish :
1520 runs-on : ubuntu-latest
21+ env :
22+ RELEASE_TAG : ${{ github.ref_type == 'tag' && github.ref_name || inputs.tag }}
1623 steps :
1724 - name : Checkout
1825 uses : actions/checkout@v4
26+ with :
27+ fetch-depth : 0
28+
29+ - name : Checkout input tag
30+ if : ${{ inputs.tag != '' && github.ref_type != 'tag' }}
31+ run : git checkout "${{ inputs.tag }}"
1932
2033 - name : Setup Node
2134 uses : actions/setup-node@v4
@@ -43,11 +56,14 @@ jobs:
4356 path : ${{ steps.pack.outputs.tarball }}
4457
4558 - name : Create GitHub Release (attach tarball)
59+ if : ${{ env.RELEASE_TAG != '' }}
4660 uses : softprops/action-gh-release@v2
4761 with :
62+ tag_name : ${{ env.RELEASE_TAG }}
4863 files : ${{ steps.pack.outputs.tarball }}
4964
5065 - name : Publish to GitHub Packages (npm.pkg.github.com)
66+ if : ${{ env.RELEASE_TAG != '' }}
5167 run : |
5268 npm config set registry https://npm.pkg.github.com
5369 npm pkg set name="@${{ github.repository_owner }}/git-ai"
5874 - name : Publish to npmjs.org (optional)
5975 env :
6076 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
61- if : ${{ env.NODE_AUTH_TOKEN != '' }}
77+ if : ${{ env.RELEASE_TAG != '' && env. NODE_AUTH_TOKEN != '' }}
6278 run : |
6379 npm config set registry https://registry.npmjs.org
6480 npm publish --access public
0 commit comments