1212 outputs :
1313 VERSION_EXISTS : ${{ steps.check-version.outputs.VERSION_EXISTS }}
1414 VERSION : ${{ steps.get-version.outputs.VERSION }}
15+ RELEASE_CHANNEL : ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}
1516 steps :
1617 - uses : GitHubSecurityLab/actions-permissions/monitor@v1
1718 - uses : actions/checkout@v5
4243 else
4344 echo "VERSION_EXISTS=false" >> "$GITHUB_OUTPUT"
4445 fi
46+ - name : Get npm tag
47+ id : npm-tag
48+ run : |
49+ $regex = "^v?(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:[^.]*)))?"
50+ $version = "${{ steps.get-version.outputs.VERSION }}"
51+ $releaseChannel = $groups["prerelease"][0].value
52+
53+ if ([string]::IsNullOrEmpty($releaseChannel)) {
54+ $releaseChannel = "latest"
55+ }
56+ Write-Output "RELEASE_CHANNEL=$releaseChannel" >> $Env:GITHUB_OUTPUT
57+ - name : Output deployment info
58+ run : echo "::notice title=Deployment Info::Deploying version ${{ steps.get-version.outputs.VERSION }} to channel ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}"
59+
4560 publish :
4661 runs-on : ubuntu-latest
4762 environment : Production
@@ -58,16 +73,17 @@ jobs:
5873 node-version-file : package.json
5974 registry-url : " https://registry.npmjs.org"
6075 cache : " npm"
76+
6177 - name : Build package
6278 run : |
6379 npm ci
6480 npm run build
6581 - name : Publish to NPM
66- run : npm publish
82+ run : npm publish --tag ${{ needs.check.outputs.RELEASE_CHANNEL }}
6783 env :
6884 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
6985 - name : Publish git release
7086 env :
7187 GH_TOKEN : ${{ github.token }}
7288 run : |
73- gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }}
89+ gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }} ${{ (steps.npm-tag.outputs.RELEASE_CHANNEL != 'latest' && '--prerelease') || ''}}
0 commit comments