From cf92d4f8f28013120f3f96c9c9f53b852ef9aeb3 Mon Sep 17 00:00:00 2001 From: shadcn Date: Sun, 19 Apr 2026 14:59:14 +0400 Subject: [PATCH] Consolidate release workflows and beta comment handling --- .github/workflows/prerelease-comment.yml | 9 +-- .github/workflows/prerelease.yml | 64 -------------------- .github/workflows/release.yml | 75 +++++++++++++++++++++--- 3 files changed, 71 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/prerelease.yml diff --git a/.github/workflows/prerelease-comment.yml b/.github/workflows/prerelease-comment.yml index 41e7f693a2..238612231b 100644 --- a/.github/workflows/prerelease-comment.yml +++ b/.github/workflows/prerelease-comment.yml @@ -3,7 +3,7 @@ name: Write Beta Release comment on: workflow_run: - workflows: ["Release - Beta"] + workflows: ["Release"] types: - completed @@ -11,12 +11,13 @@ jobs: comment: if: | github.repository_owner == 'shadcn-ui' && - ${{ github.event.workflow_run.conclusion == 'success' }} + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest name: Write comment to the PR steps: - name: "Comment on PR" - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -53,7 +54,7 @@ jobs: ``` - name: "Remove the autorelease label once published" - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml deleted file mode 100644 index d77c975933..0000000000 --- a/.github/workflows/prerelease.yml +++ /dev/null @@ -1,64 +0,0 @@ -# Adapted from create-t3-app. - -name: Release - Beta - -on: - pull_request: - types: [labeled] - branches: - - main - -permissions: - id-token: write - contents: read - -jobs: - prerelease: - if: | - github.repository_owner == 'shadcn-ui' && - contains(github.event.pull_request.labels.*.name, '🚀 autorelease') - name: Build & Publish a beta release to NPM - runs-on: ubuntu-latest - environment: Preview - - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Use PNPM - uses: pnpm/action-setup@v4 - with: - version: 9.0.6 - - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: "https://registry.npmjs.org" - cache: "pnpm" - - - name: Update npm for OIDC support - run: npm install -g npm@latest - - - name: Install NPM Dependencies - run: pnpm install - - - name: Modify package.json version - run: node .github/version-script-beta.js - - - name: Publish Beta to NPM - run: pnpm pub:beta - - - name: get-npm-version - id: package-version - uses: martinbeentjes/npm-get-version-action@main - with: - path: packages/shadcn - - - name: Upload packaged artifact - uses: actions/upload-artifact@v4 - with: - name: npm-package-shadcn@${{ steps.package-version.outputs.current-version }}-pr-${{ github.event.number }} # encode the PR number into the artifact name - path: packages/shadcn/dist/index.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ca6aabeb1..ab09eeb067 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,24 +2,81 @@ name: Release +run-name: ${{ github.event_name == 'pull_request' && format('Release Beta - PR {0}', github.event.number) || 'Release Stable' }} + on: + pull_request: + types: [labeled] + branches: + - main push: branches: - main -permissions: - id-token: write - contents: write - pull-requests: write - jobs: - release: - if: ${{ github.repository_owner == 'shadcn-ui' }} - name: Create a PR for release workflow + prerelease: + if: ${{ github.event_name == 'pull_request' && github.repository_owner == 'shadcn-ui' && contains(github.event.pull_request.labels.*.name, '🚀 autorelease') }} + name: Publish Beta to NPM runs-on: ubuntu-latest + environment: Preview + permissions: + id-token: write + contents: read + steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use PNPM + uses: pnpm/action-setup@v4 + with: + version: 9.0.6 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org" + cache: "pnpm" + + - name: Update npm for OIDC support + run: npm install -g npm@latest + + - name: Install NPM Dependencies + run: pnpm install + + - name: Modify package.json version + run: node .github/version-script-beta.js + + - name: Publish Beta to NPM + run: pnpm pub:beta + + - name: get-npm-version + id: package-version + uses: martinbeentjes/npm-get-version-action@main + with: + path: packages/shadcn + + - name: Upload packaged artifact + uses: actions/upload-artifact@v4 + with: + name: npm-package-shadcn@${{ steps.package-version.outputs.current-version }}-pr-${{ github.event.number }} # encode the PR number into the artifact name + path: packages/shadcn/dist/index.js + + release: + if: ${{ github.event_name == 'push' && github.repository_owner == 'shadcn-ui' }} + name: Create Version PR or Publish Stable Release + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + pull-requests: write + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 with: fetch-depth: 0