diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index a270364d460..ff7e6926a92 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -13,6 +13,8 @@ permissions: jobs: release-please: runs-on: ubuntu-24.04 + outputs: + releases_created: ${{ steps.release.outputs.releases_created }} steps: - uses: actions/checkout@v5 @@ -27,6 +29,44 @@ jobs: with: token: "${{ secrets.GITHUB_TOKEN }}" + - name: "Fix peerDependency and lockfile in Release PR" + if: ${{ steps.release.outputs.pr }} + run: | + set -ex + gh pr checkout ${{ fromJson(steps.release.outputs.pr).number }} + + # Update peer dependency: Release Please doesn't handle circular peerDependencies + # @ui5/project has peerDependency on @ui5/builder, and @ui5/builder has devDependency on @ui5/project + # The node-workspace plugin can't resolve this cycle, so we update it manually + # Extract builder version and update project peer dependency + BUILDER_VERSION=$(jq -r '.version' packages/builder/package.json) + 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 + + # Regenerate package-lock.json to sync with updated workspace packages + npm install + + # Fix lockfile corruption: node-workspace plugin updates npm alias entries in package-lock.json + # but the internal/* packages have npm aliases (@ui5/builder-npm, @ui5/cli-npm, etc.) that point + # to old versions (^4.0.x) which are still correct and should not be updated to new versions (^5.0.x) + # that don't exist on npm yet. We restore these specific entries from the main branch. + # Restore original entries for @ui5/*-npm packages to avoid unintended updates + # Note: npm aliases can be in node_modules or internal/documentation/node_modules + git show origin/main:package-lock.json | jq -r '.packages | to_entries[] | select(.key | test("(node_modules|internal/documentation/node_modules)/@ui5/(builder|cli|fs|logger|project|server)-npm$")) | .key' | while read key; do + original_entry=$(git show origin/main:package-lock.json | jq ".packages[\"$key\"]") + jq --tab --arg key "$key" --argjson entry "$original_entry" '.packages[$key] = $entry' package-lock.json > tmp.$$.json && mv tmp.$$.json package-lock.json + done + + # Commit the change back to the PR branch + # Amend the Release Please commit to include our fixes + # This keeps the PR clean with a single commit + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add packages/project/package.json package-lock.json + git commit --amend --no-edit + git push --force-with-lease + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish-packages: runs-on: ubuntu-24.04 needs: release-please @@ -79,4 +119,4 @@ jobs: working-directory: packages/cli run: | echo "🚀 Publishing @ui5/cli" - npm publish --access public --tag next \ No newline at end of file + npm publish --access public --tag next diff --git a/release-please-config.json b/release-please-config.json index 45da99a6c95..e863f409e98 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,8 +1,11 @@ { "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", - "group-pull-request-title-pattern": "release: UI5 CLI packages", - "prerelease-type": "alpha", + "group-pull-request-title-pattern": "release: UI5 CLI packages ${branch}", + "release-type": "node", + "always-update": true, + "pull-request-header": ":tractor: New release prepared", "prerelease": true, + "prerelease-type": "alpha", "release-as": "5.0.0-alpha.0", "packages": { "packages/logger": { @@ -27,13 +30,10 @@ ] } }, - "release-type": "node", - "always-update": true, - "pull-request-header": ":tractor: New release prepared", - "pull-request-title-pattern": "release: UI5 CLI packages", "plugins": [ { - "type": "node-workspace" + "type": "node-workspace", + "merge": false }, { "type": "linked-versions",