66permissions :
77 contents : write
88
9- # env:
10- # GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
11-
129jobs :
10+ # Define a basic job that passes the manually ordered package list to the next job
11+ setup :
12+ runs-on : ubuntu-latest
13+ outputs :
14+ package_order : ${{ steps.set-order.outputs.package_order }}
15+ steps :
16+ - name : Set package order
17+ id : set-order
18+ run : |
19+ # Define the ordered list of packages - dependencies first
20+ # Place base packages with minimal dependencies at the beginning
21+ # and packages with more dependencies later
22+ PACKAGE_ORDER='[
23+ {"path": "packages/utils", "repo": "cognesy/instructor-utils", "name": "instructor-utils"},
24+ {"path": "packages/http-client", "repo": "cognesy/instructor-http-client", "name": "instructor-http-client"},
25+ {"path": "packages/templates", "repo": "cognesy/instructor-templates", "name": "instructor-templates"},
26+ {"path": "packages/polyglot", "repo": "cognesy/instructor-polyglot", "name": "instructor-polyglot"},
27+ {"path": "packages/setup", "repo": "cognesy/instructor-setup", "name": "instructor-setup"},
28+ {"path": "packages/instructor", "repo": "cognesy/instructor-struct", "name": "instructor-struct"},
29+ {"path": "packages/addons", "repo": "cognesy/instructor-addons", "name": "instructor-addons"},
30+ {"path": "packages/auxiliary", "repo": "cognesy/instructor-aux", "name": "instructor-auxiliary"},
31+ {"path": "packages/evals", "repo": "cognesy/instructor-evals", "name": "instructor-evals"},
32+ {"path": "packages/hub", "repo": "cognesy/instructor-hub", "name": "instructor-hub"},
33+ {"path": "packages/tell", "repo": "cognesy/instructor-tell", "name": "instructor-tell"}
34+ ]'
35+ echo "package_order=${PACKAGE_ORDER}" >> $GITHUB_OUTPUT
36+
37+ # Split packages in the defined order
1338 split :
39+ needs : setup
1440 runs-on : ubuntu-latest
1541 strategy :
1642 fail-fast : false
1743 matrix :
18- package :
19- - local : ' packages/addons'
20- repo : ' cognesy/instructor-addons'
21- name : ' instructor-addons'
22- - local : ' packages/auxiliary'
23- repo : ' cognesy/instructor-aux'
24- name : ' instructor-aux'
25- - local : ' packages/evals'
26- repo : ' cognesy/instructor-evals'
27- name : ' instructor-evals'
28- - local : ' packages/http-client'
29- repo : ' cognesy/instructor-http-client'
30- name : ' instructor-http-client'
31- - local : ' packages/hub'
32- repo : ' cognesy/instructor-hub'
33- name : ' instructor-hub'
34- - local : ' packages/instructor'
35- repo : ' cognesy/instructor-struct'
36- name : ' instructor-struct'
37- - local : ' packages/polyglot'
38- repo : ' cognesy/instructor-polyglot'
39- name : ' instructor-polyglot'
40- - local : ' packages/setup'
41- repo : ' cognesy/instructor-setup'
42- name : ' instructor-setup'
43- - local : ' packages/tell'
44- repo : ' cognesy/instructor-tell'
45- name : ' instructor-tell'
46- - local : ' packages/templates'
47- repo : ' cognesy/instructor-templates'
48- name : ' instructor-templates'
49- - local : ' packages/utils'
50- repo : ' cognesy/instructor-utils'
51- name : ' instructor-utils'
44+ # Convert the package order array to a matrix
45+ package_index : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
5246
5347 steps :
5448 - uses : actions/checkout@v4
5549 with :
5650 fetch-depth : 0 # Full history for proper splitting
5751
52+ # Get the package details from the ordered list
53+ - name : Get package details
54+ id : package-details
55+ run : |
56+ PACKAGE_ORDER='${{ needs.setup.outputs.package_order }}'
57+ PACKAGE_INDEX=${{ matrix.package_index }}
58+
59+ # Extract package info
60+ PACKAGE_PATH=$(echo $PACKAGE_ORDER | jq -r ".[$PACKAGE_INDEX].path")
61+ REPO_NAME=$(echo $PACKAGE_ORDER | jq -r ".[$PACKAGE_INDEX].repo")
62+ PACKAGE_NAME=$(echo $PACKAGE_ORDER | jq -r ".[$PACKAGE_INDEX].name")
63+
64+ echo "PACKAGE_PATH=${PACKAGE_PATH}" >> $GITHUB_OUTPUT
65+ echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_OUTPUT
66+ echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
67+
68+ echo "Processing package $PACKAGE_NAME ($PACKAGE_PATH) -> $REPO_NAME"
69+
70+ # Wait for previous packages to be processed
71+ # This delay increases with each package index to ensure dependencies are available
72+ - name : Wait for dependencies
73+ run : |
74+ # Wait longer for later packages (more dependencies)
75+ WAIT_TIME=$((${{ matrix.package_index }} * 30))
76+ echo "Waiting $WAIT_TIME seconds for previous packages to be processed..."
77+ sleep $WAIT_TIME
78+
5879 # Verify release notes exist for this package
5980 - name : Verify release notes
6081 id : check_notes
6182 run : |
6283 TAG_NAME=${{ github.ref_name }}
63- NOTES_PATH="${{ matrix.package.local }}/release_notes/${TAG_NAME}.md"
84+ PACKAGE_PATH="${{ steps.package-details.outputs.PACKAGE_PATH }}"
85+ NOTES_PATH="$PACKAGE_PATH/release_notes/${TAG_NAME}.md"
6486
6587 if [ -f "$NOTES_PATH" ]; then
6688 echo "NOTES_EXIST=true" >> $GITHUB_ENV
@@ -69,32 +91,85 @@ jobs:
6991 echo "NOTES_EXIST=false" >> $GITHUB_ENV
7092 echo "Warning: No release notes found at $NOTES_PATH"
7193 # Create a minimal release note if none exists
72- mkdir -p "${{ matrix.package.local }} /release_notes"
94+ mkdir -p "$PACKAGE_PATH /release_notes"
7395 echo "# ${TAG_NAME}\n\nThis release is part of the main monorepo release ${TAG_NAME}." > "$NOTES_PATH"
7496 echo "Created minimal release notes"
7597 fi
7698
77- # ► push branch + tag
99+ # Split the monorepo
78100 - name : Split Monorepo
79101 uses : " danharrin/monorepo-split-github-action@v2.3.0"
80102 env :
81103 GITHUB_TOKEN : ${{ secrets.SPLIT_TOKEN_4 }}
82104 with :
83- # github_token: ${{ secrets.SPLIT_TOKEN_4 }} # PAT here
84105 tag : ${{ github.ref_name }} # e.g. v1.2.3
85- package_directory : ${{ matrix .package.local }}
106+ package_directory : ${{ steps .package-details.outputs.PACKAGE_PATH }}
86107 repository_organization : cognesy
87- repository_name : ${{ matrix .package.name }}
108+ repository_name : ${{ steps .package-details.outputs.PACKAGE_NAME }}
88109 user_name : ' ddebowczyk'
89110 user_email : ' ddebowczyk@gmail.com'
90111
91- # ► create GitHub Release with notes
112+ # Create GitHub Release with notes
92113 - uses : softprops/action-gh-release@v2
93114 if : github.ref_type == 'tag'
94115 env :
95116 GITHUB_TOKEN : ${{ secrets.SPLIT_TOKEN_4 }}
96117 with :
97- repository : ${{ matrix.package.repo }} # target repo
98- tag_name : ${{ github.ref_name }} # v1.2.3
99- body_path : ${{ matrix.package.local }}/release_notes/${{ github.ref_name }}.md
100- token : ${{ secrets.SPLIT_TOKEN_4 }} # PAT here
118+ repository : ${{ steps.package-details.outputs.REPO_NAME }}
119+ tag_name : ${{ github.ref_name }}
120+ body_path : ${{ steps.package-details.outputs.PACKAGE_PATH }}/release_notes/${{ github.ref_name }}.md
121+ token : ${{ secrets.SPLIT_TOKEN_4 }}
122+
123+ # Validate packages were published correctly
124+ validate :
125+ needs : split
126+ runs-on : ubuntu-latest
127+ steps :
128+ - name : Set up PHP
129+ uses : shivammathur/setup-php@v2
130+ with :
131+ php-version : ' 8.3'
132+
133+ - name : Validate package versions
134+ run : |
135+ echo "Validating package versions after split..."
136+
137+ # Wait for package registry to update
138+ echo "Waiting for Packagist to update (2 minutes)..."
139+ sleep 120
140+
141+ # Create temporary composer project to test package availability
142+ mkdir -p /tmp/validation
143+ cd /tmp/validation
144+
145+ # Initialize composer project
146+ composer init --name=cognesy/validation --description="Validation project" --author="Validation <validation@example.com>" --type=project --no-interaction
147+
148+ # Try to require each package at the new version
149+ TAG_VERSION="${{ github.ref_name }}"
150+ VERSION="${TAG_VERSION#v}"
151+
152+ echo "Validating version: $VERSION"
153+
154+ PACKAGES=(
155+ "cognesy/instructor-utils:^$VERSION"
156+ "cognesy/instructor-http-client:^$VERSION"
157+ "cognesy/instructor-templates:^$VERSION"
158+ "cognesy/instructor-struct:^$VERSION"
159+ "cognesy/instructor-polyglot:^$VERSION"
160+ "cognesy/instructor-setup:^$VERSION"
161+ "cognesy/instructor-addons:^$VERSION"
162+ "cognesy/instructor-aux:^$VERSION"
163+ "cognesy/instructor-evals:^$VERSION"
164+ "cognesy/instructor-hub:^$VERSION"
165+ "cognesy/instructor-tell:^$VERSION"
166+ )
167+
168+ for pkg in "${PACKAGES[@]}"; do
169+ echo "Validating package: $pkg"
170+ if ! composer require --no-update "$pkg"; then
171+ echo "WARNING: Package $pkg is not yet available. This may be due to package registry delays."
172+ fi
173+ done
174+
175+ echo "All packages have been processed. Some may still be propagating to Packagist."
0 commit comments