Skip to content

Commit

Permalink
Merge pull request #23571 from storybookjs/fix-wrong-latest-tag
Browse files Browse the repository at this point in the history
Release tooling: Fix getting changes from wrong tag
  • Loading branch information
JReinhold authored Jul 24, 2023
2 parents 6850a8f + 2514ced commit 950df76
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 208 deletions.
392 changes: 195 additions & 197 deletions CHANGELOG.prerelease.md

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion docs/versions/next.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
{"version":"7.2.0-alpha.0","info":{"plain":"- Angular: Make enableProdMode optional - [#23489](https://github.com/storybookjs/storybook/pull/23489), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!\n- Features: For 7.2 - [#23446](https://github.com/storybookjs/storybook/pull/23446), thanks [@ndelangen](https://github.com/ndelangen)!\n- Svelte-vite: Improve error when sveltekit plugins found in non-sveltekit projects - [#23472](https://github.com/storybookjs/storybook/pull/23472), thanks [@yannbf](https://github.com/yannbf)!\n- Svelte-vite: Remove unused import - [#23475](https://github.com/storybookjs/storybook/pull/23475), thanks [@yannbf](https://github.com/yannbf)!"}}
{
"version": "7.2.0-alpha.0",
"info": {
"plain": "- Angular: Make enableProdMode optional - [#23489](https://github.com/storybookjs/storybook/pull/23489), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!\n- Router: Support RegExp in Route component - [#23292](https://github.com/storybookjs/storybook/pull/23292), thanks [@ndelangen](https://github.com/ndelangen)!\n- UI: Improve tabs component, more type correct, allow for FC as title - [#23288](https://github.com/storybookjs/storybook/pull/23288), thanks [@ndelangen](https://github.com/ndelangen)!\n- Addons: Improve code quality by using title as FC & sharing state via useAddonState - [#23298](https://github.com/storybookjs/storybook/pull/23298), thanks [@ndelangen](https://github.com/ndelangen)!\n- InteractionsAddon: Improve code quality by using title as FC & sharing state via useAddonState - [#23291](https://github.com/storybookjs/storybook/pull/23291), thanks [@ndelangen](https://github.com/ndelangen)!\n- UI: Add storyStatus to sidebar UI - [#23342](https://github.com/storybookjs/storybook/pull/23342), thanks [@ndelangen](https://github.com/ndelangen)!\n- Addon API: Add experimental page addon type - [#23307](https://github.com/storybookjs/storybook/pull/23307), thanks [@ndelangen](https://github.com/ndelangen)!\n- UI: refactor Canvas component so we can improve types for PREVIEW addons and TAB addons - [#23311](https://github.com/storybookjs/storybook/pull/23311), thanks [@ndelangen](https://github.com/ndelangen)!\n- UI: Improve Button layout and props - [#23356](https://github.com/storybookjs/storybook/pull/23356), thanks [@cdedreuille](https://github.com/cdedreuille)!\n- Dependencies: Remove references to api and the 2 deprecated channel packages - [#23384](https://github.com/storybookjs/storybook/pull/23384), thanks [@ndelangen](https://github.com/ndelangen)!\n- UI: Show the story status in the search results - [#23441](https://github.com/storybookjs/storybook/pull/23441), thanks [@ndelangen](https://github.com/ndelangen)!\n- UI: Create new form elements in the new Core UI (Input, TextArea, Select) - [#23469](https://github.com/storybookjs/storybook/pull/23469), thanks [@cdedreuille](https://github.com/cdedreuille)!\n- CLI: Improve support of mono repositories - [#23458](https://github.com/storybookjs/storybook/pull/23458), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!\n"
}
}
4 changes: 1 addition & 3 deletions scripts/release/is-pr-frozen.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */
import chalk from 'chalk';
import program from 'commander';
import { simpleGit } from 'simple-git';
import { setOutput } from '@actions/core';
import path from 'path';
import { readJson } from 'fs-extra';
import { getPullInfoFromCommit } from './utils/get-github-info';
import { git } from './utils/git-client';

program
.name('is-pr-frozen')
Expand All @@ -15,8 +15,6 @@ program
.option('-P, --patch', 'Look for patch PR instead of prerelease PR', false)
.option('-V, --verbose', 'Enable verbose logging', false);

const git = simpleGit();

const CODE_DIR_PATH = path.join(__dirname, '..', '..', 'code');
const CODE_PACKAGE_JSON_PATH = path.join(CODE_DIR_PATH, 'package.json');

Expand Down
4 changes: 1 addition & 3 deletions scripts/release/pick-patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import program from 'commander';
import chalk from 'chalk';
import ora from 'ora';
import { simpleGit } from 'simple-git';
import { setOutput } from '@actions/core';
import { git } from './utils/git-client';
import { getUnpickedPRs } from './utils/github-client';

program.name('pick-patches').description('Cherry pick patch PRs back to main');
Expand All @@ -15,8 +15,6 @@ const OWNER = 'storybookjs';
const REPO = 'storybook';
const SOURCE_BRANCH = 'next';

const git = simpleGit();

interface PR {
number: number;
id: string;
Expand Down
5 changes: 2 additions & 3 deletions scripts/release/utils/get-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import chalk from 'chalk';
import semver from 'semver';
import type { PullRequestInfo } from './get-github-info';
import { getPullInfoFromCommit } from './get-github-info';
import { git } from './git-client';
import { getLatestTag, git } from './git-client';
import { getUnpickedPRs } from './github-client';

export const RELEASED_LABELS = {
Expand Down Expand Up @@ -42,8 +42,7 @@ export const getFromCommit = async (from?: string | undefined, verbose?: boolean
let actualFrom = from;
if (!from) {
console.log(`🔍 No 'from' specified, finding latest version tag, fetching all of them...`);
// await git.fetch('origin', ['--all', '--tags']);
const { latest } = await git.tags(['v*', '--sort=-v:refname', '--merged']);
const latest = await getLatestTag();
if (!latest) {
throw new Error(
'Could not automatically detect which commit to generate from, because no version tag was found in the history. Have you fetch tags?'
Expand Down
29 changes: 28 additions & 1 deletion scripts/release/utils/git-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import { simpleGit } from 'simple-git';

export const git = simpleGit();
export const git = simpleGit({
config: [
/**
* ensures that prereleases are listed as earlier than stable releases.
* WITHOUT the config, this is the list of tags:
* v7.1.0-rc.2
* v7.1.0-rc.1
* v7.1.0-rc.0
* v7.1.0-beta.3
* ...
* v7.1.0
* v7.0.2
*
* WITH the config, v7.1.0 is correctly on the top:
* v7.1.0
* v7.1.0-rc.2
* v7.1.0-rc.1
* v7.1.0-rc.0
* v7.1.0-beta.3
* ...
* v7.0.2
*
* The top most tag is considered the "latest", which is used as a starting point for looking for changes for upcoming releases
* See https://stackoverflow.com/a/52680984
*/
'versionsort.suffix=-',
],
});

export async function getLatestTag() {
return (await git.tags(['v*', '--sort=-v:refname', '--merged'])).latest;
Expand Down

0 comments on commit 950df76

Please sign in to comment.