Skip to content

Commit

Permalink
docs: changelog of 1.0.0-alpha.0 (#100)
Browse files Browse the repository at this point in the history
* chore: mod pre-publish scripts

 - use local CI run lint,compile,test
 - delete github access token

* chore: add the version.ts file to gitignore

* docs: changelog of 1.0.0-alpha.0

* chore: update .gitignore

* docs: fix changelog lint error
  • Loading branch information
YumoImer authored Sep 5, 2024
1 parent 9cd8c4f commit cbaa87b
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 209 deletions.
1 change: 0 additions & 1 deletion .dumi/preset/components-changelog-cn.json

This file was deleted.

1 change: 0 additions & 1 deletion .dumi/preset/components-changelog-en.json

This file was deleted.

1 change: 0 additions & 1 deletion .dumi/preset/misc-changelog.json

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ server/
# Docs templates
components/version/token-meta.json
components/version/token.json
components/version/version.ts
components/version/version.tsx
.dumi/preset/components-changelog*
.dumi/preset/misc-changelog.json
report.html
dist/
25 changes: 25 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ tag: vVERSION

---

## 1.0.0-alpha.0

`2024-09-05`

- 🔥 New Component Bubble. [#19](https://github.com/ant-design/x/pull/19) [@li-jia-nan](https://github.com/li-jia-nan)
- 🔥 Bubble support direction [#52](https://github.com/ant-design/x/pull/52) [@li-jia-nan](https://github.com/li-jia-nan)
- 🔥 New Component Bubble.List. [#57](https://github.com/ant-design/x/pull/57) [@zombieJ](https://github.com/zombieJ)
- 🔥 New Component Conversations. [#48](https://github.com/ant-design/x/pull/48) [@YumoImer](https://github.com/YumoImer)
- 🔥 New Component Prompts. [#55](https://github.com/ant-design/x/pull/55) [@YumoImer](https://github.com/YumoImer)
- 🔥 New Component Sender. [#46](https://github.com/ant-design/x/pull/46) [@ONLY-yours](https://github.com/ONLY-yours)
- 🔥 New Component ThoughtChain. [#86](https://github.com/ant-design/x/pull/86) [@YumoImer](https://github.com/YumoImer)
- 📦 Use `father` to build. [#84](https://github.com/ant-design/x/pull/84) [@zombieJ](https://github.com/zombieJ)
- 🛠 Fix ThemeContext instances being inconsistent when using `antd` es or lib package. [#88](https://github.com/ant-design/x/pull/88) [@YumoImer](https://github.com/YumoImer)
- 🛠 Refactor: API Naming Conventions [#73](https://github.com/ant-design/x/pull/73) [@zombieJ](https://github.com/zombieJ)
- 🛠 MISC: CI, Github Actions, Publish
- 🛠 [#59](https://github.com/ant-design/x/pull/59) [@zombieJ](https://github.com/zombieJ)
- 🛠 [#62](https://github.com/ant-design/x/pull/62) [@zombieJ](https://github.com/zombieJ)
- 🛠 [#71](https://github.com/ant-design/x/pull/71) [@ONLY-yours](https://github.com/ONLY-yours)
- 🛠 [#72](https://github.com/ant-design/x/pull/72) [@YumoImer](https://github.com/YumoImer)
- 🛠 [#98](https://github.com/ant-design/x/pull/98) [@YumoImer](https://github.com/YumoImer)
- 📖 Update README.md
- 📖 [#81](https://github.com/ant-design/x/pull/81) [@zombieJ](https://github.com/zombieJ)
- 📖 [#82](https://github.com/ant-design/x/pull/82) [@zombieJ](https://github.com/zombieJ)
- 📖 [#61](https://github.com/ant-design/x/pull/61) [@afc163](https://github.com/afc163)

## 0.0.0-alpha.0

`2024-05-10`
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ tag: vVERSION

---

## 1.0.0-alpha.0

`2024-09-05`

- 🔥 新组件 Bubble. [#19](https://github.com/ant-design/x/pull/19) [@li-jia-nan](https://github.com/li-jia-nan)
- 🔥 Bubble 支持方向 [#52](https://github.com/ant-design/x/pull/52) [@li-jia-nan](https://github.com/li-jia-nan)
- 🔥 新组件 Bubble.List. [#57](https://github.com/ant-design/x/pull/57) [@zombieJ](https://github.com/zombieJ)
- 🔥 新组件 Conversations. [#48](https://github.com/ant-design/x/pull/48) [@YumoImer](https://github.com/YumoImer)
- 🔥 新组件 Prompts. [#55](https://github.com/ant-design/x/pull/55) [@YumoImer](https://github.com/YumoImer)
- 🔥 新组件 Sender. [#46](https://github.com/ant-design/x/pull/46) [@ONLY-yours](https://github.com/ONLY-yours)
- 🔥 新组件 ThoughtChain. [#86](https://github.com/ant-design/x/pull/86) [@YumoImer](https://github.com/YumoImer)
- 📦 使用 `father` 构建. [#84](https://github.com/ant-design/x/pull/84) [@zombieJ](https://github.com/zombieJ)
- 🛠 修复使用 `antd` 的 es 或 lib 包时 ThemeContext 实例不一致的问题. [#88](https://github.com/ant-design/x/pull/88) [@YumoImer](https://github.com/YumoImer)
- 🛠 重构:API 命名规范 [#73](https://github.com/ant-design/x/pull/73) [@zombieJ](https://github.com/zombieJ)
- 🛠 杂项:CI、Github Actions、发布
- 🛠 [#59](https://github.com/ant-design/x/pull/59) [@zombieJ](https://github.com/zombieJ)
- 🛠 [#62](https://github.com/ant-design/x/pull/62) [@zombieJ](https://github.com/zombieJ)
- 🛠 [#71](https://github.com/ant-design/x/pull/71) [@ONLY-yours](https://github.com/ONLY-yours)
- 🛠 [#72](https://github.com/ant-design/x/pull/72) [@YumoImer](https://github.com/YumoImer)
- 🛠 [#98](https://github.com/ant-design/x/pull/98) [@YumoImer](https://github.com/YumoImer)
- 📖 更新 README.md
- 📖 [#81](https://github.com/ant-design/x/pull/81) [@zombieJ](https://github.com/zombieJ)
- 📖 [#82](https://github.com/ant-design/x/pull/82) [@zombieJ](https://github.com/zombieJ)
- 📖 [#61](https://github.com/ant-design/x/pull/61) [@afc163](https://github.com/afc163)

## 0.0.0-alpha.0

`2024-05-10`
Expand Down
1 change: 0 additions & 1 deletion components/version/version.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ant-design/x",
"version": "0.0.0-alpha.0",
"version": "1.0.0-alpha.0",
"description": "Crafting AI-driven interfaces with React, seamlessly integrating smart chat components and API services at your fingertips.",
"keywords": [
"AI",
Expand Down
23 changes: 3 additions & 20 deletions scripts/check-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function exitProcess(code = 1) {

async function checkVersion() {
spinner.start('正在检查当前版本是否已经存在');
const { versions } = await fetch('http://registry.npmjs.org/@ant-design/x').then((res: Response) =>
res.json(),
const { versions } = await fetch('http://registry.npmjs.org/@ant-design/x').then(
(res: Response) => res.json(),
);
if (version in versions) {
spinner.fail(chalk.yellow('😈 Current version already exists. Forget update package.json?'));
Expand Down Expand Up @@ -63,34 +63,17 @@ async function checkRemote() {
if (!remote?.includes('ant-design/x')) {
const { value } = await git.getConfig('remote.origin.url');
if (!value?.includes('ant-design/x')) {
spinner.fail(
chalk.red('🧐 Your remote origin is not ant-design/x, did you fork it?'),
);
spinner.fail(chalk.red('🧐 Your remote origin is not ant-design/x, did you fork it?'));
exitProcess();
}
}
spinner.succeed('远程分支检查通过');
}

async function checkToken() {
if (!process.env.GITHUB_ACCESS_TOKEN) {
console.log(
spinner.fail(
chalk.red(
'🚨 请先设置 GITHUB_ACCESS_TOKEN 环境变量到本地,请不要泄露给任何在线页面: https://octokit.github.io/rest.js/v20#authentication',
),
),
);
exitProcess();
}
spinner.succeed('GITHUB_ACCESS_TOKEN 检查通过');
}

export default async function checkRepo() {
const status = await git.status();
await checkVersion();
await checkBranch(status);
await checkCommit(status);
await checkRemote();
await checkToken();
}
197 changes: 13 additions & 184 deletions scripts/pre-publish.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* eslint-disable camelcase, no-async-promise-executor */
import fs from 'node:fs';
import runScript from '@npmcli/run-script';
import { Octokit } from '@octokit/rest';
import AdmZip from 'adm-zip';
import axios from 'axios';
import chalk from 'chalk';
import Spinnies from 'spinnies';

Expand All @@ -12,8 +8,6 @@ import checkRepo from './check-repo';
const { Notification: Notifier } = require('node-notifier');
const simpleGit = require('simple-git');

const blockStatus = ['failure', 'cancelled', 'timed_out'] as const;

const spinner = { interval: 80, frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] };
const spinnies = new Spinnies({ spinner });

Expand Down Expand Up @@ -64,61 +58,13 @@ process.on('SIGINT', () => {
process.exit(1);
});

const emojify = (status: string = '') => {
if (!status) {
return '';
}
const emoji = {
/* status */
completed: '✅',
queued: '🕒',
in_progress: '⌛',
/* conclusion */
success: '✅',
failure: '❌',
neutral: '⚪',
cancelled: '❌',
skipped: '⏭️',
timed_out: '⌛',
action_required: '🔴',
}[status];
return `${emoji || ''} ${(status || '').padEnd(15)}`;
};

const toMB = (bytes: number) => (bytes / 1024 / 1024).toFixed(2);

async function downloadArtifact(msgKey: string, url: string, filepath: string, token?: string) {
const headers: Record<string, string> = {};
if (token) {
headers.Authorization = `token ${token}`;
}

const response = await axios.get(url, {
headers,
responseType: 'arraybuffer',
onDownloadProgress: (progressEvent) => {
const { loaded, total = 0 } = progressEvent;

showMessage(
`下载进度 ${toMB(loaded)}MB/${toMB(total)}MB (${((loaded / total) * 100).toFixed(2)}%)`,
true,
msgKey,
);
},
});

fs.writeFileSync(filepath, Buffer.from(response.data));

return filepath;
}

const runPrePublish = async () => {
await checkRepo();
showMessage(chalk.black.bgGreenBright('本次发布将跳过本地 CI 检查,远程 CI 通过后方可发布'));

const git = simpleGit();
const octokit = new Octokit({ auth: process.env.GITHUB_ACCESS_TOKEN });
const { current: currentBranch } = await git.branch();

// 本地-远程分支同步
showMessage(`正在拉取远程分支 ${currentBranch}`, true);
await git.pull('origin', currentBranch);
showMessage(`成功拉取远程分支 ${currentBranch}`, 'succeed');
Expand All @@ -130,145 +76,28 @@ const runPrePublish = async () => {
const { latest } = await git.log();
const sha = process.env.TARGET_SHA || latest.hash;

// 最后一次 commit 信息
showMessage(`找到本地最新 commit:`, 'succeed');
showMessage(chalk.cyan(` hash: ${sha}`));
showMessage(chalk.cyan(` date: ${latest.date}`));
showMessage(chalk.cyan(` message: ${latest.message}`));
showMessage(chalk.cyan(` author_name: ${latest.author_name}`));

const owner = 'ant-design';
const repo = 'ant-design';
showMessage(`开始检查远程分支 ${currentBranch} 的 CI 状态`, true);

const failureUrlList: string[] = [];
const {
data: { check_runs },
} = await octokit.checks.listForRef({
owner,
repo,
ref: sha,
});
showMessage(`远程分支 CI 状态(${check_runs.length}):`, 'succeed');
check_runs.forEach((run) => {
showMessage(` ${run.name.padEnd(36)} ${emojify(run.status)} ${emojify(run.conclusion || '')}`);
if (blockStatus.some((status) => run.conclusion === status)) {
failureUrlList.push(run.html_url!);
}
});
const conclusions = check_runs.map((run) => run.conclusion);
if (blockStatus.some((status) => conclusions.includes(status))) {
showMessage(chalk.bgRedBright('远程分支 CI 执行异常,无法继续发布,请尝试修复或重试'), 'fail');
showMessage(` 点此查看状态:https://github.com/${owner}/${repo}/commit/${sha}`);

failureUrlList.forEach((url) => {
showMessage(` - ${url}`);
});

process.exit(1);
}

const statuses = check_runs.map((run) => run.status);
if (check_runs.length < 1 || statuses.includes('queued') || statuses.includes('in_progress')) {
showMessage(chalk.bgRedBright('远程分支 CI 还在执行中,请稍候再试'), 'fail');
showMessage(` 点此查看状态:https://github.com/${owner}/${repo}/commit/${sha}`);
process.exit(1);
}
showMessage(`远程分支 CI 已通过`, 'succeed');
// clean up
await runScript({ event: 'clean', path: '.', stdio: 'inherit' });
showMessage(`成功清理构建产物目录`, 'succeed');

// 从 github artifact 中下载产物
const downloadArtifactPromise = Promise.resolve().then(async () => {
showMessage('开始查找远程分支构建产物', true, '[Github]');

const {
data: { workflow_runs },
} = await octokit.rest.actions.listWorkflowRunsForRepo({
owner,
repo,
head_sha: sha,
per_page: 100,
exclude_pull_requests: true,
event: 'push',
status: 'completed',
conclusion: 'success',
head_branch: currentBranch,
});
const testWorkflowRun = workflow_runs.find((run) => run.name === '✅ test');
if (!testWorkflowRun) {
throw new Error('找不到远程构建工作流');
}

const {
data: { artifacts },
} = await octokit.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: testWorkflowRun?.id || 0,
});
const artifact = artifacts.find((item) => item.name === 'build artifacts');
if (!artifact) {
throw new Error('找不到远程构建产物');
}

showMessage(`准备从远程分支下载构建产物`, true, '[Github]');
const { url } = await octokit.rest.actions.downloadArtifact.endpoint({
owner,
repo,
artifact_id: artifact.id,
archive_format: 'zip',
});

// 返回下载后的文件路径
return downloadArtifact('[Github]', url, 'artifacts.zip', process.env.GITHUB_ACCESS_TOKEN);
});
downloadArtifactPromise
.then(() => {
showMessage(`成功下载构建产物`, 'succeed', '[Github]');
})
.catch((e: Error) => {
showMessage(chalk.bgRedBright(e.message), 'fail', '[Github]');
});

// 从 OSS 下载产物
const downloadOSSPromise = Promise.resolve().then(async () => {
const url = `https://antd-visual-diff.oss-cn-shanghai.aliyuncs.com/${sha}/oss-artifacts.zip`;

showMessage(`准备从远程 OSS 下载构建产物`, true, '[OSS]');

// 返回下载后的文件路径
return downloadArtifact('[OSS]', url, 'oss-artifacts.zip');
});
downloadOSSPromise
.then(() => {
showMessage(`成功下载构建产物`, 'succeed', '[OSS]');
})
.catch((e: Error) => {
showMessage(chalk.bgRedBright(e.message), 'fail', '[OSS]');
});

// 任意一个完成,则完成
let firstArtifactFile: string;

try {
// @ts-ignore
firstArtifactFile = await Promise.any([downloadArtifactPromise, downloadOSSPromise]);
} catch (error) {
showMessage(
chalk.bgRedBright(`下载失败,请确认你当前 ${sha.slice(0, 6)} 位于 main 分支中`),
'fail',
);
process.exit(1);
}

showMessage(`成功从远程分支下载构建产物`, 'succeed');
// CI
showMessage(`[CI] 正在执行 lint`, true);
await runScript({ event: 'lint', path: '.', stdio: 'inherit' });
showMessage(`[CI] lint 执行成功`, 'succeed');
showMessage(`[CI] 正在执行 compile`, true);
await runScript({ event: 'compile', path: '.', stdio: 'inherit' });
showMessage(`[CI] compile 执行成功`, 'succeed');
showMessage(`[CI] 正在执行 test`, true);
await runScript({ event: 'test', path: '.', stdio: 'inherit' });
showMessage(`[CI] test 执行成功`, 'succeed');

// unzip
showMessage(`正在解压构建产物`, true);
const zip = new AdmZip(firstArtifactFile);
zip.extractAllTo('./', true);
showMessage(`成功解压构建产物`, 'succeed');
await runScript({ event: 'test:dekko', path: '.', stdio: 'inherit' });
await runScript({ event: 'test:package-diff', path: '.', stdio: 'inherit' });
showMessage(`文件检查通过,准备发布!`, 'succeed');
Expand Down

0 comments on commit cbaa87b

Please sign in to comment.