-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (89 loc) · 3.1 KB
/
Copy pathsplit.yml
File metadata and controls
92 lines (89 loc) · 3.1 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
name: 'Split Packages'
on:
push:
tags:
- 'v*'
workflow_run: # This catches pushes to release branches
workflows: ["Build"]
types:
- completed
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
jobs:
split_packages:
if: >
( github.event_name == 'workflow_run' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.conclusion == 'success'
) || github.event_name != 'workflow_run'
runs-on: ubuntu-latest
name: 'Split Packages'
strategy:
matrix:
package:
-
local_path: 'packages/framework'
split_repository: 'framework'
-
local_path: 'packages/dic'
split_repository: 'di'
-
local_path: 'packages/wake'
split_repository: 'wake'
-
local_path: 'apps/basic-skeleton'
split_repository: 'basic-app-skeleton'
steps:
- uses: actions/checkout@v4
- run: .github/split-preprocess.sh
-
name: 'Split (Branch)'
if: "!startsWith(github.ref, 'refs/tags/')"
uses: danharrin/monorepo-split-github-action@v2.3.0
with:
package_directory: ${{ matrix.package.local_path }}
repository_organization: outboardphp
repository_name: ${{ matrix.package.split_repository }}
branch: ${{ github.ref_name }}
user_name: ${{ github.actor }}
user_email: ${{ github.actor }}@users.noreply.github.com
-
name: Determine Target Branch For Tag
id: determine_branch
if: "startsWith(github.ref, 'refs/tags/')"
run: |
TAG="${GITHUB_REF_NAME}"
# Extract major version (e.g., v1.2.3 -> 1)
if [[ $TAG =~ ^v([0-9]+) ]]; then
MAJOR="${BASH_REMATCH[1]}"
else
echo "Could not extract major version from tag $TAG" >&2
exit 1
fi
# Fetch all tags and determine the latest major version
git fetch --tags
LATEST_MAJOR=$(git tag | grep -E '^v[0-9]+' | sed -E 's/^v([0-9]+).*/\1/' | sort -n | tail -1)
if [[ -z $LATEST_MAJOR ]]; then
echo "Could not determine latest major version from tags" >&2
exit 1
fi
if [[ $MAJOR -eq $LATEST_MAJOR ]]; then
TARGET_BRANCH="main"
else
TARGET_BRANCH="${MAJOR}.x"
fi
echo "Determined target branch is ${TARGET_BRANCH} (latest major: $LATEST_MAJOR)"
echo "branch=${TARGET_BRANCH}" >> $GITHUB_OUTPUT
-
name: 'Split (Tag)'
if: "startsWith(github.ref, 'refs/tags/')"
uses: danharrin/monorepo-split-github-action@v2.3.0
with:
tag: ${{ github.ref_name }}
package_directory: '${{ matrix.package.local_path }}'
repository_organization: outboardphp
repository_name: ${{ matrix.package.split_repository }}
branch: ${{ steps.determine_branch.outputs.branch }}
user_name: ${{ github.actor }}
user_email: ${{ github.actor }}@users.noreply.github.com