Skip to content

Commit 5c6de7f

Browse files
committed
chore: ci workflow with oidc
1 parent 3e61cef commit 5c6de7f

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.github/workflows/npm_release.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ jobs:
145145
script: ./gradlew runtestsAndVerifyResults --stacktrace
146146
publish:
147147
runs-on: ubuntu-latest
148+
environment: npm-publish
148149
needs:
149150
- build
150151
- test
@@ -168,10 +169,27 @@ jobs:
168169
with:
169170
name: npm-package
170171
path: dist
171-
- name: Publish package
172+
- name: Update npm (required for OIDC trusted publishing)
172173
run: |
173-
echo "Publishing @nativescript/android@$NPM_VERSION to NPM with tag $NPM_TAG..."
174-
npm publish ./dist/nativescript-android-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --provenance
174+
npm install -g npm@^11.5.1
175+
npm --version
176+
- name: Publish package (OIDC trusted publishing)
177+
if: ${{ vars.USE_NPM_TOKEN != 'true' }}
178+
run: |
179+
echo "Publishing @nativescript/android@$NPM_VERSION to NPM with tag $NPM_TAG via OIDC trusted publishing..."
180+
unset NODE_AUTH_TOKEN
181+
if [ -n "${NPM_CONFIG_USERCONFIG:-}" ]; then
182+
rm -f "$NPM_CONFIG_USERCONFIG"
183+
fi
184+
npm publish ./dist/nativescript-android-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --access public --provenance
185+
env:
186+
NODE_AUTH_TOKEN: ""
187+
188+
- name: Publish package (granular token)
189+
if: ${{ vars.USE_NPM_TOKEN == 'true' }}
190+
run: |
191+
echo "Publishing @nativescript/android@$NPM_VERSION to NPM with tag $NPM_TAG via granular token..."
192+
npm publish ./dist/nativescript-android-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --access public --provenance
175193
env:
176194
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
177195
github-release:

0 commit comments

Comments
 (0)