-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (105 loc) · 4.35 KB
/
Copy pathnpm-publish.yml
File metadata and controls
124 lines (105 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: NPM Publish
on:
push:
tags:
- 'v*' # 触发条件:推送以 v 开头的标签 (如 v1.0.2)
workflow_dispatch: # 允许手动触发
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整历史记录
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
scope: '@perlinson'
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Bootstrap packages
run: npx lerna bootstrap --no-ci
- name: Build packages
run: |
npm run build:simple
# 或者逐个构建
cd packages/modernx-core && npx father-build
cd ../modernx-immer && npx father-build
cd ../modernx-loading && npx father-build
cd ../modernx && npx father-build
- name: Check package versions
run: |
echo "Checking package versions..."
node -e "
const fs = require('fs');
const packages = ['modernx-core', 'modernx-immer', 'modernx-loading', 'modernx'];
packages.forEach(pkg => {
const pkgPath = \`packages/\${pkg}/package.json\`;
const pkgJson = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
console.log(\`\${pkg}: \${pkgJson.version}\`);
});
"
- name: Publish to NPM
run: |
echo "Publishing packages to NPM..."
# 按依赖顺序发布
echo "Publishing modernx-core..."
cd packages/modernx-core
npm publish --access public
cd ../..
echo "Publishing modernx..."
cd packages/modernx
npm publish --access public
cd ../..
echo "Publishing modernx-immer..."
cd packages/modernx-immer
npm publish --access public
cd ../..
echo "Publishing modernx-loading..."
cd packages/modernx-loading
npm publish --access public
cd ../..
echo "Publishing modernx-cli..."
cd packages/modernx-cli
npm publish --access public
cd ../..
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Verify publish
run: |
echo "Verifying published packages..."
npm view modernx@$(node -p "require('./packages/modernx/package.json').version")
npm view modernx-core@$(node -p "require('./packages/modernx-core/package.json').version")
npm view modernx-immer@$(node -p "require('./packages/modernx-immer/package.json').version")
npm view modernx-loading@$(node -p "require('./packages/modernx-loading/package.json').version")
npm view modernx-cli@$(node -p "require('./packages/modernx-cli/package.json').version")
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
## 🚀 ModernX Release ${{ github.ref }}
### 📦 Published Packages
- modernx@$(node -p "require('./packages/modernx/package.json').version")
- modernx-core@$(node -p "require('./packages/modernx-core/package.json').version")
- modernx-immer@$(node -p "require('./packages/modernx-immer/package.json').version")
- modernx-loading@$(node -p "require('./packages/modernx-loading/package.json').version")
- modernx-cli@$(node -p "require('./packages/modernx-cli/package.json').version")
### 📋 Changes
See [CHANGELOG.md](https://github.com/perlinson/modernx/blob/main/CHANGELOG.md) for detailed changes.
### 🚀 Installation
\`\`\`bash
npm install modernx@latest
\`\`\`
### 🔗 Links
- [Documentation](https://perlinson.github.io/modernx)
- [NPM Package](https://www.npmjs.com/package/modernx)
- [GitHub Repository](https://github.com/perlinson/modernx)
draft: false
prerelease: false