@@ -75,12 +75,57 @@ jobs:
7575 steps :
7676 - uses : actions/checkout@v4
7777
78+ - name : Get package stability and determine version
79+ working-directory : packages/${{ matrix.package }}
80+ id : version
81+ run : |
82+ if [ -f composer.json ]; then
83+ # Extract moox-stability from composer.json
84+ STABILITY=$(jq -r '.extra."moox-stability" // "dev"' composer.json)
85+ BASE_VERSION="${{ needs.prepare.outputs.core-version }}"
86+
87+ echo "Package: ${{ matrix.package }}"
88+ echo "Base version: $BASE_VERSION"
89+ echo "Stability: $STABILITY"
90+
91+ # Determine final version based on stability
92+ if [ "$STABILITY" = "stable" ]; then
93+ FINAL_VERSION="$BASE_VERSION"
94+ IS_PRERELEASE=false
95+ echo "✅ Using stable version: $FINAL_VERSION"
96+ elif [ "$STABILITY" = "dev" ]; then
97+ FINAL_VERSION="${BASE_VERSION}-dev"
98+ IS_PRERELEASE=true
99+ echo "🔧 Using dev version: $FINAL_VERSION"
100+ else
101+ FINAL_VERSION="${BASE_VERSION}-${STABILITY}"
102+ IS_PRERELEASE=true
103+ echo "🚧 Using $STABILITY version: $FINAL_VERSION"
104+ fi
105+
106+ echo "final-version=$FINAL_VERSION" >> $GITHUB_OUTPUT
107+ echo "is-prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
108+ echo "stability=$STABILITY" >> $GITHUB_OUTPUT
109+
110+ else
111+ echo "No composer.json found in ${{ matrix.package }}"
112+ echo "final-version=${{ needs.prepare.outputs.core-version }}" >> $GITHUB_OUTPUT
113+ echo "is-prerelease=false" >> $GITHUB_OUTPUT
114+ echo "stability=stable" >> $GITHUB_OUTPUT
115+ fi
116+
78117 - name : Replace core version in composer.json
79118 working-directory : packages/${{ matrix.package }}
80119 run : |
81120 if [ -f composer.json ]; then
82121 echo "Updating moox/core version in ${{ matrix.package }} to ${{ needs.prepare.outputs.core-version }}"
83- sed -i 's/"moox\/core": "[^"]*"/"moox\/core": "${{ needs.prepare.outputs.core-version }}"/g' composer.json
122+
123+ # More robust sed pattern that handles different JSON formatting
124+ sed -i 's/"moox\/core":\s*"[^"]*"/"moox\/core": "${{ needs.prepare.outputs.core-version }}"/g' composer.json
125+
126+ # Also handle self.version case
127+ sed -i 's/"moox\/core":\s*"self\.version"/"moox\/core": "${{ needs.prepare.outputs.core-version }}"/g' composer.json
128+
84129 echo "Updated composer.json:"
85130 grep "moox/core" composer.json || echo "No moox/core dependency found"
86131 else
@@ -97,54 +142,68 @@ jobs:
97142 git commit -m "Update moox/core dependency to ${{ needs.prepare.outputs.core-version }}" || echo "No changes to commit"
98143 fi
99144
100- - name : Split package to separate repository
101- 102- env :
103- GITHUB_TOKEN : ${{ github.event.inputs.user_token != '' && github.event.inputs.user_token || secrets.BOT }}
104- with :
105- tag : " ${{ github.event.inputs.version }}"
106- package_directory : " packages/${{ matrix.package }}"
107- repository_organization : " mooxphp"
108- repository_name : " ${{ matrix.package }}"
109- user_name : " Moox Bot"
110- 111145
112- - name : Create GitHub Release for split package
146+ - name : Split package to separate repository
113147 run : |
114148 PACKAGE="${{ matrix.package }}"
115- VERSION="${{ github.event.inputs. version }}"
116- RELEASE_BODY=$(echo '$ {{ github.event.inputs.packages }}' | jq -r ".\"$PACKAGE\".\"release-message\" // [] | .[:10] | join(\"\\n\")")
117- STABILITY=$(echo '$ {{ github.event.inputs.packages }}' | jq -r ".\"$PACKAGE\".\"moox-stability\" // \"dev\"")
118-
149+ VERSION="${{ steps.version.outputs.final- version }}"
150+ IS_PRERELEASE="$ {{ steps.version.outputs.is-prerelease }}"
151+ STABILITY="$ {{ steps.version.outputs.stability }}"
152+
119153 echo "Package: $PACKAGE"
120- echo "Version: $VERSION"
154+ echo "Version: $VERSION"
155+ echo "Is prerelease: $IS_PRERELEASE"
121156 echo "Stability: $STABILITY"
122- echo "Release notes: $RELEASE_BODY"
157+ # - name: Split package to separate repository
158+ # uses: symplify/[email protected] 159+ # env:
160+ # GITHUB_TOKEN: ${{ github.event.inputs.user_token != '' && github.event.inputs.user_token || secrets.BOT }}
161+ # with:
162+ # tag: "${{ steps.version.outputs.final-version }}"
163+ # package_directory: "packages/${{ matrix.package }}"
164+ # repository_organization: "mooxphp"
165+ # repository_name: "${{ matrix.package }}"
166+ # user_name: "Moox Bot"
167+ 168+
169+ # - name: Create GitHub Release for split package
170+ # run: |
171+ # PACKAGE="${{ matrix.package }}"
172+ # VERSION="${{ steps.version.outputs.final-version }}"
173+ # IS_PRERELEASE="${{ steps.version.outputs.is-prerelease }}"
174+ # STABILITY="${{ steps.version.outputs.stability }}"
175+ # RELEASE_BODY=$(echo '${{ github.event.inputs.packages }}' | jq -r ".\"$PACKAGE\".\"release-message\" // [] | .[:10] | join(\"\\n\")")
123176
124- # Only create release if stability is not 'dev'
125- if [ "$STABILITY" != "dev" ]; then
126- echo "✅ Creating release for $PACKAGE (stability: $STABILITY)"
177+ # echo "Package: $PACKAGE"
178+ # echo "Version: $VERSION"
179+ # echo "Stability: $STABILITY"
180+ # echo "Is prerelease: $IS_PRERELEASE"
181+ # echo "Release notes: $RELEASE_BODY"
182+
183+ # # Only create release if stability is not 'dev'
184+ # if [ "$STABILITY" != "dev" ]; then
185+ # echo "✅ Creating release for $PACKAGE (stability: $STABILITY)"
127186
128- # Wait for tag propagation
129- sleep 10
187+ # # Wait for tag propagation
188+ # sleep 10
130189
131- if [ "${{ needs.prepare.outputs.is-prerelease }} " = "true" ]; then
132- gh release create "$VERSION" \
133- --repo "mooxphp/$PACKAGE" \
134- --title "Release $VERSION" \
135- --notes "$RELEASE_BODY" \
136- --prerelease
137- else
138- gh release create "$VERSION" \
139- --repo "mooxphp/$PACKAGE" \
140- --title "Release $VERSION" \
141- --notes "$RELEASE_BODY"
142- fi
190+ # if [ "$IS_PRERELEASE " = "true" ]; then
191+ # gh release create "$VERSION" \
192+ # --repo "mooxphp/$PACKAGE" \
193+ # --title "Release $VERSION" \
194+ # --notes "$RELEASE_BODY" \
195+ # --prerelease
196+ # else
197+ # gh release create "$VERSION" \
198+ # --repo "mooxphp/$PACKAGE" \
199+ # --title "Release $VERSION" \
200+ # --notes "$RELEASE_BODY"
201+ # fi
143202
144- echo "✅ Release created successfully"
145- else
146- echo "⏭️ Skipping release for $PACKAGE (stability: dev)"
147- echo " Package was split to repository but no release was created"
148- fi
149- env :
150- GH_TOKEN : ${{ github.event.inputs.user_token != '' && github.event.inputs.user_token || secrets.BOT }}
203+ # echo "✅ Release created successfully"
204+ # else
205+ # echo "⏭️ Skipping release for $PACKAGE (stability: dev)"
206+ # echo " Package was split to repository but no release was created"
207+ # fi
208+ # env:
209+ # GH_TOKEN: ${{ github.event.inputs.user_token != '' && github.event.inputs.user_token || secrets.BOT }}
0 commit comments