Skip to content

Commit b72512a

Browse files
committed
refactor: Release Please workflow & config
1 parent 8a34a45 commit b72512a

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

.github/workflows/release-please.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

release-please-config.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3-
"group-pull-request-title-pattern": "release: UI5 CLI packages",
4-
"prerelease-type": "alpha",
3+
"group-pull-request-title-pattern": "release: UI5 CLI packages ${branch}",
4+
"release-type": "node",
5+
"always-update": true,
6+
"pull-request-header": ":tractor: New release prepared",
57
"prerelease": true,
8+
"prerelease-type": "alpha",
69
"release-as": "5.0.0-alpha.0",
710
"packages": {
811
"packages/logger": {
@@ -27,12 +30,10 @@
2730
]
2831
}
2932
},
30-
"release-type": "node",
31-
"always-update": true,
32-
"pull-request-header": ":tractor: New release prepared",
3333
"plugins": [
3434
{
35-
"type": "node-workspace"
35+
"type": "node-workspace",
36+
"merge": false
3637
},
3738
{
3839
"type": "linked-versions",

0 commit comments

Comments
 (0)