diff --git a/.github/workflows/canary-release-pr.yml b/.github/workflows/canary-release-pr.yml index 827f24a2c5f8..659765318fe5 100644 --- a/.github/workflows/canary-release-pr.yml +++ b/.github/workflows/canary-release-pr.yml @@ -1,11 +1,11 @@ name: Publish canary release of PR -run-name: 'Canary release: PR #${{ inputs.pr }}, triggered by ${{ github.triggering_actor }}' +run-name: "Canary release: PR #${{ inputs.pr }}, triggered by ${{ github.triggering_actor }}" on: workflow_dispatch: inputs: pr: - description: 'Pull request number to create a canary release for' + description: "Pull request number to create a canary release for" required: true type: number @@ -58,7 +58,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version-file: '.nvmrc' + node-version-file: ".nvmrc" - name: Cache dependencies uses: actions/cache@v3 with: @@ -91,10 +91,10 @@ jobs: with: githubToken: ${{ secrets.GH_TOKEN }} prNumber: ${{ inputs.pr }} - find: 'CANARY_RELEASE_SECTION' + find: "CANARY_RELEASE_SECTION" isHtmlCommentTag: true replace: | - This pull request has been released as version [`${{ steps.version.outputs.next-version }}`](https://npmjs.com/package/@storybook/cli/v/${{ steps.version.outputs.next-version }}). Install it by pinning all your Storybook dependencies to that version. + 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 diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 8738f1bfea6a..29115c4244cf 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -110,13 +110,14 @@ export const doUpgrade = async ({ }: UpgradeOptions) => { const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr }); - const currentVersion = versions['@storybook/cli']; const beforeVersion = await getStorybookCoreVersion(); + const currentVersion = versions['@storybook/cli']; + const isCanary = currentVersion.startsWith('0.0.0'); - if (lt(currentVersion, beforeVersion)) { + if (!isCanary && lt(currentVersion, beforeVersion)) { throw new UpgradeStorybookToLowerVersionError({ beforeVersion, currentVersion }); } - if (eq(currentVersion, beforeVersion)) { + if (!isCanary && eq(currentVersion, beforeVersion)) { throw new UpgradeStorybookToSameVersionError({ beforeVersion }); } @@ -166,12 +167,12 @@ export const doUpgrade = async ({ // only upgrade packages that are in the monorepo return dependency in versions; }) as Array; - return monorepoDependencies.map( - (dependency) => - // add ^ modifier to the version if this is the latest and stable version - // example output: @storybook/react@^8.0.0 - `${dependency}@${!isOutdated || isPrerelease ? '^' : ''}${versions[dependency]}` - ); + return monorepoDependencies.map((dependency) => { + /* add ^ modifier to the version if this is the latest stable or prerelease version + example outputs: @storybook/react@^8.0.0 */ + const maybeCaret = (!isOutdated || isPrerelease) && !isCanary ? '^' : ''; + return `${dependency}@${maybeCaret}${versions[dependency]}`; + }); }; const upgradedDependencies = toUpgradedDependencies(packageJson.dependencies);