Skip to content

Commit ffbf70e

Browse files
committed
ci(workflows): add script for full release of alpha test package
1 parent e1de0b3 commit ffbf70e

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Dispatch All Publish Alpha
2+
run-name: Dispatch All Publish Alpha--${{ inputs.version }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: |
9+
输入您将要发布的版本号,
10+
例如: `3.xx.xx`.
11+
required: true
12+
type: string
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.sha }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: windows-latest
20+
outputs:
21+
publishVersion: ${{ steps.parseVersion.outputs.publishVersion }}
22+
steps:
23+
- name: Parse Version
24+
id: parseVersion
25+
uses: actions/github-script@v6
26+
with:
27+
script: |
28+
const version = `${{ inputs.version }}`
29+
if(/^\d\.\d+\.\d+/.test(vserion)) {
30+
throw new Error('版本号格式不正确')
31+
}
32+
const publishVersion = version.slice(2)
33+
core.setOutput('publishVersion', publishVersion)
34+
35+
- name: CheckOut Code
36+
uses: actions/checkout@master
37+
with:
38+
ref: ${{ github.ref_name }}
39+
40+
- name: Setup pnpm
41+
uses: pnpm/action-setup@v2
42+
43+
- name: Setup Node
44+
uses: actions/setup-node@v3
45+
with:
46+
node-version: 20.10.0
47+
registry-url: 'https://registry.npmjs.org'
48+
49+
- name: Get pnpm store directory
50+
id: pnpm-cache
51+
run: |
52+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
53+
54+
- uses: actions/cache@v3
55+
name: Setup pnpm cache
56+
with:
57+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
58+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
59+
restore-keys: |
60+
${{ runner.os }}-pnpm-store-
61+
- name: Install dependencies
62+
run: pnpm i --no-frozen-lockfile
63+
64+
- name: Run Build Components
65+
run: pnpm build:ui -t ${{ steps.parseVersion.outputs.publishVersion }}
66+
67+
- name: Run Build Sass Common
68+
run: pnpm build:ui saas-common -t ${{ steps.parseVersion.outputs.publishVersion }} -d saas
69+
70+
- name: Run Build Theme
71+
run: pnpm build:theme
72+
73+
- name: Run Build Renderless
74+
run: pnpm build:renderless
75+
76+
- name: Run Build ThemeSaas
77+
run: pnpm build:themeSaas
78+
79+
- name: Run Build ThemeMobile
80+
run: pnpm build:themeMobile
81+
82+
- name: Run Build Runtime
83+
run: pnpm build:runtime
84+
85+
- name: Run Release alpha
86+
run: pnpm release:alpha
87+
88+
- name: Publish Vue3 And Vue2 components
89+
run: pnpm pub:all
90+
env:
91+
NODE_AUTH_TOKEN: ${{ secrets.NPM_OPENTINY_VUE_TOKEN }}

internals/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"build:runtime": "pnpm build:entry-app && esno src/index.ts build:runtime",
2222
"// ---------------------全局适配@aurora包名--------------------- ": "",
2323
"release:aurora": "esno src/index.ts release:aurora",
24+
"release:alpha": "esno src/index.ts release:alpha",
2425
"// ----------------------辅助脚本---------------------- ": "",
2526
"create:ui": "esno src/commands/create/create-ui.ts",
2627
"sync-icons": "esno src/commands/create/sync-icons.ts",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { pathFromPackages } from '../build/build-ui'
2+
import path from 'node:path'
3+
import fs from 'fs-extra'
4+
5+
const excludeFiles = ['.png', '.gif', '.jpeg', '.jpg', '.ttf', 'node_modules']
6+
7+
// 递归遍历所有的组件,然后依次修改文件内容
8+
const findAllpage = (packagesPath) => {
9+
if (excludeFiles.some((item) => packagesPath.includes(item)) || !fs.existsSync(packagesPath)) {
10+
return
11+
}
12+
13+
if (fs.statSync(packagesPath).isDirectory()) {
14+
// 循环递归查找子文件夹
15+
fs.readdirSync(packagesPath).forEach((childPatch) => {
16+
findAllpage(path.join(packagesPath, childPatch))
17+
})
18+
} else {
19+
const content = fs.readFileSync(packagesPath).toString('UTF-8' as BufferEncoding)
20+
let result = content.replace(/@opentiny\/vue/g, '@opentinyvue/vue')
21+
22+
fs.writeFileSync(packagesPath, result)
23+
}
24+
}
25+
26+
export const releaseAlpha = () => {
27+
const distLists = ['dist3/', 'dist2/', 'renderless/dist', 'theme/dist', 'theme-mobile/dist', 'theme-saas/dist']
28+
distLists.forEach((item) => {
29+
findAllpage(pathFromPackages(item))
30+
})
31+
}

internals/cli/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { Command, Option } from 'commander'
33
import { createIconSaas } from './commands/create/index.js'
44
import { buildUi, buildEntry, buildRuntime, buildReact, buildEntryReact, chartTheme } from './commands/build'
55
import { releaseAurora } from './commands/release/releaseAurora'
6+
import { releaseAlpha } from './commands/release/releaseAlpha'
67

78
const program = new Command()
89

910
program.command('release:aurora').description('转换为aurora的包').action(releaseAurora)
1011

12+
program.command('release:alpha').description('转换为组织名为@opentinyvue的包').action(releaseAlpha)
13+
1114
program.command('create:icon-saas').description('同步生成 icon-saas').action(createIconSaas)
1215

1316
program.command('build:entry-react').description('生成 react 组件库入口').action(buildEntryReact)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"build:virtual-template": "pnpm --filter @opentiny-internal/unplugin-virtual-template build",
7474
"build:site": "pnpm i -g pnpm && pnpm build:vite-import && pnpm build:virtual-template && pnpm -C examples/sites build",
7575
"release:aurora": "pnpm -C internals/cli release:aurora",
76+
"release:alpha": "pnpm -C internals/cli release:alpha",
7677
"// ---------- 使用pnpm批量发布npm包 ----------": "",
7778
"pub2": "pnpm --filter=\"./packages/dist2/**\" publish --tag v2-latest --no-git-checks --access=public",
7879
"pub3": "pnpm --filter=\"./packages/dist3/**\" publish --no-git-checks --access=public",

0 commit comments

Comments
 (0)