feat: 引入多渠道发布策略
- 创建staging分支用于beta发布 - 新增alpha发布工作流(.github/workflows/alpha.yml) - 新增beta发布工作流(.github/workflows/beta.yml) - 添加release:alpha和release:beta脚本 - 为渐进式迁移奠定基础设施 🔄 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
112
.github/workflows/alpha.yml
vendored
Normal file
112
.github/workflows/alpha.yml
vendored
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
name: Alpha Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
alpha:
|
||||||
|
name: Alpha Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20.x'
|
||||||
|
cache: 'pnpm'
|
||||||
|
registry-url: 'https://registry.npmjs.org/'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pnpm run test:ci
|
||||||
|
|
||||||
|
- name: Release alpha version
|
||||||
|
run: |
|
||||||
|
# 确保在正确的分支
|
||||||
|
git checkout develop
|
||||||
|
|
||||||
|
# 获取当前时间戳和短commit hash
|
||||||
|
TIMESTAMP=$(date +%Y%m%d%H%M%S)
|
||||||
|
SHORT_COMMIT=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
# 读取当前版本,移除任何现有的预发布标识
|
||||||
|
CURRENT_VERSION=$(node -p "require('./package.json').version.split('-')[0]")
|
||||||
|
|
||||||
|
# 生成唯一的alpha版本号:base-alpha.timestamp.commit
|
||||||
|
ALPHA_VERSION="${CURRENT_VERSION}-alpha.${TIMESTAMP}.${SHORT_COMMIT}"
|
||||||
|
|
||||||
|
echo "生成alpha版本号: $ALPHA_VERSION"
|
||||||
|
|
||||||
|
# 直接设置版本号
|
||||||
|
npm version $ALPHA_VERSION --no-git-tag-version
|
||||||
|
|
||||||
|
# 使用pnpm发布alpha版本
|
||||||
|
pnpm publish --tag alpha --no-git-checks
|
||||||
|
|
||||||
|
# 输出版本信息供后续步骤使用
|
||||||
|
echo "ALPHA_VERSION=$ALPHA_VERSION" >> $GITHUB_ENV
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Comment on related PRs
|
||||||
|
if: success()
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
// 获取alpha版本号
|
||||||
|
const version = process.env.ALPHA_VERSION;
|
||||||
|
|
||||||
|
// 查找相关的PR
|
||||||
|
const { data: prs } = await github.rest.pulls.list({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
state: 'open',
|
||||||
|
base: 'develop'
|
||||||
|
});
|
||||||
|
|
||||||
|
const comment = `🚀 **Alpha版本已发布!**
|
||||||
|
|
||||||
|
📦 版本号: \`${version}\`
|
||||||
|
🔗 安装命令: \`npx dpml-prompt@${version} <command>\`
|
||||||
|
或者: \`npx dpml-prompt@alpha <command>\`
|
||||||
|
|
||||||
|
📚 使用示例:
|
||||||
|
\`\`\`bash
|
||||||
|
npx dpml-prompt@${version} hello
|
||||||
|
npx dpml-prompt@${version} init
|
||||||
|
npx dpml-prompt@${version} action <roleId>
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
💡 你可以使用这个alpha版本测试最新的develop分支功能。
|
||||||
|
|
||||||
|
⚠️ **迁移提示**: 推荐使用 \`@alpha\` 替代 \`@snapshot\` 进行开发测试。`;
|
||||||
|
|
||||||
|
// 为每个相关PR添加评论
|
||||||
|
for (const pr of prs) {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: pr.number,
|
||||||
|
body: comment
|
||||||
|
});
|
||||||
|
}
|
||||||
137
.github/workflows/beta.yml
vendored
Normal file
137
.github/workflows/beta.yml
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
name: Beta Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- staging
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
beta:
|
||||||
|
name: Beta Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20.x'
|
||||||
|
cache: 'pnpm'
|
||||||
|
registry-url: 'https://registry.npmjs.org/'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pnpm run test:ci
|
||||||
|
|
||||||
|
- name: Release beta version
|
||||||
|
run: |
|
||||||
|
# 确保在正确的分支
|
||||||
|
git checkout staging
|
||||||
|
|
||||||
|
# 读取当前版本,移除任何现有的预发布标识
|
||||||
|
CURRENT_VERSION=$(node -p "require('./package.json').version.split('-')[0]")
|
||||||
|
|
||||||
|
# 检查是否已存在beta版本,如果存在则递增
|
||||||
|
EXISTING_BETA=$(npm view dpml-prompt@beta version 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
if [[ $EXISTING_BETA == $CURRENT_VERSION-beta.* ]]; then
|
||||||
|
# 提取现有beta版本号并递增
|
||||||
|
BETA_NUMBER=$(echo $EXISTING_BETA | sed "s/$CURRENT_VERSION-beta\.//")
|
||||||
|
NEXT_BETA_NUMBER=$((BETA_NUMBER + 1))
|
||||||
|
else
|
||||||
|
# 首个beta版本
|
||||||
|
NEXT_BETA_NUMBER=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 生成beta版本号:base-beta.number
|
||||||
|
BETA_VERSION="${CURRENT_VERSION}-beta.${NEXT_BETA_NUMBER}"
|
||||||
|
|
||||||
|
echo "生成beta版本号: $BETA_VERSION"
|
||||||
|
|
||||||
|
# 直接设置版本号
|
||||||
|
npm version $BETA_VERSION --no-git-tag-version
|
||||||
|
|
||||||
|
# 使用pnpm发布beta版本
|
||||||
|
pnpm publish --tag beta --no-git-checks
|
||||||
|
|
||||||
|
# 输出版本信息供后续步骤使用
|
||||||
|
echo "BETA_VERSION=$BETA_VERSION" >> $GITHUB_ENV
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Comment on related PRs
|
||||||
|
if: success()
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
// 获取beta版本号
|
||||||
|
const version = process.env.BETA_VERSION;
|
||||||
|
|
||||||
|
// 查找相关的PR (staging相关的PR)
|
||||||
|
const { data: prs } = await github.rest.pulls.list({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
state: 'open'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 过滤staging相关的PR
|
||||||
|
const stagingPrs = prs.filter(pr =>
|
||||||
|
pr.base.ref === 'staging' || pr.head.ref === 'staging'
|
||||||
|
);
|
||||||
|
|
||||||
|
const comment = `🎯 **Beta版本已发布!**
|
||||||
|
|
||||||
|
📦 版本号: \`${version}\`
|
||||||
|
🔗 安装命令: \`npx dpml-prompt@${version} <command>\`
|
||||||
|
或者: \`npx dpml-prompt@beta <command>\`
|
||||||
|
|
||||||
|
📚 使用示例:
|
||||||
|
\`\`\`bash
|
||||||
|
npx dpml-prompt@${version} hello
|
||||||
|
npx dpml-prompt@${version} init
|
||||||
|
npx dpml-prompt@${version} action <roleId>
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
💡 这是一个稳定的预览版本,适合用户测试和反馈。
|
||||||
|
|
||||||
|
🔄 **推荐迁移路径**: 从 \`@snapshot\` → \`@beta\` 获得更稳定的体验。`;
|
||||||
|
|
||||||
|
// 为相关PR添加评论
|
||||||
|
for (const pr of stagingPrs) {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: pr.number,
|
||||||
|
body: comment
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有staging相关PR,在最近的develop PR中也通知
|
||||||
|
if (stagingPrs.length === 0) {
|
||||||
|
const developPrs = prs.filter(pr => pr.base.ref === 'develop').slice(0, 3);
|
||||||
|
for (const pr of developPrs) {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: pr.number,
|
||||||
|
body: comment
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,6 +33,8 @@
|
|||||||
"changeset:status": "changeset status",
|
"changeset:status": "changeset status",
|
||||||
"release": "pnpm changeset publish",
|
"release": "pnpm changeset publish",
|
||||||
"release:snapshot": "pnpm changeset version --snapshot snapshot && pnpm changeset publish --tag snapshot",
|
"release:snapshot": "pnpm changeset version --snapshot snapshot && pnpm changeset publish --tag snapshot",
|
||||||
|
"release:alpha": "pnpm changeset version --snapshot alpha && pnpm changeset publish --tag alpha",
|
||||||
|
"release:beta": "pnpm changeset version --snapshot beta && pnpm changeset publish --tag beta",
|
||||||
"version:patch": "pnpm changeset add --type patch",
|
"version:patch": "pnpm changeset add --type patch",
|
||||||
"version:minor": "pnpm changeset add --type minor",
|
"version:minor": "pnpm changeset add --type minor",
|
||||||
"version:major": "pnpm changeset add --type major"
|
"version:major": "pnpm changeset add --type major"
|
||||||
|
|||||||
Reference in New Issue
Block a user