-
Notifications
You must be signed in to change notification settings - Fork 7
190 lines (168 loc) · 7.78 KB
/
Copy pathsync.yml
File metadata and controls
190 lines (168 loc) · 7.78 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: SmartAdmin Sync
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: read
concurrency:
group: smartadmin-sync-${{ github.ref }}
cancel-in-progress: true
env:
TARGET_BRANCH: master
SYNC_SOURCE_BEFORE: ${{ github.event.before }}
SMART_ADMIN_REPO: zoujingli/SmartAdmin
SMART_ADMIN_LIBRARY_REPO: zoujingli/SmartAdminLibrary
SMART_ADMIN_BUILDER_REPO: zoujingli/SmartAdminBuilder
SMARTADMIN_RELEASE_DB_HOST: 127.0.0.1
SMARTADMIN_RELEASE_DB_PORT: 3306
SMARTADMIN_RELEASE_DB_USERNAME: root
SMARTADMIN_RELEASE_DB_PASSWORD: root
# 公开仓导出校验会执行 composer web:build,其中 vue-tsc 需要高于 Node 默认堆限制。
NODE_OPTIONS: --max-old-space-size=4096
jobs:
sync:
# 该工作流会同步到公开 SmartAdmin 仓库;公开仓收到 Bot 推送时必须跳过,避免反向同步或缺少私有导出脚本导致失败。
if: github.repository == 'zoujingli/SmartAdminDeveloper'
name: Export and sync public repositories
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=10
steps:
- name: Checkout SmartAdminDeveloper
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve sync version
id: version
shell: bash
run: |
VERSION="$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || true)"
if [[ -z "$VERSION" ]]; then
VERSION="v1.0.0"
fi
echo "name=$VERSION" >> "$GITHUB_OUTPUT"
echo "composer_version=${VERSION#v}" >> "$GITHUB_OUTPUT"
echo "short_sha=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"
{
echo 'source_subject<<SUBJECT'
git log -1 --pretty=%s
echo 'SUBJECT'
} >> "$GITHUB_OUTPUT"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: mbstring, pdo, pdo_mysql, redis, zlib, bcmath, openssl, zip, opcache
tools: composer:v2
coverage: none
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Enable pnpm
run: |
npm install -g pnpm@10.28.2
pnpm --version
- name: Export SmartAdminLibrary
run: .github/tools/release/export-library.sh "$PWD" "$RUNNER_TEMP/SmartAdminLibrary" "${{ steps.version.outputs.name }}"
- name: Validate SmartAdminLibrary export
working-directory: ${{ runner.temp }}/SmartAdminLibrary
run: |
composer validate --strict
composer install --no-interaction --prefer-dist --optimize-autoloader
chmod +x "$GITHUB_WORKSPACE/bin/smart.php" "$GITHUB_WORKSPACE/bin/swoole-linux-x64"
"$GITHUB_WORKSPACE/bin/smart.php" runtime vendor/bin/phpunit
"$GITHUB_WORKSPACE/bin/smart.php" runtime vendor/bin/phpstan analyse --memory-limit=1G
- name: Sync SmartAdminLibrary repository
id: sync_library
env:
GH_TOKEN: ${{ secrets.SMART_ADMIN_RELEASE_TOKEN }}
SYNC_SOURCE_SUBJECT: ${{ steps.version.outputs.source_subject }}
run: |
gh repo view "$SMART_ADMIN_LIBRARY_REPO" >/dev/null 2>&1 || gh repo create "$SMART_ADMIN_LIBRARY_REPO" --public --description 'SmartAdmin base library package'
.github/tools/release/sync-target-repo.sh \
"$SMART_ADMIN_LIBRARY_REPO" \
"$RUNNER_TEMP/SmartAdminLibrary" \
"" \
"同步: SmartAdminLibrary ${SYNC_SOURCE_SUBJECT}"
- name: Export SmartAdminBuilder
run: .github/tools/release/export-builder.sh "$PWD" "$RUNNER_TEMP/SmartAdminBuilder" "${{ steps.version.outputs.name }}"
- name: Validate SmartAdminBuilder export
working-directory: ${{ runner.temp }}/SmartAdminBuilder
run: |
composer validate --strict
composer install --no-interaction --prefer-dist --optimize-autoloader
vendor/bin/phpunit
vendor/bin/phpstan analyse --memory-limit=1G
- name: Sync SmartAdminBuilder repository
id: sync_builder
env:
GH_TOKEN: ${{ secrets.SMART_ADMIN_RELEASE_TOKEN }}
SYNC_SOURCE_SUBJECT: ${{ steps.version.outputs.source_subject }}
run: |
gh repo view "$SMART_ADMIN_BUILDER_REPO" >/dev/null 2>&1 || gh repo create "$SMART_ADMIN_BUILDER_REPO" --public --description 'SmartAdmin Phar/SFX builder package'
.github/tools/release/sync-target-repo.sh \
"$SMART_ADMIN_BUILDER_REPO" \
"$RUNNER_TEMP/SmartAdminBuilder" \
"" \
"同步: SmartAdminBuilder ${SYNC_SOURCE_SUBJECT}"
- name: Prepare package exports for SmartAdmin validation
run: |
# Library/Builder 已单独校验;公开 SmartAdmin 只需要源码 path 包。
# 这里删除包内 vendor 和 tests,避免 Hyperf 在根项目 DI 扫描阶段递归扫描依赖包测试夹具。
rm -rf \
"$RUNNER_TEMP/SmartAdminLibrary/vendor" \
"$RUNNER_TEMP/SmartAdminLibrary/tests" \
"$RUNNER_TEMP/SmartAdminBuilder/vendor" \
"$RUNNER_TEMP/SmartAdminBuilder/tests"
- name: Export SmartAdmin
run: .github/tools/release/export-smart-admin.sh "$PWD" "$RUNNER_TEMP/SmartAdmin" "${{ steps.version.outputs.name }}"
- name: Validate SmartAdmin export
working-directory: ${{ runner.temp }}/SmartAdmin
env:
SYNC_COMPOSER_VERSION: ${{ steps.version.outputs.composer_version }}
run: |
composer config --global repositories.smart-admin-library "{\"type\":\"path\",\"url\":\"$RUNNER_TEMP/SmartAdminLibrary\",\"options\":{\"versions\":{\"zoujingli/smart-admin-library\":\"$SYNC_COMPOSER_VERSION\"}}}"
composer config --global repositories.smart-admin-builder "{\"type\":\"path\",\"url\":\"$RUNNER_TEMP/SmartAdminBuilder\",\"options\":{\"versions\":{\"zoujingli/smart-admin-builder\":\"$SYNC_COMPOSER_VERSION\"}}}"
composer validate --strict
composer install --dry-run --no-interaction --prefer-dist --ignore-platform-req=ext-opcache
composer install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=ext-opcache
composer test
composer analyse
(cd web && pnpm install --frozen-lockfile)
composer web:build
composer docs:check
- name: Sync SmartAdmin repository
id: sync_smart_admin
env:
GH_TOKEN: ${{ secrets.SMART_ADMIN_RELEASE_TOKEN }}
SYNC_SOURCE_SUBJECT: ${{ steps.version.outputs.source_subject }}
run: |
gh repo view "$SMART_ADMIN_REPO" >/dev/null 2>&1 || gh repo create "$SMART_ADMIN_REPO" --public --description 'SmartAdmin open-source administration framework'
.github/tools/release/sync-target-repo.sh \
"$SMART_ADMIN_REPO" \
"$RUNNER_TEMP/SmartAdmin" \
"" \
"同步: SmartAdmin ${SYNC_SOURCE_SUBJECT}"
- name: Sync summary
run: |
cat <<SUMMARY >> "$GITHUB_STEP_SUMMARY"
## SmartAdmin code sync ${{ steps.version.outputs.short_sha }}
- SmartAdminLibrary changed: ${{ steps.sync_library.outputs.changed }}
- SmartAdminBuilder changed: ${{ steps.sync_builder.outputs.changed }}
- SmartAdmin changed: ${{ steps.sync_smart_admin.outputs.changed }}
- Version constraint baseline: ${{ steps.version.outputs.name }}
- Tag publishing is intentionally skipped in this workflow. Push a `v*` tag to run the release workflow.
SUMMARY