@@ -316,31 +316,63 @@ jobs:
316316 if : startsWith(github.ref, 'refs/tags/')
317317 run : npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
318318
319- - name : Publish LSP as pre-release to NPM
320- if : github.ref == 'refs/heads/master'
319+ - name : Package LSP for NPM
320+ if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
321321 working-directory : server
322322 run : |
323- npm version preminor --preid next-$(git rev-parse --short HEAD)
324- npm publish --access public --tag next
325- env :
326- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
327-
328- - name : Publish LSP to NPM
329- if : startsWith(github.ref, 'refs/tags/')
330- working-directory : server
331- run : npm publish --access public
332- env :
333- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
323+ if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
324+ npm version preminor --preid next-$(git rev-parse --short HEAD)
325+ fi
326+ mkdir -p ../npm-packages
327+ npm pack --pack-destination ../npm-packages
334328
335329 - name : Build @rescript/tools package
336330 working-directory : tools
337331 run : |
338332 npm ci
339333 npm run build
340334
341- - name : Publish @rescript/tools package
335+ - name : Package @rescript/tools for NPM
342336 if : ${{ startsWith(github.event.head_commit.message, 'publish tools') && (github.ref == 'refs/heads/master') }}
343337 working-directory : tools
344- run : npm publish --access public
338+ run : npm pack --pack-destination ../npm-packages
339+
340+ - name : Upload NPM packages
341+ if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
342+ uses : actions/upload-artifact@v4
343+ with :
344+ name : npm-packages
345+ path : npm-packages/*.tgz
346+ retention-days : 1
347+
348+ publish-npm :
349+ name : Publish NPM packages
350+ needs : package
351+ if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
352+ runs-on : ubuntu-24.04
353+ permissions :
354+ contents : read
355+ id-token : write
356+
357+ steps :
358+ - name : Use Node.js
359+ uses : actions/setup-node@v6
360+ with :
361+ node-version : 24
362+ registry-url : " https://registry.npmjs.org"
363+ package-manager-cache : false
364+
365+ - name : Download NPM packages
366+ uses : actions/download-artifact@v4
367+ with :
368+ name : npm-packages
369+ path : packages
370+
371+ - name : Publish LSP to NPM
345372 env :
346- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
373+ NPM_TAG : ${{ github.ref == 'refs/heads/master' && 'next' || 'latest' }}
374+ run : npm publish packages/rescript-language-server-*.tgz --access public --tag "$NPM_TAG"
375+
376+ - name : Publish @rescript/tools package
377+ if : ${{ startsWith(github.event.head_commit.message, 'publish tools') && (github.ref == 'refs/heads/master') }}
378+ run : npm publish packages/rescript-tools-*.tgz --access public
0 commit comments