diff --git a/.github/workflows/merge-release-branch.yml b/.github/workflows/merge-release-branch.yml index 1d2d9765..329c3a81 100644 --- a/.github/workflows/merge-release-branch.yml +++ b/.github/workflows/merge-release-branch.yml @@ -46,6 +46,12 @@ jobs: - eclipse-zenoh/zenoh-ts - eclipse-zenoh/zenoh-dissector steps: + - name: Setup rust toolchain + if: ${{ !contains(fromJSON('["eclipse-zenoh/zenoh", "eclipse-zenoh/zenoh-pico", "eclipse-zenoh/zenoh-cpp"]'), matrix.repo) }} + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.75.0 + - name: Update git/branch in release branch if: ${{ !contains(fromJSON('["eclipse-zenoh/zenoh", "eclipse-zenoh/zenoh-pico", "eclipse-zenoh/zenoh-cpp"]'), matrix.repo) }} uses: ZettaScaleLabs/ci/set-git-branch@set-git-branch-action @@ -70,17 +76,28 @@ jobs: - name: Create PR id: cpr run: | - pr_url=$(gh pr create \ + output=$(gh pr create \ --title "chore: Merge release/${{ inputs.version }} into main" \ - --body "Open new development line" \ + --body ":warning: This needs to be a merge commit :warning:" \ --head ${{ steps.compute-branch.outputs.branch }} \ --base main \ --label internal \ -R ${{ matrix.repo }} \ - ) - echo "pull-request-operation=created" >> $GITHUB_OUTPUT - pr_number="${pr_url##*/pull/}" - echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT + ) || exit_code=$? + if [[ ${exit_code} == 0 ]]; then + echo "pull-request-operation=created" >> $GITHUB_OUTPUT + pr_number="${output##*/pull/}" + echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT + else + if [[ $output == *"No commits between"* ]]; then + echo "pull-request-operation=none" >> $GITHUB_OUTPUT + exit 0 + elif [[ $output == *"pull request for branch"* ]]; then + echo "pull-request-operation=updated" >> $GITHUB_OUTPUT + pr_number="${output##*/pull/}" + echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT + fi + fi env: GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }} @@ -97,6 +114,6 @@ jobs: # GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }} - name: Add the PR as annotation to workflow run - if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }} + if: ${{ contains(fromJSON('["created", "updated"]'), steps.cpr.outputs.pull-request-operation ) }} run: > echo "::notice:: Created PR: https://github.com/${{ matrix.repo }}/pull/${{ steps.cpr.outputs.pull-request-number }}" \ No newline at end of file diff --git a/dist/build-crates-debian-main.js b/dist/build-crates-debian-main.js index cf136881..3b4bc14e 100644 --- a/dist/build-crates-debian-main.js +++ b/dist/build-crates-debian-main.js @@ -128159,8 +128159,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/build-crates-standalone-main.js b/dist/build-crates-standalone-main.js index b1fd8865..dfeedf77 100644 --- a/dist/build-crates-standalone-main.js +++ b/dist/build-crates-standalone-main.js @@ -128143,8 +128143,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/bump-crates-main.js b/dist/bump-crates-main.js index dc0ef5a6..10cdce6c 100644 --- a/dist/bump-crates-main.js +++ b/dist/bump-crates-main.js @@ -81394,8 +81394,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/publish-crates-cargo-main.js b/dist/publish-crates-cargo-main.js index 8c3fc3f3..0de7a4ff 100644 --- a/dist/publish-crates-cargo-main.js +++ b/dist/publish-crates-cargo-main.js @@ -81279,8 +81279,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/publish-crates-debian-main.js b/dist/publish-crates-debian-main.js index 1ba0e959..8a51c03a 100644 --- a/dist/publish-crates-debian-main.js +++ b/dist/publish-crates-debian-main.js @@ -128138,8 +128138,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/publish-crates-eclipse-main.js b/dist/publish-crates-eclipse-main.js index bace671e..f29b61bd 100644 --- a/dist/publish-crates-eclipse-main.js +++ b/dist/publish-crates-eclipse-main.js @@ -128219,8 +128219,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/publish-crates-github-main.js b/dist/publish-crates-github-main.js index f23b2edb..34cfc049 100644 --- a/dist/publish-crates-github-main.js +++ b/dist/publish-crates-github-main.js @@ -128219,8 +128219,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/publish-crates-homebrew-main.js b/dist/publish-crates-homebrew-main.js index bbf6ec7a..42c8fe92 100644 --- a/dist/publish-crates-homebrew-main.js +++ b/dist/publish-crates-homebrew-main.js @@ -128123,8 +128123,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/dist/set-git-branch-main.js b/dist/set-git-branch-main.js index 7de5c8e8..55767e74 100644 --- a/dist/set-git-branch-main.js +++ b/dist/set-git-branch-main.js @@ -81275,8 +81275,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) { } for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } @@ -81612,14 +81613,16 @@ async function main(input) { .filter(r => r); for (const path of cargoPaths) { await _cargo__WEBPACK_IMPORTED_MODULE_4__/* .setGitBranch */ .B0(path, input.depsRegExp, input.depsGitUrl, input.depsBranch); - (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git add .", { cwd: repo }); - (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`git commit --message 'chore: Update git/branch ${path}/Cargo.toml'`, { cwd: repo, env: _config__WEBPACK_IMPORTED_MODULE_5__/* .gitEnv */ .B }); - (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`cargo check --manifest-path ${path}/Cargo.toml`); - (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git commit Cargo.lock --message 'chore: Update Cargo lockfile'", { - cwd: repo, - env: _config__WEBPACK_IMPORTED_MODULE_5__/* .gitEnv */ .B, - check: false, - }); + if ((0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git diff", { cwd: repo, check: false })) { + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git add .", { cwd: repo }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`git commit --message 'chore: Update git/branch ${path}/Cargo.toml'`, { cwd: repo, env: _config__WEBPACK_IMPORTED_MODULE_5__/* .gitEnv */ .B }); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`cargo check --manifest-path ${path}/Cargo.toml`); + (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git commit Cargo.lock --message 'chore: Update Cargo lockfile'", { + cwd: repo, + env: _config__WEBPACK_IMPORTED_MODULE_5__/* .gitEnv */ .B, + check: false, + }); + } } (0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`git push --force ${remote} eclipse-zenoh-bot/post-release-${input.version}`, { cwd: repo }); await cleanup(input); diff --git a/src/cargo.ts b/src/cargo.ts index a35b3136..c1848ed2 100644 --- a/src/cargo.ts +++ b/src/cargo.ts @@ -278,8 +278,11 @@ export async function setGitBranch(path: string, pattern: RegExp, gitUrl: string for (const dep in manifest.dependencies) { if (pattern.test(dep)) { - // if the dep has a path set, don't set the git/branch to avoid ambiguities - if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) { + // if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities + if ( + !toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) || + !toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace")) + ) { await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl); await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch); } diff --git a/src/set-git-branch.ts b/src/set-git-branch.ts index c232b70b..f8d70cd2 100644 --- a/src/set-git-branch.ts +++ b/src/set-git-branch.ts @@ -56,15 +56,17 @@ export async function main(input: Input) { for (const path of cargoPaths) { await cargo.setGitBranch(path, input.depsRegExp, input.depsGitUrl, input.depsBranch); - sh("git add .", { cwd: repo }); - sh(`git commit --message 'chore: Update git/branch ${path}/Cargo.toml'`, { cwd: repo, env: gitEnv }); + if (sh("git diff", { cwd: repo, check: false })) { + sh("git add .", { cwd: repo }); + sh(`git commit --message 'chore: Update git/branch ${path}/Cargo.toml'`, { cwd: repo, env: gitEnv }); - sh(`cargo check --manifest-path ${path}/Cargo.toml`); - sh("git commit Cargo.lock --message 'chore: Update Cargo lockfile'", { - cwd: repo, - env: gitEnv, - check: false, - }); + sh(`cargo check --manifest-path ${path}/Cargo.toml`); + sh("git commit Cargo.lock --message 'chore: Update Cargo lockfile'", { + cwd: repo, + env: gitEnv, + check: false, + }); + } } sh(`git push --force ${remote} eclipse-zenoh-bot/post-release-${input.version}`, { cwd: repo });