-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (204 loc) · 8.77 KB
/
Copy pathsplit.yml
File metadata and controls
219 lines (204 loc) · 8.77 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Split Packages
on:
push:
tags:
- 'api-resource/v*.*.*'
- 'framework/v*.*.*'
- 'support/v*.*.*'
- 'http/v*.*.*'
- 'http-client/v*.*.*'
- 'logging/v*.*.*'
- 'mail/v*.*.*'
- 'queue/v*.*.*'
- 'scheduler/v*.*.*'
- 'router/v*.*.*'
- 'view/v*.*.*'
- 'view-php/v*.*.*'
- 'view-ssr/v*.*.*'
- 'razor/v*.*.*'
- 'cache/v*.*.*'
- 'config/v*.*.*'
- 'env/v*.*.*'
- 'events/v*.*.*'
- 'database/v*.*.*'
- 'session/v*.*.*'
- 'auth/v*.*.*'
- 'errors/v*.*.*'
- 'filesystem/v*.*.*'
- 'validation/v*.*.*'
- 'security/v*.*.*'
- 'dumper/v*.*.*'
- 'ssr-bridge/v*.*.*'
- 'skeleton/v*.*.*'
workflow_dispatch:
jobs:
split:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
package:
- id: framework
path: packages/framework
repository: codemonster-ru/annabel-framework
- id: api-resource
path: packages/api-resource
repository: codemonster-ru/api-resource
- id: support
path: packages/support
repository: codemonster-ru/support
- id: http
path: packages/http
repository: codemonster-ru/http
- id: http-client
path: packages/http-client
repository: codemonster-ru/http-client
- id: logging
path: packages/logging
repository: codemonster-ru/logging
- id: mail
path: packages/mail
repository: codemonster-ru/mail
- id: queue
path: packages/queue
repository: codemonster-ru/queue
- id: scheduler
path: packages/scheduler
repository: codemonster-ru/scheduler
- id: router
path: packages/router
repository: codemonster-ru/router
- id: view
path: packages/view
repository: codemonster-ru/view
- id: view-php
path: packages/view-php
repository: codemonster-ru/view-php
- id: view-ssr
path: packages/view-ssr
repository: codemonster-ru/view-ssr
- id: razor
path: packages/razor
repository: codemonster-ru/razor
- id: cache
path: packages/cache
repository: codemonster-ru/cache
- id: config
path: packages/config
repository: codemonster-ru/config-php
- id: env
path: packages/env
repository: codemonster-ru/env
- id: events
path: packages/events
repository: codemonster-ru/events
- id: database
path: packages/database
repository: codemonster-ru/database
- id: session
path: packages/session
repository: codemonster-ru/session
- id: auth
path: packages/auth
repository: codemonster-ru/auth
- id: errors
path: packages/errors
repository: codemonster-ru/errors
- id: filesystem
path: packages/filesystem
repository: codemonster-ru/filesystem
- id: validation
path: packages/validation
repository: codemonster-ru/validation
- id: security
path: packages/security
repository: codemonster-ru/security
- id: dumper
path: packages/dumper
repository: codemonster-ru/dumper
- id: ssr-bridge
path: packages/ssr-bridge
repository: codemonster-ru/ssr-bridge
- id: skeleton
path: skeleton/annabel-skeleton
repository: codemonster-ru/annabel-skeleton
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate split token
run: |
if [ -z "${MONOREPO_SPLIT_TOKEN}" ]; then
echo "MONOREPO_SPLIT_TOKEN secret is required to push split repositories."
exit 1
fi
env:
MONOREPO_SPLIT_TOKEN: ${{ secrets.MONOREPO_SPLIT_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Parse package tag
id: tag
if: github.ref_type == 'tag'
run: |
PACKAGE_ID="${GITHUB_REF_NAME%%/*}"
VERSION_TAG="${GITHUB_REF_NAME#*/}"
echo "package_id=${PACKAGE_ID}" >> "$GITHUB_OUTPUT"
echo "version_tag=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
- name: Split package
id: split
if: github.ref_type != 'tag' || matrix.package.id == steps.tag.outputs.package_id
run: |
SPLIT_SHA=$(git subtree split --prefix="${PACKAGE_PATH}" "${GITHUB_SHA}")
echo "sha=${SPLIT_SHA}" >> "$GITHUB_OUTPUT"
env:
PACKAGE_PATH: ${{ matrix.package.path }}
- name: Push main branch
if: github.ref_type == 'branch'
run: |
REMOTE_URL="https://x-access-token:${MONOREPO_SPLIT_TOKEN}@github.com/${TARGET_REPOSITORY}.git"
git push "$REMOTE_URL" "${SPLIT_SHA}:refs/heads/main" --force
env:
MONOREPO_SPLIT_TOKEN: ${{ secrets.MONOREPO_SPLIT_TOKEN }}
SPLIT_SHA: ${{ steps.split.outputs.sha }}
TARGET_REPOSITORY: ${{ matrix.package.repository }}
- name: Push package tag
id: push_tag
if: github.ref_type == 'tag' && matrix.package.id == steps.tag.outputs.package_id
run: |
REMOTE_URL="https://x-access-token:${MONOREPO_SPLIT_TOKEN}@github.com/${TARGET_REPOSITORY}.git"
git tag -f "$VERSION_TAG" "$SPLIT_SHA"
git push "$REMOTE_URL" "refs/tags/${VERSION_TAG}:refs/tags/${VERSION_TAG}"
echo "version_tag=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
env:
MONOREPO_SPLIT_TOKEN: ${{ secrets.MONOREPO_SPLIT_TOKEN }}
SPLIT_SHA: ${{ steps.split.outputs.sha }}
TARGET_REPOSITORY: ${{ matrix.package.repository }}
VERSION_TAG: ${{ steps.tag.outputs.version_tag }}
- name: Extract release notes
if: github.ref_type == 'tag' && matrix.package.id == steps.tag.outputs.package_id
run: |
VERSION="${VERSION_TAG#v}"
CHANGELOG="${PACKAGE_PATH}/CHANGELOG.md"
if [ -f "$CHANGELOG" ]; then
awk "/^## \\[$VERSION\\]/ {flag=1; next} /^## \\[/ {flag=0} flag {print}" "$CHANGELOG" > RELEASE_NOTES.md
fi
if [ ! -s RELEASE_NOTES.md ]; then
echo "Release ${GITHUB_REF_NAME}" > RELEASE_NOTES.md
fi
env:
PACKAGE_PATH: ${{ matrix.package.path }}
VERSION_TAG: ${{ steps.tag.outputs.version_tag }}
- name: Create GitHub Release
if: github.ref_type == 'tag' && matrix.package.id == steps.tag.outputs.package_id
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}