@@ -29,15 +29,38 @@ jobs:
2929 with :
3030 token : " ${{ secrets.GITHUB_TOKEN }}"
3131
32- - name : Update PR title with version
33- if : steps.release.outputs.pr
32+ - name : " Fix peerDependency and lockfile in Release PR "
33+ if : ${{ steps.release.outputs.pr }}
3434 run : |
35- PR_NUMBER="${{ fromJSON(steps.release.outputs.pr).number }}"
36- PR_BRANCH="${{ fromJSON(steps.release.outputs.pr).headBranchName }}"
37- git fetch origin $PR_BRANCH
38- git checkout $PR_BRANCH
39- VERSION=$(jq -r .version packages/cli/package.json)
40- gh pr edit $PR_NUMBER --title "release: UI5 CLI packages $VERSION"
35+ set -ex
36+ gh pr checkout ${{ fromJson(steps.release.outputs.pr).number }}
37+
38+ # Update peer dependency: Release Please doesn't handle circular peerDependencies
39+ # @ui5/project has peerDependency on @ui5/builder, and @ui5/builder has devDependency on @ui5/project
40+ # The node-workspace plugin can't resolve this cycle, so we update it manually
41+ # Extract builder version and update project peer dependency
42+ BUILDER_VERSION=$(jq -r '.version' packages/builder/package.json)
43+ jq --tab --arg new_version "^$BUILDER_VERSION" '.peerDependencies."@ui5/builder" = $new_version' packages/project/package.json > tmp.$$.json && mv tmp.$$.json packages/project/package.json
44+
45+ # Regenerate package-lock.json to sync with updated workspace packages
46+ npm install
47+
48+ # Fix lockfile corruption: node-workspace plugin updates npm alias entries in package-lock.json
49+ # but the internal/* packages have npm aliases (@ui5/builder-npm, @ui5/cli-npm, etc.) that point
50+ # to old versions (^4.0.x) which are still correct and should not be updated to new versions (^5.0.x)
51+ # that don't exist on npm yet. We restore these specific entries from the main branch.
52+ # Restore original entries for @ui5/*-npm packages to avoid unintended updates
53+ git show origin/main:package-lock.json | jq -r '.packages | to_entries[] | select(.key | test("node_modules/@ui5/(builder|cli|fs|logger|project|server)-npm$")) | .key' | while read key; do
54+ original_entry=$(git show origin/main:package-lock.json | jq ".packages[\"$key\"]")
55+ jq --tab --arg key "$key" --argjson entry "$original_entry" '.packages[$key] = $entry' package-lock.json > tmp.$$.json && mv tmp.$$.json package-lock.json
56+ done
57+
58+ # Commit the change back to the PR branch
59+ git config user.name "github-actions[bot]"
60+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
61+ git add packages/project/package.json package-lock.json
62+ git commit -m "chore: update @ui5/builder peer dependency and regenerate lockfile"
63+ git push
4164 env :
4265 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4366
0 commit comments