From 047a39f643d5c7fb3cc36842d0fb1e9a6100afb8 Mon Sep 17 00:00:00 2001 From: Aleksandr Pasevin Date: Wed, 13 Aug 2025 15:55:31 +0300 Subject: [PATCH] fix(ci): prevent staging workflow from publishing stable versions with rc tags - Add changeset detection to staging workflow to skip RC publishing when no pending changesets exist - Add concurrency controls to prevent staging/release workflow conflicts - Only publish RC snapshots when there are actual changes to test - Prevents stable versions from being incorrectly tagged as 'rc' on npm - Ensures Release workflow can properly publish stable versions with 'latest' tags Fixes issue where Version Packages merge triggered staging workflow to publish stable versions (0.4.0, 0.5.0, etc.) with 'rc' tags instead of 'latest' tags. --- .github/workflows/docker-stg.yaml | 29 +++++++++++++++++++++++++++++ .github/workflows/publish.yml | 5 ++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-stg.yaml b/.github/workflows/docker-stg.yaml index 9ef2a300c..df28b4a15 100644 --- a/.github/workflows/docker-stg.yaml +++ b/.github/workflows/docker-stg.yaml @@ -29,6 +29,11 @@ on: default: 'main' type: string +# Prevent concurrent staging deployments and avoid conflicts with release workflow +concurrency: + group: staging-deployment-${{ github.ref }} + cancel-in-progress: true + permissions: contents: read @@ -74,7 +79,20 @@ jobs: env: NODE_OPTIONS: '--max-old-space-size=8192' + - name: Check for pending changesets + id: changeset-check + run: | + # Check if there are any pending changesets to create snapshots from + if [ -z "$(find .changeset -name '*.md' -not -name 'README.md' -not -name 'config.json')" ]; then + echo "has_changesets=false" >> $GITHUB_OUTPUT + echo "⚠️ No pending changesets found. Skipping RC publishing to prevent stable version pollution." + else + echo "has_changesets=true" >> $GITHUB_OUTPUT + echo "✅ Pending changesets found. Proceeding with RC snapshot creation." + fi + - name: Create RC snapshot version + if: steps.changeset-check.outputs.has_changesets == 'true' run: | # Create RC snapshot version with 'rc' tag pnpm changeset version --snapshot rc @@ -84,14 +102,17 @@ jobs: HUSKY: 0 - name: Rebuild packages after version update + if: steps.changeset-check.outputs.has_changesets == 'true' run: pnpm -r build env: NODE_OPTIONS: '--max-old-space-size=8192' - name: Type check all packages + if: steps.changeset-check.outputs.has_changesets == 'true' run: pnpm -r typecheck - name: Publish RC packages + if: steps.changeset-check.outputs.has_changesets == 'true' run: | # Publish RC packages with dependencies pre-built # Temporarily disable prepublishOnly scripts to skip rebuild during publishing @@ -105,7 +126,15 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} HUSKY: 0 + - name: Skip RC publishing notice + if: steps.changeset-check.outputs.has_changesets == 'false' + run: | + echo "🚫 RC publishing skipped because no pending changesets were found." + echo "This prevents publishing stable versions with 'rc' tags." + echo "Stable versions should only be published by the Release workflow with 'latest' tags." + - name: Update export versions for RC packages + if: steps.changeset-check.outputs.has_changesets == 'true' run: | # Sync versions.ts with the newly published RC versions # This ensures staging exports use correct RC versions (e.g., 0.2.1-rc.123) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 22ee36659..edbd32bf3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,7 +9,10 @@ on: branches: - main -concurrency: ${{ github.workflow }}-${{ github.ref }} +# Prevent concurrent release operations and coordinate with staging workflow +concurrency: + group: release-publishing-${{ github.ref }} + cancel-in-progress: false permissions: contents: write