12
12
outputs :
13
13
VERSION_EXISTS : ${{ steps.check-version.outputs.VERSION_EXISTS }}
14
14
VERSION : ${{ steps.get-version.outputs.VERSION }}
15
+ RELEASE_CHANNEL : ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}
15
16
steps :
16
17
- uses : GitHubSecurityLab/actions-permissions/monitor@v1
17
18
- uses : actions/checkout@v5
42
43
else
43
44
echo "VERSION_EXISTS=false" >> "$GITHUB_OUTPUT"
44
45
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
+
45
60
publish :
46
61
runs-on : ubuntu-latest
47
62
environment : Production
@@ -58,16 +73,17 @@ jobs:
58
73
node-version-file : package.json
59
74
registry-url : " https://registry.npmjs.org"
60
75
cache : " npm"
76
+
61
77
- name : Build package
62
78
run : |
63
79
npm ci
64
80
npm run build
65
81
- name : Publish to NPM
66
- run : npm publish
82
+ run : npm publish --tag ${{ needs.check.outputs.RELEASE_CHANNEL }}
67
83
env :
68
84
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
69
85
- name : Publish git release
70
86
env :
71
87
GH_TOKEN : ${{ github.token }}
72
88
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