Skip to content

Commit 3339b06

Browse files
committed
chore: add ability to release prerelease versions
1 parent a06b443 commit 3339b06

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

.github/workflows/publish.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,28 @@ jobs:
5858
node-version-file: package.json
5959
registry-url: "https://registry.npmjs.org"
6060
cache: "npm"
61+
- name: Get npm tag
62+
id: npm-tag
63+
run: |
64+
$regex = "^v?(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:[^.]*)))?"
65+
$version = "${{ needs.check.outputs.VERSION }}"
66+
$releaseChannel = $groups["prerelease"][0].value
67+
68+
if ([string]::IsNullOrEmpty($releaseChannel)) {
69+
$releaseChannel = "latest"
70+
}
71+
Write-Output "RELEASE_CHANNEL=$releaseChannel" >> $Env:GITHUB_OUTPUT
72+
6173
- name: Build package
6274
run: |
6375
npm ci
6476
npm run build
6577
- name: Publish to NPM
66-
run: npm publish
78+
run: npm publish --tag ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}
6779
env:
6880
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6981
- name: Publish git release
7082
env:
7183
GH_TOKEN: ${{ github.token }}
7284
run: |
73-
gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }}
85+
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

Comments
 (0)