Skip to content

Commit 624780e

Browse files
committed
Get the npm tag in the preparation job
1 parent 3339b06 commit 624780e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

.github/workflows/publish.yaml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
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
@@ -42,6 +43,20 @@ jobs:
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,24 +73,13 @@ jobs:
5873
node-version-file: package.json
5974
registry-url: "https://registry.npmjs.org"
6075
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
7276

7377
- name: Build package
7478
run: |
7579
npm ci
7680
npm run build
7781
- name: Publish to NPM
78-
run: npm publish --tag ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}
82+
run: npm publish --tag ${{ needs.check.outputs.RELEASE_CHANNEL }}
7983
env:
8084
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8185
- name: Publish git release

0 commit comments

Comments
 (0)