diff --git a/.github/actions/setup-node-and-install/action.yml b/.github/actions/setup-node-and-install/action.yml
new file mode 100644
index 000000000000..c70c0c16e2dc
--- /dev/null
+++ b/.github/actions/setup-node-and-install/action.yml
@@ -0,0 +1,42 @@
+name: 'Setup Node.js and Install Dependencies'
+description: 'Sets up Node.js, caches dependencies, and installs packages for Storybook'
+
+inputs:
+ install-code-deps:
+ description: 'Whether to install code dependencies in addition to script dependencies'
+ required: false
+ default: 'false'
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version-file: '.nvmrc'
+
+ - name: Update npm to latest
+ shell: bash
+ run: npm install -g npm@latest
+
+ - name: Cache dependencies
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.yarn/berry/cache
+ key: yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
+ restore-keys: |
+ yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
+ yarn-v1-${{ hashFiles('scripts/yarn.lock') }}
+ yarn-v1
+
+ - name: Install script dependencies
+ shell: bash
+ working-directory: scripts
+ run: yarn install
+
+ - name: Install code dependencies
+ if: inputs.install-code-deps == 'true'
+ shell: bash
+ working-directory: code
+ run: yarn install
diff --git a/.github/workflows/canary-release-pr.yml b/.github/workflows/canary-release-pr.yml
deleted file mode 100644
index 3e93ef40df5b..000000000000
--- a/.github/workflows/canary-release-pr.yml
+++ /dev/null
@@ -1,130 +0,0 @@
-name: Publish canary release of PR
-run-name: "Canary release: PR #${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}, triggered by ${{ github.triggering_actor }}"
-
-on:
- workflow_dispatch:
- inputs:
- pr:
- description: 'Pull request number to create a canary release for'
- required: true
- type: number
- pull_request:
- types: [opened, synchronize, reopened]
-
-env:
- PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}
- cancel-in-progress: true
-
-permissions:
- pull-requests: write
-
-jobs:
- release-canary:
- name: Release canary version
- runs-on: ubuntu-latest
- environment: release
- if: github.event_name == 'workflow_dispatch' || endsWith(github.head_ref, 'with-canary-release')
- steps:
- - name: Fail if triggering actor is not administrator
- uses: prince-chrismc/check-actor-permissions-action@v2.0.4
- with:
- permission: admin
-
- - name: Get pull request information
- id: info
- env:
- GH_TOKEN: ${{ secrets.GH_TOKEN }}
- run: |
- PR_NUMBER=${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}
- PR_INFO=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json isCrossRepository,headRefOid,headRefName,headRepository,headRepositoryOwner --jq '{isFork: .isCrossRepository, owner: .headRepositoryOwner.login, repoName: .headRepository.name, branch: .headRefName, sha: .headRefOid}')
- echo $PR_INFO
- # Loop through each key-value pair in PR_INFO and set as step output
- for key in $(echo "$PR_INFO" | jq -r 'keys[]'); do
- value=$(echo "$PR_INFO" | jq -r ".$key")
- echo "$key=$value" >> "$GITHUB_OUTPUT"
- done
- echo "repository=$(echo "$PR_INFO" | jq -r ".owner")/$(echo "$PR_INFO" | jq -r ".repoName")" >> $GITHUB_OUTPUT
- echo "shortSha=$(echo "$PR_INFO" | jq -r ".sha" | cut -c 1-8)" >> $GITHUB_OUTPUT
- echo "date=$(date)" >> $GITHUB_OUTPUT
- echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
-
- - name: Checkout
- uses: actions/checkout@v4
- with:
- repository: ${{ steps.info.outputs.isFork == 'true' && steps.info.outputs.repository || null }}
- ref: ${{ steps.info.outputs.sha }}
- token: ${{ secrets.GH_TOKEN }}
-
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version-file: '.nvmrc'
-
- - name: Cache dependencies
- uses: actions/cache@v4
- with:
- path: |
- ~/.yarn/berry/cache
- key: yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- restore-keys: |
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}
- yarn-v1
-
- - name: Install dependencies
- run: yarn task --task=install --start-from=install
-
- - name: Set version
- id: version
- working-directory: scripts
- run: |
- PR_NUMBER=${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}
- yarn release:version --exact 0.0.0-pr-$PR_NUMBER-sha-${{ steps.info.outputs.shortSha }} --verbose
-
- - name: Publish v${{ steps.version.outputs.next-version }}
- env:
- YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- working-directory: scripts
- run: yarn release:publish --tag canary --verbose
-
- - name: Replace Pull Request Body
- # TODO: replace with ivangabriele/find-and-replace-pull-request-body@vX when https://github.com/ivangabriele/find-and-replace-pull-request-body/pull/11 has been released
- uses: mcky/find-and-replace-pull-request-body@v1.1.6-mcky
- with:
- githubToken: ${{ secrets.GH_TOKEN }}
- prNumber: ${{ github.event_name == 'workflow_dispatch' && inputs.pr || '' }}
- find: 'CANARY_RELEASE_SECTION'
- isHtmlCommentTag: true
- replace: |
- This pull request has been released as version `${{ steps.version.outputs.next-version }}`. Try it out in a new sandbox by running `npx storybook@${{ steps.version.outputs.next-version }} sandbox` or in an existing project with `npx storybook@${{ steps.version.outputs.next-version }} upgrade`.
-
- More information
-
- | | |
- | --- | --- |
- | **Published version** | [`${{ steps.version.outputs.next-version }}`](https://npmjs.com/package/storybook/v/${{ steps.version.outputs.next-version }}) |
- | **Triggered by** | @${{ github.triggering_actor }} |
- | **Repository** | [${{ steps.info.outputs.repository }}](https://github.com/${{ steps.info.outputs.repository }}) |
- | **Branch** | [`${{ steps.info.outputs.branch }}`](https://github.com/${{ steps.info.outputs.repository }}/tree/${{ steps.info.outputs.branch }}) |
- | **Commit** | [`${{ steps.info.outputs.shortSha }}`](https://github.com/${{ steps.info.outputs.repository }}/commit/${{ steps.info.outputs.sha }}) |
- | **Datetime** | ${{ steps.info.outputs.date }} (`${{ steps.info.outputs.timestamp }}`) |
- | **Workflow run** | [${{ github.run_id }}](https://github.com/storybookjs/storybook/actions/runs/${{ github.run_id }}) |
-
- To request a new release of this pull request, mention the `@storybookjs/core` team.
-
- _core team members can create a new canary release [here](https://github.com/storybookjs/storybook/actions/workflows/canary-release-pr.yml) or locally with `gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}`_
-
-
- - name: Create failing comment on PR
- if: failure()
- env:
- GH_TOKEN: ${{ secrets.GH_TOKEN }}
- run: |
- PR_NUMBER=${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}
- gh pr comment $PR_NUMBER\
- --repo "${{github.repository }}"\
- --body "Failed to publish canary version of this pull request, triggered by @${{ github.triggering_actor }}. See the failed workflow run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
diff --git a/.github/workflows/generate-sandboxes.yml b/.github/workflows/generate-sandboxes.yml
index 425ae0f1fb44..b30b4a7b7f2f 100644
--- a/.github/workflows/generate-sandboxes.yml
+++ b/.github/workflows/generate-sandboxes.yml
@@ -2,7 +2,7 @@ name: Generate and publish sandboxes
on:
schedule:
- - cron: '2 2 */1 * *'
+ - cron: "2 2 */1 * *"
workflow_dispatch:
# To test fixes on push rather than wait for the scheduling, do the following:
# 1. Uncomment the lines below and add your branch.
@@ -14,8 +14,8 @@ on:
# 4. 👉 DON'T FORGET TO UNDO THE STEPS BEFORE YOU MERGE YOUR CHANGES!
env:
- YARN_ENABLE_IMMUTABLE_INSTALLS: 'false'
- CLEANUP_SANDBOX_NODE_MODULES: 'true'
+ YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
+ CLEANUP_SANDBOX_NODE_MODULES: "true"
defaults:
run:
@@ -32,7 +32,7 @@ jobs:
- uses: actions/setup-node@v4
with:
- node-version-file: '.nvmrc'
+ node-version-file: ".nvmrc"
- name: Setup git user
run: |
@@ -68,7 +68,7 @@ jobs:
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
- uses: Ilshidur/action-discord@master
+ uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554
with:
args: |
The generation of some or all sandboxes on the **next** branch has failed.
@@ -84,7 +84,7 @@ jobs:
- uses: actions/setup-node@v4
with:
- node-version-file: '.nvmrc'
+ node-version-file: ".nvmrc"
- name: Setup git user
run: |
@@ -120,7 +120,7 @@ jobs:
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
- uses: Ilshidur/action-discord@master
+ uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554
with:
args: |
The generation of some or all sandboxes on the **main** branch has failed.
diff --git a/.github/workflows/prepare-non-patch-release.yml b/.github/workflows/prepare-non-patch-release.yml
index c495114d461e..7443d0d4df42 100644
--- a/.github/workflows/prepare-non-patch-release.yml
+++ b/.github/workflows/prepare-non-patch-release.yml
@@ -37,7 +37,7 @@ jobs:
prepare-non-patch-pull-request:
name: Prepare non-patch pull request
runs-on: ubuntu-latest
- environment: release
+ environment: Release
defaults:
run:
working-directory: scripts
@@ -51,26 +51,8 @@ jobs:
fetch-depth: 10000
token: ${{ secrets.GH_TOKEN }}
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Cache dependencies
- uses: actions/cache@v4
- with:
- path: |
- ~/.yarn/berry/cache
- key: yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- restore-keys: |
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}
- yarn-v1
-
- - name: Install Dependencies
- working-directory: .
- run: |
- yarn task --task=install
+ - name: Setup Node.js and Install Dependencies
+ uses: ./.github/actions/setup-node-and-install
- name: Check if pull request is frozen
if: github.event_name != 'workflow_dispatch'
@@ -160,6 +142,6 @@ jobs:
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
- uses: Ilshidur/action-discord@master
+ uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554
with:
args: "The GitHub Action for preparing the release pull request bumping from v${{ steps.bump-version.outputs.current-version }} to v${{ steps.bump-version.outputs.next-version }} (triggered by ${{ github.triggering_actor }}) failed! See run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
diff --git a/.github/workflows/prepare-patch-release.yml b/.github/workflows/prepare-patch-release.yml
index f66258c0d836..f8012dcb7e69 100644
--- a/.github/workflows/prepare-patch-release.yml
+++ b/.github/workflows/prepare-patch-release.yml
@@ -19,7 +19,7 @@ jobs:
prepare-patch-pull-request:
name: Prepare patch pull request
runs-on: ubuntu-latest
- environment: release
+ environment: Release
defaults:
run:
working-directory: scripts
@@ -30,26 +30,8 @@ jobs:
ref: main
token: ${{ secrets.GH_TOKEN }}
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Cache dependencies
- uses: actions/cache@v4
- with:
- path: |
- ~/.yarn/berry/cache
- key: yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- restore-keys: |
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}
- yarn-v1
-
- - name: Install Dependencies
- working-directory: .
- run: |
- yarn task --task=install
+ - name: Setup Node.js and Install Dependencies
+ uses: ./.github/actions/setup-node-and-install
- name: Check if pull request is frozen
if: github.event_name != 'workflow_dispatch'
@@ -183,6 +165,6 @@ jobs:
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
- uses: Ilshidur/action-discord@master
+ uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554
with:
args: "The GitHub Action for preparing the release pull request bumping from v${{ steps.versions.outputs.current }} to v${{ steps.versions.outputs.next }} (triggered by ${{ github.triggering_actor }}) failed! See run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index fda55114e1d7..dd29985a719e 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -1,11 +1,22 @@
name: Publish
-run-name: Publish new version on ${{ github.ref_name }}, triggered by ${{ github.triggering_actor }}
+run-name: "${{ github.event_name == 'workflow_dispatch' && format('Publish Canary on PR #{0}, triggered by {1}', inputs.pr, github.triggering_actor) || format('Publish new version on {0}, triggered by {1}', github.ref_name, github.triggering_actor) }}"
on:
push:
+ # Normal releases, major/minor/patch/prerelease
branches:
- latest-release
- next-release
+ workflow_dispatch:
+ # Manual canary releases on PRs
+ inputs:
+ pr:
+ description: "⚠️ CANARY RELEASES ONLY - Enter the pull request number to create a canary release for"
+ required: true
+ type: number
+ pull_request:
+ # Automated canary releases on PRs with the "with-canary-release"-suffix in the branch name
+ types: [opened, synchronize, reopened]
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
@@ -17,54 +28,35 @@ permissions:
pull-requests: write
concurrency:
- group: ${{ github.workflow }}-${{ github.ref_name }}
+ # Group concurrent runs based on the event type:
+ # - For workflow_dispatch and pull_request: group by PR number to allow only one canary release per PR
+ # - For push events: group by branch name to prevent multiple releases on the same branch
+ group: ${{ github.event_name == 'workflow_dispatch' && format('{0}-{1}', github.workflow, inputs.pr) || github.event_name == 'pull_request' && format('{0}-{1}', github.workflow, github.event.pull_request.number) || format('{0}-{1}', github.workflow, github.ref_name) }}
+ cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' }}
jobs:
- publish:
- name: Publish new version
+ publish-normal:
+ name: Publish normal version
runs-on: ubuntu-latest
+ if: |
+ github.event_name == 'push' &&
+ (github.ref_name == 'latest-release' || github.ref_name == 'next-release') &&
+ contains(github.event.head_commit.message, '[skip ci]') != true
environment: Release
defaults:
run:
working-directory: scripts
steps:
- - name: Cancel if [skip ci]
- if: contains(github.event.head_commit.message, '[skip ci]')
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- # From https://stackoverflow.com/a/75809743
- run: |
- gh run cancel ${{ github.run_id }}
- gh run watch ${{ github.run_id }}
-
- name: Checkout ${{ github.ref_name }}
uses: actions/checkout@v4
with:
fetch-depth: 100
token: ${{ secrets.GH_TOKEN }}
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
-
- - name: Update npm to latest
- run: npm install -g npm@latest
-
- - name: Cache dependencies
- uses: actions/cache@v4
+ - name: Setup Node.js and Install Dependencies
+ uses: ./.github/actions/setup-node-and-install
with:
- path: |
- ~/.yarn/berry/cache
- key: yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- restore-keys: |
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
- yarn-v1-${{ hashFiles('scripts/yarn.lock') }}
- yarn-v1
-
- - name: Install script dependencies
- run: |
- yarn install
+ install-code-deps: true
- name: Cancel all release preparation runs
env:
@@ -73,6 +65,8 @@ jobs:
- name: Apply deferred version bump and commit
working-directory: .
+ env:
+ REF_NAME: ${{ github.ref_name }}
run: |
CURRENT_VERSION=$(cat ./code/package.json | jq '.version')
DEFERRED_NEXT_VERSION=$(cat ./code/package.json | jq '.deferredNextVersion')
@@ -89,7 +83,7 @@ jobs:
git config --global user.email "32066757+storybook-bot@users.noreply.github.com"
git add .
git commit -m "Bump version from $CURRENT_VERSION to $DEFERRED_NEXT_VERSION [skip ci]" || true
- git push origin ${{ github.ref_name }}
+ git push origin "$REF_NAME"
- name: Get current version
id: version
@@ -97,17 +91,16 @@ jobs:
- name: Check if publish is needed
id: publish-needed
- run: yarn release:is-version-published ${{ steps.version.outputs.current-version }}
+ env:
+ CURRENT_VERSION: ${{ steps.version.outputs.current-version }}
+ run: yarn release:is-version-published "$CURRENT_VERSION"
- name: Check release vs prerelease
if: steps.publish-needed.outputs.published == 'false'
id: is-prerelease
- run: yarn release:is-prerelease ${{ steps.version.outputs.current-version }} --verbose
-
- - name: Install code dependencies
- if: steps.publish-needed.outputs.published == 'false'
- working-directory: .
- run: yarn task --task=install --start-from=install
+ env:
+ CURRENT_VERSION: ${{ steps.version.outputs.current-version }}
+ run: yarn release:is-prerelease "$CURRENT_VERSION" --verbose
- name: Publish
if: steps.publish-needed.outputs.published == 'false'
@@ -120,7 +113,9 @@ jobs:
- name: Get changelog for ${{ steps.version.outputs.current-version }}
if: steps.publish-needed.outputs.published == 'false'
id: changelog
- run: yarn release:get-changelog-from-file ${{ steps.version.outputs.current-version }}
+ env:
+ CURRENT_VERSION: ${{ steps.version.outputs.current-version }}
+ run: yarn release:get-changelog-from-file "$CURRENT_VERSION"
# tags are needed to get list of patches to label as picked
- name: Fetch git tags
@@ -138,23 +133,31 @@ jobs:
if: steps.publish-needed.outputs.published == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ CURRENT_VERSION: ${{ steps.version.outputs.current-version }}
+ REPOSITORY: ${{ github.repository }}
+ REF_NAME: ${{ github.ref_name }}
+ CHANGELOG: ${{ steps.changelog.outputs.changelog }}
+ IS_PRERELEASE: ${{ steps.is-prerelease.outputs.prerelease == 'true' && '--prerelease' || '' }}
run: |
gh release create \
- v${{ steps.version.outputs.current-version }} \
- --repo "${{ github.repository }}" \
- --target ${{ github.ref_name }} \
- --title "v${{ steps.version.outputs.current-version }}" \
- --notes "${{ steps.changelog.outputs.changelog }}" \
- ${{ steps.is-prerelease.outputs.prerelease == 'true' && '--prerelease' || '' }}
+ "v$CURRENT_VERSION" \
+ --repo "$REPOSITORY" \
+ --target "$REF_NAME" \
+ --title "v$CURRENT_VERSION" \
+ --notes "$CHANGELOG" \
+ $IS_PRERELEASE
- name: Merge ${{ github.ref_name }} into ${{ steps.target.outputs.target }}
+ env:
+ REF_NAME: ${{ github.ref_name }}
+ TARGET_BRANCH: ${{ steps.target.outputs.target }}
run: |
git config --global user.name "storybook-bot"
git config --global user.email "32066757+storybook-bot@users.noreply.github.com"
- git fetch origin ${{ steps.target.outputs.target }}
- git checkout ${{ steps.target.outputs.target }}
- git merge ${{ github.ref_name }}
- git push origin ${{ steps.target.outputs.target }}
+ git fetch origin "$TARGET_BRANCH"
+ git checkout "$TARGET_BRANCH"
+ git merge "$REF_NAME"
+ git push origin "$TARGET_BRANCH"
- name: Force push from 'next' to 'latest-release' and 'main' on minor/major releases
if: github.ref_name == 'next-release' && steps.is-prerelease.outputs.prerelease == 'false'
@@ -167,13 +170,15 @@ jobs:
- name: Sync CHANGELOG.md from `main` to `next`
if: steps.target.outputs.target == 'main'
working-directory: .
+ env:
+ CURRENT_VERSION: ${{ steps.version.outputs.current-version }}
run: |
git fetch origin next
git checkout next
git pull
git checkout origin/main ./CHANGELOG.md
git add ./CHANGELOG.md
- git commit -m "Update CHANGELOG.md for v${{ steps.version.outputs.current-version }} [skip ci]" || true
+ git commit -m "Update CHANGELOG.md for v$CURRENT_VERSION [skip ci]" || true
git push origin next
# Sync the next.json version file to the main branch so it gets deployed to the docs site
@@ -181,6 +186,8 @@ jobs:
- name: Sync version JSONs from `next-release` to `main`
if: github.ref_name == 'next-release' && steps.is-prerelease.outputs.prerelease == 'true'
working-directory: .
+ env:
+ CURRENT_VERSION: ${{ steps.version.outputs.current-version }}
run: |
VERSION_FILE="./docs/versions/next.json"
git fetch origin main
@@ -188,7 +195,7 @@ jobs:
git pull
git checkout origin/next-release $VERSION_FILE
git add $VERSION_FILE
- git commit -m "Update $VERSION_FILE for v${{ steps.version.outputs.current-version }}"
+ git commit -m "Update $VERSION_FILE for v$CURRENT_VERSION"
git push origin main
- name: Create Sentry release
@@ -206,6 +213,106 @@ jobs:
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
- uses: Ilshidur/action-discord@master
+ uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554
with:
args: "The GitHub Action for publishing version ${{ steps.version.outputs.current-version }} (triggered by ${{ github.triggering_actor }}) failed! See run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
+
+ publish-canary:
+ name: Publish canary version
+ runs-on: ubuntu-latest
+ if: |
+ (
+ github.event_name == 'workflow_dispatch' ||
+ (github.event_name == 'pull_request' && endsWith(github.head_ref, 'with-canary-release'))
+ ) &&
+ contains(github.event.head_commit.message, '[skip ci]') != true
+ environment: Release
+ steps:
+ - name: Fail if triggering actor is not administrator
+ uses: prince-chrismc/check-actor-permissions-action@87c6d9b36c730377858fd9719fbbac1b58fa678d
+ with:
+ permission: admin
+
+ - name: Get pull request information
+ id: info
+ env:
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
+ PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}
+ REPOSITORY: ${{ github.repository }}
+ run: |
+ PR_INFO=$(gh pr view "$PR_NUMBER" --repo "$REPOSITORY" --json isCrossRepository,headRefOid,headRefName,headRepository,headRepositoryOwner --jq '{isFork: .isCrossRepository, owner: .headRepositoryOwner.login, repoName: .headRepository.name, branch: .headRefName, sha: .headRefOid}')
+ echo $PR_INFO
+ # Loop through each key-value pair in PR_INFO and set as step output
+ for key in $(echo "$PR_INFO" | jq -r 'keys[]'); do
+ value=$(echo "$PR_INFO" | jq -r ".$key")
+ echo "$key=$value" >> "$GITHUB_OUTPUT"
+ done
+ echo "repository=$(echo "$PR_INFO" | jq -r ".owner")/$(echo "$PR_INFO" | jq -r ".repoName")" >> $GITHUB_OUTPUT
+ echo "shortSha=$(echo "$PR_INFO" | jq -r ".sha" | cut -c 1-8)" >> $GITHUB_OUTPUT
+ echo "date=$(date)" >> $GITHUB_OUTPUT
+ echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
+
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ repository: ${{ steps.info.outputs.isFork == 'true' && steps.info.outputs.repository || null }}
+ ref: ${{ steps.info.outputs.sha }}
+ token: ${{ secrets.GH_TOKEN }}
+
+ - name: Setup Node.js and Install Dependencies
+ uses: ./.github/actions/setup-node-and-install
+ with:
+ install-code-deps: true
+
+ - name: Set version
+ id: version
+ working-directory: scripts
+ env:
+ PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}
+ SHORT_SHA: ${{ steps.info.outputs.shortSha }}
+ run: |
+ yarn release:version --exact "0.0.0-pr-$PR_NUMBER-sha-$SHORT_SHA" --verbose
+
+ - name: Publish v${{ steps.version.outputs.next-version }}
+ working-directory: scripts
+ run: yarn release:publish --tag canary --verbose
+
+ - name: Replace Pull Request Body
+ uses: ivangabriele/find-and-replace-pull-request-body@042438c
+ with:
+ githubToken: ${{ secrets.GH_TOKEN }}
+ prNumber: ${{ github.event_name == 'workflow_dispatch' && inputs.pr || '' }}
+ find: "CANARY_RELEASE_SECTION"
+ isHtmlCommentTag: true
+ replace: |
+ This pull request has been released as version `${{ steps.version.outputs.next-version }}`. Try it out in a new sandbox by running `npx storybook@${{ steps.version.outputs.next-version }} sandbox` or in an existing project with `npx storybook@${{ steps.version.outputs.next-version }} upgrade`.
+
+ More information
+
+ | | |
+ | --- | --- |
+ | **Published version** | [`${{ steps.version.outputs.next-version }}`](https://npmjs.com/package/storybook/v/${{ steps.version.outputs.next-version }}) |
+ | **Triggered by** | @${{ github.triggering_actor }} |
+ | **Repository** | [${{ steps.info.outputs.repository }}](https://github.com/${{ steps.info.outputs.repository }}) |
+ | **Branch** | [`${{ steps.info.outputs.branch }}`](https://github.com/${{ steps.info.outputs.repository }}/tree/${{ steps.info.outputs.branch }}) |
+ | **Commit** | [`${{ steps.info.outputs.shortSha }}`](https://github.com/${{ steps.info.outputs.repository }}/commit/${{ steps.info.outputs.sha }}) |
+ | **Datetime** | ${{ steps.info.outputs.date }} (`${{ steps.info.outputs.timestamp }}`) |
+ | **Workflow run** | [${{ github.run_id }}](https://github.com/storybookjs/storybook/actions/runs/${{ github.run_id }}) |
+
+ To request a new release of this pull request, mention the `@storybookjs/core` team.
+
+ _core team members can create a new canary release [here](https://github.com/storybookjs/storybook/actions/workflows/publish.yml) or locally with `gh workflow run --repo storybookjs/storybook publish.yml --field pr=${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}`_
+
+
+ - name: Create failing comment on PR
+ if: failure()
+ env:
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
+ PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr || github.event.pull_request.number }}
+ REPOSITORY: ${{ github.repository }}
+ TRIGGERING_ACTOR: ${{ github.triggering_actor }}
+ RUN_ID: ${{ github.run_id }}
+ run: |
+ gh pr comment "$PR_NUMBER"\
+ --repo "$REPOSITORY"\
+ --body "Failed to publish canary version of this pull request, triggered by @$TRIGGERING_ACTOR. See the failed workflow run at: https://github.com/$REPOSITORY/actions/runs/$RUN_ID"
diff --git a/.github/workflows/tests-unit.yml b/.github/workflows/tests-unit.yml
index 0c6a9f61b333..d3b64ec3b796 100644
--- a/.github/workflows/tests-unit.yml
+++ b/.github/workflows/tests-unit.yml
@@ -18,22 +18,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- - name: Set node version
- uses: actions/setup-node@v4
- with:
- node-version-file: ".nvmrc"
- cache: 'yarn'
- cache-dependency-path: |
- code/yarn.lock
- scripts/yarn.lock
-
- - name: install scripts
- run: |
- cd scripts && yarn install
- - name: install code
- run: |
- cd code && yarn install
+ - name: Setup Node.js and Install Dependencies
+ uses: ./.github/actions/setup-node-and-install
+ with:
+ install-code-deps: true
- name: compile
run: yarn task --task compile --start-from=compile
diff --git a/CONTRIBUTING/RELEASING.md b/CONTRIBUTING/RELEASING.md
index 33a74bfdc224..e99dd2a0b47f 100644
--- a/CONTRIBUTING/RELEASING.md
+++ b/CONTRIBUTING/RELEASING.md
@@ -442,7 +442,7 @@ Before you start you should make sure that your working tree is clean and the re
It's possible to release any pull request as a canary release multiple times during development. This is an effective way to try out changes in standalone projects without linking projects together via package managers.
-To create a canary release, a core team member (or anyone else with administrator privileges) must manually trigger the canary release workflow.
+To create a canary release, a core team member (or anyone else with administrator privileges) must manually trigger the publish workflow with the pull request number.
**Before creating a canary release from contributors, the core team member must ensure that the code being released is not malicious.**
@@ -450,7 +450,7 @@ Creating a canary release can either be done via GitHub's UI or the [CLI](https:
### With GitHub UI
-1. Open the workflow UI at https://github.com/storybookjs/storybook/actions/workflows/canary-release-pr.yml
+1. Open the workflow UI at https://github.com/storybookjs/storybook/actions/workflows/publish.yml
2. On the top right corner, click "Run workflow"
3. For "branch", **always select `next`**, regardless of which branch your pull request is on
4. For the pull request number, input the number for the pull request **without a leading #**
@@ -460,7 +460,7 @@ Creating a canary release can either be done via GitHub's UI or the [CLI](https:
The following command will trigger a workflow run - replace `` with the actual pull request number:
```bash
-gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=
+gh workflow run --repo storybookjs/storybook publish.yml --field pr=
```
When the release succeeds, it will update the "Canary release" section of the pull request with information about the release and how to use it (see example [here](https://github.com/storybookjs/storybook/pull/23508)). If it fails, it will create a comment on the pull request, tagging the triggering actor to let them know that it failed (see example [here](https://github.com/storybookjs/storybook/pull/23508#issuecomment-1642850467)).