From 12572a807beaf6c7bcee849aed968eadb69a530b Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 00:43:07 +0200 Subject: [PATCH 01/11] new versioning strategy that doesnt use external tools --- scripts/release/__tests__/version.test.ts | 2 +- scripts/release/version.ts | 115 ++++++++++++++++++---- scripts/utils/workspace.ts | 2 +- 3 files changed, 96 insertions(+), 23 deletions(-) diff --git a/scripts/release/__tests__/version.test.ts b/scripts/release/__tests__/version.test.ts index ccf9cb825438..16461a7d5a5d 100644 --- a/scripts/release/__tests__/version.test.ts +++ b/scripts/release/__tests__/version.test.ts @@ -15,7 +15,7 @@ jest.mock('../../utils/exec'); const { execaCommand } = require('../../utils/exec'); beforeEach(() => { - jest.resetAllMocks(); + jest.clearAllMocks(); }); describe('Version', () => { diff --git a/scripts/release/version.ts b/scripts/release/version.ts index 01c6ffe46027..93f07c4efbee 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -1,15 +1,14 @@ /* eslint-disable no-console */ import { setOutput } from '@actions/core'; -import { ensureDir, readFile, readJson, writeFile, writeJson } from 'fs-extra'; +import { readFile, readJson, writeFile, writeJson } from 'fs-extra'; import chalk from 'chalk'; import path from 'path'; import program from 'commander'; import semver from 'semver'; import { z } from 'zod'; -import dedent from 'ts-dedent'; +import { getWorkspaces } from '../utils/workspace'; import { execaCommand } from '../utils/exec'; import { listOfPackages } from '../utils/list-packages'; -import packageVersionMap from '../../code/lib/cli/src/versions'; program .name('version') @@ -112,24 +111,33 @@ const bumpAllPackageVersions = async (nextVersion: string, verbose?: boolean) => * }); * However that doesn't update peer deps. Trade offs */ - const yarnVersionsPath = path.join(__dirname, '..', '..', 'code', '.yarn', 'versions'); - let yarnDefferedVersionFileContents = dedent`# this file is auto-generated by scripts/release/version.ts - releases: - - `; - Object.keys(packageVersionMap).forEach((packageName) => { - yarnDefferedVersionFileContents += ` '${packageName}': ${nextVersion}\n`; - }); - await ensureDir(yarnVersionsPath); - await writeFile( - path.join(yarnVersionsPath, 'generated-by-versions-script.yml'), - yarnDefferedVersionFileContents - ); + // const yarnVersionsPath = path.join(__dirname, '..', '..', 'code', '.yarn', 'versions'); + // let yarnDefferedVersionFileContents = dedent`# this file is auto-generated by scripts/release/version.ts + // releases: - await execaCommand('yarn version apply --all', { - cwd: CODE_DIR_PATH, - stdio: verbose ? 'inherit' : undefined, - }); + // `; + // Object.keys(packageVersionMap).forEach((packageName) => { + // yarnDefferedVersionFileContents += ` '${packageName}': ${nextVersion}\n`; + // }); + // await ensureDir(yarnVersionsPath); + // await writeFile( + // path.join(yarnVersionsPath, 'generated-by-versions-script.yml'), + // yarnDefferedVersionFileContents + // ); + + // await execaCommand('yarn version apply --all', { + // cwd: CODE_DIR_PATH, + // stdio: verbose ? 'inherit' : undefined, + // }); + // await execaCommand(`yarn lerna version ${nextVersion} --no-git-tag-version --exact --yes`, { + // cwd: CODE_DIR_PATH, + // stdio: verbose ? 'inherit' : undefined, + // }); + // update lock file + // await execaCommand(`yarn task --task install`, { + // cwd: CODE_DIR_PATH, + // stdio: verbose ? 'inherit' : undefined, + // }); console.log(`✅ Bumped version of ${chalk.cyan('all packages')}`); }; @@ -152,6 +160,65 @@ const bumpVersionSources = async (currentVersion: string, nextVersion: string) = console.log(`✅ Bumped versions in:\n ${chalk.cyan(filesToUpdate.join('\n '))}`); }; +const bumpPackageJsons = async ({ + currentVersion, + nextVersion, + verbose, +}: { + currentVersion: string; + nextVersion: string; + verbose?: boolean; +}) => { + console.log(`🤜 Bumping versions and dependencies in ${chalk.cyan('all packages')}...`); + const allPackages = await getWorkspaces(); + // 1. go through all packages in the monorepo + await Promise.all( + allPackages.map(async (pkg) => { + // 2. get the package.json + const packageJsonPath = path.join(CODE_DIR_PATH, pkg.location, 'package.json'); + const packageJson: { + version: string; + dependencies: Record; + devDependencies: Record; + peerDependencies: Record; + [key: string]: any; + } = await readJson(packageJsonPath); + // 3. bump the version + packageJson.version = nextVersion; + const { dependencies, devDependencies, peerDependencies } = packageJson; + + // 4. go through all deps in the package.json + Object.entries({ dependencies, devDependencies, peerDependencies }).forEach( + ([depType, deps]) => { + if (!deps) { + return; + } + // 5. find all storybook deps + Object.entries(deps) + .filter( + ([depName, depVersion]) => + depName.startsWith('@storybook/') && depVersion.includes(currentVersion) + ) + .forEach(([depName, depVersion]) => { + // 6. bump the version of any found storybook dep + const nextDepVersion = depVersion.replace(currentVersion, nextVersion); + if (verbose) { + console.log( + ` Bumping ${chalk.blue(pkg.name)}'s ${chalk.red(depType)} on ${chalk.green( + depName + )} from ${chalk.yellow(depVersion)} to ${chalk.yellow(nextDepVersion)}` + ); + } + packageJson[depType][depName] = nextDepVersion; + }); + } + ); + await writeJson(packageJsonPath, packageJson, { spaces: 2 }); + }) + ); + console.log(`✅ Bumped peer dependency versions in ${chalk.cyan('all packages')}`); +}; + export const run = async (options: unknown) => { if (!validateOptions(options)) { return; @@ -200,8 +267,14 @@ export const run = async (options: unknown) => { console.log(`⏭ Bumping all packages to ${chalk.blue(nextVersion)}...`); await bumpCodeVersion(nextVersion); - await bumpAllPackageVersions(nextVersion, verbose); + // await bumpAllPackageVersions(nextVersion, verbose); await bumpVersionSources(currentVersion, nextVersion); + await bumpPackageJsons({ currentVersion, nextVersion, verbose }); + // update lock file + await execaCommand(`yarn task --task install`, { + cwd: CODE_DIR_PATH, + stdio: verbose ? 'inherit' : undefined, + }); if (process.env.GITHUB_ACTIONS === 'true') { setOutput('current-version', currentVersion); diff --git a/scripts/utils/workspace.ts b/scripts/utils/workspace.ts index c490d593f1b5..3219c558599f 100644 --- a/scripts/utils/workspace.ts +++ b/scripts/utils/workspace.ts @@ -4,7 +4,7 @@ import { execaCommand } from './exec'; export type Workspace = { name: string; location: string }; -async function getWorkspaces() { +export async function getWorkspaces() { const { stdout } = await execaCommand('yarn workspaces list --json', { cwd: CODE_DIRECTORY, shell: true, From 2300ee33dbaab31631ef61188c14e3e0ebffbbe2 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 00:43:59 +0200 Subject: [PATCH 02/11] code deps are not necessary anymore --- .github/workflows/prepare-patch-release.yml | 4 ---- .github/workflows/prepare-prerelease.yml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/prepare-patch-release.yml b/.github/workflows/prepare-patch-release.yml index 26a9453b38ca..ba2478d577b7 100644 --- a/.github/workflows/prepare-patch-release.yml +++ b/.github/workflows/prepare-patch-release.yml @@ -85,10 +85,6 @@ jobs: git config --global user.email 'github-actions[bot]@users.noreply.github.com' yarn release:pick-patches - - name: Install code dependencies - working-directory: . - run: yarn task --task=install --start-from=install - - name: Bump version id: bump-version if: steps.unreleased-changes.outputs.has-changes-to-release == 'true' diff --git a/.github/workflows/prepare-prerelease.yml b/.github/workflows/prepare-prerelease.yml index f597cdad3d0a..1323dbe2b8cd 100644 --- a/.github/workflows/prepare-prerelease.yml +++ b/.github/workflows/prepare-prerelease.yml @@ -104,10 +104,6 @@ jobs: gh run cancel ${{ github.run_id }} gh run watch ${{ github.run_id }} - - name: Install code dependencies - working-directory: . - run: yarn task --task=install --start-from=install - - name: Bump version id: bump-version run: | From a72732bdf10a85ec7ccdcfac0f688284488d3150 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 10:02:33 +0200 Subject: [PATCH 03/11] fix tests, clenaup --- scripts/release/__tests__/version.test.ts | 66 ++++++++++++++++++++--- scripts/release/version.ts | 63 ++++++---------------- 2 files changed, 73 insertions(+), 56 deletions(-) diff --git a/scripts/release/__tests__/version.test.ts b/scripts/release/__tests__/version.test.ts index 16461a7d5a5d..1d57a456102d 100644 --- a/scripts/release/__tests__/version.test.ts +++ b/scripts/release/__tests__/version.test.ts @@ -12,7 +12,19 @@ jest.mock('../../../code/lib/cli/src/versions', () => ({ })); jest.mock('../../utils/exec'); -const { execaCommand } = require('../../utils/exec'); + +jest.mock('../../utils/workspace', () => ({ + getWorkspaces: jest.fn().mockResolvedValue([ + { + name: '@storybook/addon-a11y', + location: 'addons/a11y', + }, + ]), +})); + +jest.spyOn(console, 'log').mockImplementation(() => {}); +jest.spyOn(console, 'warn').mockImplementation(() => {}); +jest.spyOn(console, 'error').mockImplementation(() => {}); beforeEach(() => { jest.clearAllMocks(); @@ -29,6 +41,7 @@ describe('Version', () => { 'version.ts' ); const VERSIONS_PATH = path.join(CODE_DIR_PATH, 'lib', 'cli', 'src', 'versions.ts'); + const A11Y_PACKAGE_JSON_PATH = path.join(CODE_DIR_PATH, 'addons', 'a11y', 'package.json'); it('should throw when release type is invalid', async () => { fsExtra.__setMockFiles({ @@ -152,6 +165,23 @@ describe('Version', () => { [CODE_PACKAGE_JSON_PATH]: JSON.stringify({ version: currentVersion }), [MANAGER_API_VERSION_PATH]: `export const version = "${currentVersion}";`, [VERSIONS_PATH]: `export default { "@storybook/addon-a11y": "${currentVersion}" };`, + [A11Y_PACKAGE_JSON_PATH]: JSON.stringify({ + version: currentVersion, + dependencies: { + '@storybook/core-server': currentVersion, + 'unrelated-package-a': '1.0.0', + }, + devDependencies: { + 'unrelated-package-b': currentVersion, + '@storybook/core-common': `^${currentVersion}`, + }, + peerDependencies: { + '@storybook/preview-api': `*`, + '@storybook/svelte': '0.1.1', + '@storybook/manager-api': `~${currentVersion}`, + }, + }), + [VERSIONS_PATH]: `export default { "@storybook/addon-a11y": "${currentVersion}" };`, }); await version({ releaseType, preId, exact }); @@ -161,18 +191,38 @@ describe('Version', () => { { version: expectedVersion }, { spaces: 2 } ); - expect(fsExtra.writeFile).toHaveBeenCalledWith( - path.join(CODE_DIR_PATH, '.yarn', 'versions', 'generated-by-versions-script.yml'), - expect.stringContaining(expectedVersion) - ); - expect(execaCommand).toHaveBeenCalledWith('yarn version apply --all', { cwd: CODE_DIR_PATH }); expect(fsExtra.writeFile).toHaveBeenCalledWith( MANAGER_API_VERSION_PATH, - expect.stringContaining(expectedVersion) + `export const version = "${expectedVersion}";` ); expect(fsExtra.writeFile).toHaveBeenCalledWith( VERSIONS_PATH, - expect.stringContaining(expectedVersion) + `export default { "@storybook/addon-a11y": "${expectedVersion}" };` + ); + expect(fsExtra.writeJson).toHaveBeenCalledWith( + A11Y_PACKAGE_JSON_PATH, + expect.objectContaining({ + // should update package version + version: expectedVersion, + dependencies: { + // should update storybook dependencies matching current version + '@storybook/core-server': expectedVersion, + 'unrelated-package-a': '1.0.0', + }, + devDependencies: { + // should not update non-storybook dependencies, even if they match current version + 'unrelated-package-b': currentVersion, + // should update dependencies with range modifiers correctly (e.g. ^1.0.0 -> ^2.0.0) + '@storybook/core-common': `^${expectedVersion}`, + }, + peerDependencies: { + // should not update storybook depenedencies if they don't match current version + '@storybook/preview-api': `*`, + '@storybook/svelte': '0.1.1', + '@storybook/manager-api': `~${expectedVersion}`, + }, + }), + { spaces: 2 } ); } ); diff --git a/scripts/release/version.ts b/scripts/release/version.ts index 93f07c4efbee..f3a97677b0ed 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -97,48 +97,6 @@ const bumpCodeVersion = async (nextVersion: string) => { const bumpAllPackageVersions = async (nextVersion: string, verbose?: boolean) => { console.log(`🤜 Bumping version of ${chalk.cyan('all packages')}...`); - /** - * This uses the release workflow outlined by Yarn documentation here: - * https://yarnpkg.com/features/release-workflow - * - * However we build the release YAML file manually instead of using the `yarn version --deferred` command - * This is super hacky, but it's also way faster than invoking `yarn version` for each package, which is 1s each - * - * A simpler alternative is to use Lerna with: - * await execaCommand(`yarn lerna version ${nextVersion} --no-git-tag-version --exact`, { - * cwd: CODE_DIR_PATH, - * stdio: verbose ? 'inherit' : undefined, - * }); - * However that doesn't update peer deps. Trade offs - */ - // const yarnVersionsPath = path.join(__dirname, '..', '..', 'code', '.yarn', 'versions'); - // let yarnDefferedVersionFileContents = dedent`# this file is auto-generated by scripts/release/version.ts - // releases: - - // `; - // Object.keys(packageVersionMap).forEach((packageName) => { - // yarnDefferedVersionFileContents += ` '${packageName}': ${nextVersion}\n`; - // }); - // await ensureDir(yarnVersionsPath); - // await writeFile( - // path.join(yarnVersionsPath, 'generated-by-versions-script.yml'), - // yarnDefferedVersionFileContents - // ); - - // await execaCommand('yarn version apply --all', { - // cwd: CODE_DIR_PATH, - // stdio: verbose ? 'inherit' : undefined, - // }); - // await execaCommand(`yarn lerna version ${nextVersion} --no-git-tag-version --exact --yes`, { - // cwd: CODE_DIR_PATH, - // stdio: verbose ? 'inherit' : undefined, - // }); - // update lock file - // await execaCommand(`yarn task --task install`, { - // cwd: CODE_DIR_PATH, - // stdio: verbose ? 'inherit' : undefined, - // }); - console.log(`✅ Bumped version of ${chalk.cyan('all packages')}`); }; @@ -160,7 +118,7 @@ const bumpVersionSources = async (currentVersion: string, nextVersion: string) = console.log(`✅ Bumped versions in:\n ${chalk.cyan(filesToUpdate.join('\n '))}`); }; -const bumpPackageJsons = async ({ +const bumpAllPackageJsons = async ({ currentVersion, nextVersion, verbose, @@ -169,8 +127,12 @@ const bumpPackageJsons = async ({ nextVersion: string; verbose?: boolean; }) => { - console.log(`🤜 Bumping versions and dependencies in ${chalk.cyan('all packages')}...`); const allPackages = await getWorkspaces(); + console.log( + `🤜 Bumping versions and dependencies in ${chalk.cyan( + `all ${allPackages.length} package.json` + )}'s...` + ); // 1. go through all packages in the monorepo await Promise.all( allPackages.map(async (pkg) => { @@ -186,7 +148,11 @@ const bumpPackageJsons = async ({ // 3. bump the version packageJson.version = nextVersion; const { dependencies, devDependencies, peerDependencies } = packageJson; - + if (verbose) { + console.log( + ` Bumping ${chalk.blue(pkg.name)}'s version to ${chalk.yellow(nextVersion)}` + ); + } // 4. go through all deps in the package.json Object.entries({ dependencies, devDependencies, peerDependencies }).forEach( ([depType, deps]) => { @@ -197,7 +163,9 @@ const bumpPackageJsons = async ({ Object.entries(deps) .filter( ([depName, depVersion]) => - depName.startsWith('@storybook/') && depVersion.includes(currentVersion) + depName.startsWith('@storybook/') && + // ignore storybook dependneices that don't use the current version + depVersion.includes(currentVersion) ) .forEach(([depName, depVersion]) => { // 6. bump the version of any found storybook dep @@ -267,9 +235,8 @@ export const run = async (options: unknown) => { console.log(`⏭ Bumping all packages to ${chalk.blue(nextVersion)}...`); await bumpCodeVersion(nextVersion); - // await bumpAllPackageVersions(nextVersion, verbose); await bumpVersionSources(currentVersion, nextVersion); - await bumpPackageJsons({ currentVersion, nextVersion, verbose }); + await bumpAllPackageJsons({ currentVersion, nextVersion, verbose }); // update lock file await execaCommand(`yarn task --task install`, { cwd: CODE_DIR_PATH, From 948bf3f111953861e596b20da7135105de936952 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 10:04:14 +0200 Subject: [PATCH 04/11] test workflow --- .github/workflows/prepare-prerelease.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/prepare-prerelease.yml b/.github/workflows/prepare-prerelease.yml index 1323dbe2b8cd..f920ac74e4a7 100644 --- a/.github/workflows/prepare-prerelease.yml +++ b/.github/workflows/prepare-prerelease.yml @@ -5,6 +5,7 @@ on: push: branches: - next + - fix-release-publish workflow_dispatch: inputs: release-type: @@ -44,7 +45,7 @@ jobs: - name: Checkout next uses: actions/checkout@v3 with: - ref: next + ref: fix-release-publish # this needs to be set to a high enough number that it will contain the last version tag # as of May 2023, the whole repo had 55K commits fetch-depth: 10000 @@ -149,10 +150,10 @@ jobs: --body "${{ steps.description.outputs.description }}" fi - - name: Report job failure to Discord - if: failure() - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }} - uses: Ilshidur/action-discord@master - 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 }}' + # - name: Report job failure to Discord + # if: failure() + # env: + # DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }} + # uses: Ilshidur/action-discord@master + # 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 }}' From b1f7904b9b2615cda9544ddfa78bd9aeb84abdd4 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 10:17:51 +0200 Subject: [PATCH 05/11] don't use lerna --- scripts/release/version.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/release/version.ts b/scripts/release/version.ts index f3a97677b0ed..ee6b9e88db0b 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -6,9 +6,9 @@ import path from 'path'; import program from 'commander'; import semver from 'semver'; import { z } from 'zod'; +import type { Workspace } from '../utils/workspace'; import { getWorkspaces } from '../utils/workspace'; import { execaCommand } from '../utils/exec'; -import { listOfPackages } from '../utils/list-packages'; program .name('version') @@ -119,23 +119,24 @@ const bumpVersionSources = async (currentVersion: string, nextVersion: string) = }; const bumpAllPackageJsons = async ({ + packages, currentVersion, nextVersion, verbose, }: { + packages: Workspace[]; currentVersion: string; nextVersion: string; verbose?: boolean; }) => { - const allPackages = await getWorkspaces(); console.log( `🤜 Bumping versions and dependencies in ${chalk.cyan( - `all ${allPackages.length} package.json` + `all ${packages.length} package.json` )}'s...` ); // 1. go through all packages in the monorepo await Promise.all( - allPackages.map(async (pkg) => { + packages.map(async (pkg) => { // 2. get the package.json const packageJsonPath = path.join(CODE_DIR_PATH, pkg.location, 'package.json'); const packageJson: { @@ -195,15 +196,14 @@ export const run = async (options: unknown) => { console.log(`🚛 Finding Storybook packages...`); - const [packages, currentVersion] = await Promise.all([listOfPackages(), getCurrentVersion()]); + const [packages, currentVersion] = await Promise.all([getWorkspaces(), getCurrentVersion()]); console.log( `📦 found ${packages.length} storybook packages at version ${chalk.red(currentVersion)}` ); if (verbose) { const formattedPackages = packages.map( - (pkg) => - `${chalk.green(pkg.name.padEnd(60))}${chalk.red(pkg.version)}: ${chalk.cyan(pkg.location)}` + (pkg) => `${chalk.green(pkg.name.padEnd(60))}: ${chalk.cyan(pkg.location)}` ); console.log(`📦 Packages: ${formattedPackages.join('\n ')}`); @@ -236,7 +236,7 @@ export const run = async (options: unknown) => { await bumpCodeVersion(nextVersion); await bumpVersionSources(currentVersion, nextVersion); - await bumpAllPackageJsons({ currentVersion, nextVersion, verbose }); + await bumpAllPackageJsons({ packages, currentVersion, nextVersion, verbose }); // update lock file await execaCommand(`yarn task --task install`, { cwd: CODE_DIR_PATH, From 7cdb0a8b50226739f4c9ff9c4a5886adecddc6ca Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 10:27:46 +0200 Subject: [PATCH 06/11] run yarn task from root --- scripts/release/__tests__/version.test.ts | 5 +++++ scripts/release/version.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/release/__tests__/version.test.ts b/scripts/release/__tests__/version.test.ts index 1d57a456102d..43ef929db0fe 100644 --- a/scripts/release/__tests__/version.test.ts +++ b/scripts/release/__tests__/version.test.ts @@ -12,6 +12,7 @@ jest.mock('../../../code/lib/cli/src/versions', () => ({ })); jest.mock('../../utils/exec'); +const { execaCommand } = require('../../utils/exec'); jest.mock('../../utils/workspace', () => ({ getWorkspaces: jest.fn().mockResolvedValue([ @@ -224,6 +225,10 @@ describe('Version', () => { }), { spaces: 2 } ); + expect(execaCommand).toHaveBeenCalledWith('yarn task --task=install', { + cwd: path.join(CODE_DIR_PATH, '..'), + stdio: undefined, + }); } ); }); diff --git a/scripts/release/version.ts b/scripts/release/version.ts index ee6b9e88db0b..9d658ff2e3e5 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -237,11 +237,13 @@ export const run = async (options: unknown) => { await bumpCodeVersion(nextVersion); await bumpVersionSources(currentVersion, nextVersion); await bumpAllPackageJsons({ packages, currentVersion, nextVersion, verbose }); - // update lock file - await execaCommand(`yarn task --task install`, { - cwd: CODE_DIR_PATH, + + console.log(`⬆️ Updating lock file with ${chalk.blue('yarn install')}`); + await execaCommand(`yarn task --task=install`, { + cwd: path.join(__dirname, '..', '..'), stdio: verbose ? 'inherit' : undefined, }); + console.log(`✅ Updated lock file with ${chalk.blue('yarn install')}`); if (process.env.GITHUB_ACTIONS === 'true') { setOutput('current-version', currentVersion); From ee7e0c38206dd7ffba6aabe565b693cbad811012 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 10:47:24 +0200 Subject: [PATCH 07/11] try raw yarn install --- scripts/release/version.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release/version.ts b/scripts/release/version.ts index 9d658ff2e3e5..2b442319d454 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -239,8 +239,8 @@ export const run = async (options: unknown) => { await bumpAllPackageJsons({ packages, currentVersion, nextVersion, verbose }); console.log(`⬆️ Updating lock file with ${chalk.blue('yarn install')}`); - await execaCommand(`yarn task --task=install`, { - cwd: path.join(__dirname, '..', '..'), + await execaCommand(`yarn install`, { + cwd: path.join(CODE_DIR_PATH), stdio: verbose ? 'inherit' : undefined, }); console.log(`✅ Updated lock file with ${chalk.blue('yarn install')}`); From cad930310fc22b3eac7e0584681cbd36e0277bce Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 10:50:56 +0200 Subject: [PATCH 08/11] install everything in CI --- .github/workflows/prepare-prerelease.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prepare-prerelease.yml b/.github/workflows/prepare-prerelease.yml index f920ac74e4a7..67a737ed4520 100644 --- a/.github/workflows/prepare-prerelease.yml +++ b/.github/workflows/prepare-prerelease.yml @@ -66,9 +66,10 @@ jobs: yarn-v1-${{ hashFiles('scripts/yarn.lock') }} yarn-v1 - - name: Install Script Dependencies + - name: Install Dependencies + working-directory: . run: | - yarn install + yarn task --task=install - name: Check if pull request is frozen if: github.event_name != 'workflow_dispatch' From 1608464a90f42c74c7b729797f39c5c3bab1439f Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 11:26:15 +0200 Subject: [PATCH 09/11] include "Dependencies" as known label --- code/package.json | 4 ---- scripts/release/generate-pr-description.ts | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/code/package.json b/code/package.json index ed081b15a576..7bc9b0c6fa31 100644 --- a/code/package.json +++ b/code/package.json @@ -323,10 +323,6 @@ [ "dependencies", "Dependency Upgrades" - ], - [ - "other", - "Other" ] ] } diff --git a/scripts/release/generate-pr-description.ts b/scripts/release/generate-pr-description.ts index b36fd7fc7165..8e49b17c3e73 100644 --- a/scripts/release/generate-pr-description.ts +++ b/scripts/release/generate-pr-description.ts @@ -48,6 +48,7 @@ const LABELS_BY_IMPORTANCE = { 'feature request': '✨ Feature Request', bug: '🐛 Bug', maintenance: '🔧 Maintenance', + dependencies: '📦 Dependencies', documentation: '📝 Documentation', build: '🏗️ Build', unknown: '❔ Missing Label', From b784bf28f5ba4ed7b5e2af197f04859670292efb Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 11:33:25 +0200 Subject: [PATCH 10/11] allow lock file updates in CI --- scripts/release/__tests__/version.test.ts | 4 ++-- scripts/release/version.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/release/__tests__/version.test.ts b/scripts/release/__tests__/version.test.ts index 43ef929db0fe..c33c5fc31b8b 100644 --- a/scripts/release/__tests__/version.test.ts +++ b/scripts/release/__tests__/version.test.ts @@ -225,8 +225,8 @@ describe('Version', () => { }), { spaces: 2 } ); - expect(execaCommand).toHaveBeenCalledWith('yarn task --task=install', { - cwd: path.join(CODE_DIR_PATH, '..'), + expect(execaCommand).toHaveBeenCalledWith('yarn install --mode=update-lockfile', { + cwd: path.join(CODE_DIR_PATH), stdio: undefined, }); } diff --git a/scripts/release/version.ts b/scripts/release/version.ts index 2b442319d454..03f608567392 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -238,12 +238,12 @@ export const run = async (options: unknown) => { await bumpVersionSources(currentVersion, nextVersion); await bumpAllPackageJsons({ packages, currentVersion, nextVersion, verbose }); - console.log(`⬆️ Updating lock file with ${chalk.blue('yarn install')}`); - await execaCommand(`yarn install`, { + console.log(`⬆️ Updating lock file with ${chalk.blue('yarn install --mode=update-lockfile')}`); + await execaCommand(`yarn install --mode=update-lockfile`, { cwd: path.join(CODE_DIR_PATH), stdio: verbose ? 'inherit' : undefined, }); - console.log(`✅ Updated lock file with ${chalk.blue('yarn install')}`); + console.log(`✅ Updated lock file with ${chalk.blue('yarn install --mode=update-lockfile')}`); if (process.env.GITHUB_ACTIONS === 'true') { setOutput('current-version', currentVersion); From 05b258d1fd714d1004a19cc4c20d9d728e15d7ed Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 9 Jun 2023 11:39:48 +0200 Subject: [PATCH 11/11] revert workflow debugs --- .github/workflows/prepare-patch-release.yml | 5 +++-- .github/workflows/prepare-prerelease.yml | 17 ++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/prepare-patch-release.yml b/.github/workflows/prepare-patch-release.yml index ba2478d577b7..d5a8ca655af6 100644 --- a/.github/workflows/prepare-patch-release.yml +++ b/.github/workflows/prepare-patch-release.yml @@ -44,9 +44,10 @@ jobs: yarn-v1-${{ hashFiles('scripts/yarn.lock') }} yarn-v1 - - name: Install Script Dependencies + - name: Install Dependencies + working-directory: . run: | - yarn install + yarn task --task=install - name: Check if pull request is frozen if: github.event_name != 'workflow_dispatch' diff --git a/.github/workflows/prepare-prerelease.yml b/.github/workflows/prepare-prerelease.yml index 67a737ed4520..932c4b31f64f 100644 --- a/.github/workflows/prepare-prerelease.yml +++ b/.github/workflows/prepare-prerelease.yml @@ -5,7 +5,6 @@ on: push: branches: - next - - fix-release-publish workflow_dispatch: inputs: release-type: @@ -45,7 +44,7 @@ jobs: - name: Checkout next uses: actions/checkout@v3 with: - ref: fix-release-publish + ref: next # this needs to be set to a high enough number that it will contain the last version tag # as of May 2023, the whole repo had 55K commits fetch-depth: 10000 @@ -151,10 +150,10 @@ jobs: --body "${{ steps.description.outputs.description }}" fi - # - name: Report job failure to Discord - # if: failure() - # env: - # DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }} - # uses: Ilshidur/action-discord@master - # 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 }}' + - name: Report job failure to Discord + if: failure() + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }} + uses: Ilshidur/action-discord@master + 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 }}'