99 paths-ignore :
1010 - ' packages/**'
1111 workflow_dispatch :
12+ inputs :
13+ release_type :
14+ description : ' Release type. "dev" publishes a -next prerelease without bumping package.json. patch/minor/major/prerelease bump package.json, commit + tag to main, then publish as a stable release.'
15+ type : choice
16+ options :
17+ - dev
18+ - patch
19+ - minor
20+ - major
21+ - prerelease
22+ default : patch
1223
1324permissions : read-all
1425
1930 build :
2031 name : Build
2132 runs-on : macos-latest
33+ permissions :
34+ contents : write
2235 outputs :
2336 npm_version : ${{ steps.npm_version_output.outputs.NPM_VERSION }}
2437 npm_tag : ${{ steps.npm_version_output.outputs.NPM_TAG }}
38+ is_release : ${{ steps.npm_version_output.outputs.IS_RELEASE }}
2539
2640 steps :
2741 - name : Harden the runner (Audit all outbound calls)
3246 - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3347 with :
3448 fetch-depth : 0
49+ token : ${{ secrets.GITHUB_TOKEN }}
3550
3651 - uses : actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
3752 with :
4661 NPM_VERSION=$(node -e "console.log(require('./package.json').version);")
4762 echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
4863
64+ - name : Bump, commit and tag stable release (manual dispatch)
65+ if : ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'dev' }}
66+ run : |
67+ git config user.name "github-actions[bot]"
68+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
69+ npm version ${{ inputs.release_type }} -m "chore: release v%s"
70+ NPM_VERSION=$(node -e "console.log(require('./package.json').version);")
71+ echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
72+ git push origin HEAD:${GITHUB_REF_NAME} --follow-tags
73+
4974 - name : Bump version for dev release
50- if : ${{ !contains(github.ref, 'refs/tags/') }}
75+ if : ${{ !contains(github.ref, 'refs/tags/') && (github.event_name != 'workflow_dispatch' || inputs.release_type == 'dev') }}
5176 run : |
5277 NPM_VERSION=$(node ./scripts/get-next-version.js)
5378 echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
5782 id : npm_version_output
5883 run : |
5984 NPM_TAG=$(node ./scripts/get-npm-tag.js)
85+ if [[ "${GITHUB_REF}" == refs/tags/* ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.release_type }}" != "dev" ]]; then
86+ IS_RELEASE=true
87+ else
88+ IS_RELEASE=false
89+ fi
6090 echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT
6191 echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT
92+ echo IS_RELEASE=$IS_RELEASE >> $GITHUB_OUTPUT
6293
6394 - name : Build nativescript
6495 run : npm pack
@@ -123,8 +154,8 @@ jobs:
123154
124155 github-release :
125156 runs-on : ubuntu-latest
126- # only runs on tagged commits
127- if : ${{ contains(github.ref, 'refs/tags/') }}
157+ # runs for tag pushes and for manual dispatches that bumped a stable release
158+ if : ${{ needs.build.outputs.is_release == 'true' }}
128159 permissions :
129160 contents : write
130161 needs :
@@ -140,6 +171,7 @@ jobs:
140171 - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
141172 with :
142173 fetch-depth : 0
174+ ref : v${{needs.build.outputs.npm_version}}
143175
144176 - uses : actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
145177 with :
@@ -169,6 +201,7 @@ jobs:
169201
170202 - uses : ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
171203 with :
204+ tag : v${{needs.build.outputs.npm_version}}
172205 artifacts : " dist/nativescript-*.tgz,dist/nativescript-*.intoto.jsonl"
173206 bodyFile : " body.md"
174207 prerelease : ${{needs.build.outputs.npm_tag != 'latest'}}
0 commit comments