Skip to content

Commit

Permalink
ci(workflows): add script for full release of alpha test package (#2785)
Browse files Browse the repository at this point in the history
* ci(workflows): add script for full release of alpha test package

* fix: 修复检视意见
  • Loading branch information
zzcr authored Jan 13, 2025
1 parent 92e6fec commit 83b8346
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/dispatch-all-publish-alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Dispatch All Publish Alpha
run-name: Dispatch All Publish Alpha--${{ inputs.version }}

on:
workflow_dispatch:
inputs:
version:
description: |
输入您将要发布的版本号,
例如: `3.xx.xx`.
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

jobs:
build:
runs-on: windows-latest
outputs:
publishVersion: ${{ steps.parseVersion.outputs.publishVersion }}
steps:
- name: Parse Version
id: parseVersion
uses: actions/github-script@v6
with:
script: |
const version = `${{ inputs.version }}`
if(!/^\d\.\d+\.\d+/.test(vserion)) {
throw new Error('版本号格式不正确')
}
const publishVersion = version.slice(2)
core.setOutput('publishVersion', publishVersion)
- name: CheckOut Code
uses: actions/checkout@master
with:
ref: ${{ github.ref_name }}

- name: Setup pnpm
uses: pnpm/action-setup@v2

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.10.0
registry-url: 'https://registry.npmjs.org'

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i --no-frozen-lockfile

- name: Run Build Components
run: pnpm build:ui -t ${{ steps.parseVersion.outputs.publishVersion }}

- name: Run Build Sass Common
run: pnpm build:ui saas-common -t ${{ steps.parseVersion.outputs.publishVersion }} -d saas

- name: Run Build Theme
run: pnpm build:theme

- name: Run Build Renderless
run: pnpm build:renderless

- name: Run Build ThemeSaas
run: pnpm build:themeSaas

- name: Run Build ThemeMobile
run: pnpm build:themeMobile

- name: Run Build Runtime
run: pnpm build:runtime

- name: Run Release alpha
run: pnpm release:alpha

- name: Publish Vue3 And Vue2 components
run: pnpm pub:all
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_OPENTINY_VUE_TOKEN }}
1 change: 1 addition & 0 deletions internals/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"build:runtime": "pnpm build:entry-app && esno src/index.ts build:runtime",
"// ---------------------全局适配@aurora包名--------------------- ": "",
"release:aurora": "esno src/index.ts release:aurora",
"release:alpha": "esno src/index.ts release:alpha",
"// ----------------------辅助脚本---------------------- ": "",
"create:ui": "esno src/commands/create/create-ui.ts",
"sync-icons": "esno src/commands/create/sync-icons.ts",
Expand Down
31 changes: 31 additions & 0 deletions internals/cli/src/commands/release/releaseAlpha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { pathFromPackages } from '../build/build-ui'
import path from 'node:path'
import fs from 'fs-extra'

const excludeFiles = ['.png', '.gif', '.jpeg', '.jpg', '.ttf', 'node_modules']

// 递归遍历所有的组件,然后依次修改文件内容
const findAllpage = (packagesPath) => {
if (excludeFiles.some((item) => packagesPath.includes(item)) || !fs.existsSync(packagesPath)) {
return
}

if (fs.statSync(packagesPath).isDirectory()) {
// 循环递归查找子文件夹
fs.readdirSync(packagesPath).forEach((childPatch) => {
findAllpage(path.join(packagesPath, childPatch))
})
} else {
const content = fs.readFileSync(packagesPath).toString('UTF-8' as BufferEncoding)
let result = content.replace(/@opentiny\/vue/g, '@opentinyvue/vue')

fs.writeFileSync(packagesPath, result)
}
}

export const releaseAlpha = () => {
const distLists = ['dist3/', 'dist2/', 'renderless/dist', 'theme/dist', 'theme-mobile/dist', 'theme-saas/dist']
distLists.forEach((item) => {
findAllpage(pathFromPackages(item))
})
}
3 changes: 3 additions & 0 deletions internals/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { Command, Option } from 'commander'
import { createIconSaas } from './commands/create/index.js'
import { buildUi, buildEntry, buildRuntime, buildReact, buildEntryReact, chartTheme } from './commands/build'
import { releaseAurora } from './commands/release/releaseAurora'
import { releaseAlpha } from './commands/release/releaseAlpha'

const program = new Command()

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

program.command('release:alpha').description('转换为组织名为@opentinyvue的包').action(releaseAlpha)

program.command('create:icon-saas').description('同步生成 icon-saas').action(createIconSaas)

program.command('build:entry-react').description('生成 react 组件库入口').action(buildEntryReact)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"build:virtual-template": "pnpm --filter @opentiny-internal/unplugin-virtual-template build",
"build:site": "pnpm i -g pnpm && pnpm build:vite-import && pnpm build:virtual-template && pnpm -C examples/sites build",
"release:aurora": "pnpm -C internals/cli release:aurora",
"release:alpha": "pnpm -C internals/cli release:alpha",
"// ---------- 使用pnpm批量发布npm包 ----------": "",
"pub2": "pnpm --filter=\"./packages/dist2/**\" publish --tag v2-latest --no-git-checks --access=public",
"pub3": "pnpm --filter=\"./packages/dist3/**\" publish --no-git-checks --access=public",
Expand Down

0 comments on commit 83b8346

Please sign in to comment.