From 3339b0696cf4e5361ddda30dd0cff853cabd92a8 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 29 Aug 2025 12:34:26 +0200 Subject: [PATCH 1/2] chore: add ability to release prerelease versions --- .github/workflows/publish.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 60c478f5..8391fd3e 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -58,16 +58,28 @@ jobs: node-version-file: package.json registry-url: "https://registry.npmjs.org" cache: "npm" + - name: Get npm tag + id: npm-tag + run: | + $regex = "^v?(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:[^.]*)))?" + $version = "${{ needs.check.outputs.VERSION }}" + $releaseChannel = $groups["prerelease"][0].value + + if ([string]::IsNullOrEmpty($releaseChannel)) { + $releaseChannel = "latest" + } + Write-Output "RELEASE_CHANNEL=$releaseChannel" >> $Env:GITHUB_OUTPUT + - name: Build package run: | npm ci npm run build - name: Publish to NPM - run: npm publish + run: npm publish --tag ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Publish git release env: GH_TOKEN: ${{ github.token }} run: | - gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }} + 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') || ''}} From 624780edb7591f85e1f1a10ad33efdb01b48be7b Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 29 Aug 2025 14:05:27 +0200 Subject: [PATCH 2/2] Get the npm tag in the preparation job --- .github/workflows/publish.yaml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 8391fd3e..ec564825 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -12,6 +12,7 @@ jobs: outputs: VERSION_EXISTS: ${{ steps.check-version.outputs.VERSION_EXISTS }} VERSION: ${{ steps.get-version.outputs.VERSION }} + RELEASE_CHANNEL: ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }} steps: - uses: GitHubSecurityLab/actions-permissions/monitor@v1 - uses: actions/checkout@v5 @@ -42,6 +43,20 @@ jobs: else echo "VERSION_EXISTS=false" >> "$GITHUB_OUTPUT" fi + - name: Get npm tag + id: npm-tag + run: | + $regex = "^v?(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:[^.]*)))?" + $version = "${{ steps.get-version.outputs.VERSION }}" + $releaseChannel = $groups["prerelease"][0].value + + if ([string]::IsNullOrEmpty($releaseChannel)) { + $releaseChannel = "latest" + } + Write-Output "RELEASE_CHANNEL=$releaseChannel" >> $Env:GITHUB_OUTPUT + - name: Output deployment info + run: echo "::notice title=Deployment Info::Deploying version ${{ steps.get-version.outputs.VERSION }} to channel ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }}" + publish: runs-on: ubuntu-latest environment: Production @@ -58,24 +73,13 @@ jobs: node-version-file: package.json registry-url: "https://registry.npmjs.org" cache: "npm" - - name: Get npm tag - id: npm-tag - run: | - $regex = "^v?(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:[^.]*)))?" - $version = "${{ needs.check.outputs.VERSION }}" - $releaseChannel = $groups["prerelease"][0].value - - if ([string]::IsNullOrEmpty($releaseChannel)) { - $releaseChannel = "latest" - } - Write-Output "RELEASE_CHANNEL=$releaseChannel" >> $Env:GITHUB_OUTPUT - name: Build package run: | npm ci npm run build - name: Publish to NPM - run: npm publish --tag ${{ steps.npm-tag.outputs.RELEASE_CHANNEL }} + run: npm publish --tag ${{ needs.check.outputs.RELEASE_CHANNEL }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Publish git release