Skip to content

Commit d0dfe74

Browse files
authored
Merge pull request #273 from ZettaScaleLabs/set-git-branch-action
Improvements to set-git-branch action
2 parents 9ad9fc3 + c6ee8fb commit d0dfe74

12 files changed

+76
-43
lines changed

.github/workflows/merge-release-branch.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
- eclipse-zenoh/zenoh-ts
4747
- eclipse-zenoh/zenoh-dissector
4848
steps:
49+
- name: Setup rust toolchain
50+
if: ${{ !contains(fromJSON('["eclipse-zenoh/zenoh", "eclipse-zenoh/zenoh-pico", "eclipse-zenoh/zenoh-cpp"]'), matrix.repo) }}
51+
uses: actions-rust-lang/setup-rust-toolchain@v1
52+
with:
53+
toolchain: 1.75.0
54+
4955
- name: Update git/branch in release branch
5056
if: ${{ !contains(fromJSON('["eclipse-zenoh/zenoh", "eclipse-zenoh/zenoh-pico", "eclipse-zenoh/zenoh-cpp"]'), matrix.repo) }}
5157
uses: ZettaScaleLabs/ci/set-git-branch@set-git-branch-action
@@ -70,17 +76,28 @@ jobs:
7076
- name: Create PR
7177
id: cpr
7278
run: |
73-
pr_url=$(gh pr create \
79+
output=$(gh pr create \
7480
--title "chore: Merge release/${{ inputs.version }} into main" \
75-
--body "Open new development line" \
81+
--body ":warning: This needs to be a merge commit :warning:" \
7682
--head ${{ steps.compute-branch.outputs.branch }} \
7783
--base main \
7884
--label internal \
7985
-R ${{ matrix.repo }} \
80-
)
81-
echo "pull-request-operation=created" >> $GITHUB_OUTPUT
82-
pr_number="${pr_url##*/pull/}"
83-
echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT
86+
) || exit_code=$?
87+
if [[ ${exit_code} == 0 ]]; then
88+
echo "pull-request-operation=created" >> $GITHUB_OUTPUT
89+
pr_number="${output##*/pull/}"
90+
echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT
91+
else
92+
if [[ $output == *"No commits between"* ]]; then
93+
echo "pull-request-operation=none" >> $GITHUB_OUTPUT
94+
exit 0
95+
elif [[ $output == *"pull request for branch"* ]]; then
96+
echo "pull-request-operation=updated" >> $GITHUB_OUTPUT
97+
pr_number="${output##*/pull/}"
98+
echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT
99+
fi
100+
fi
84101
env:
85102
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
86103

@@ -97,6 +114,6 @@ jobs:
97114
# GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
98115

99116
- name: Add the PR as annotation to workflow run
100-
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
117+
if: ${{ contains(fromJSON('["created", "updated"]'), steps.cpr.outputs.pull-request-operation ) }}
101118
run: >
102119
echo "::notice:: Created PR: https://github.com/${{ matrix.repo }}/pull/${{ steps.cpr.outputs.pull-request-number }}"

dist/build-crates-debian-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128159,8 +128159,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128159128159
}
128160128160
for (const dep in manifest.dependencies) {
128161128161
if (pattern.test(dep)) {
128162-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
128163-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
128162+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
128163+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
128164+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
128164128165
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128165128166
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128166128167
}

dist/build-crates-standalone-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128143,8 +128143,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128143128143
}
128144128144
for (const dep in manifest.dependencies) {
128145128145
if (pattern.test(dep)) {
128146-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
128147-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
128146+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
128147+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
128148+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
128148128149
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128149128150
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128150128151
}

dist/bump-crates-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81394,8 +81394,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
8139481394
}
8139581395
for (const dep in manifest.dependencies) {
8139681396
if (pattern.test(dep)) {
81397-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
81398-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
81397+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
81398+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
81399+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
8139981400
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
8140081401
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
8140181402
}

dist/publish-crates-cargo-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81279,8 +81279,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
8127981279
}
8128081280
for (const dep in manifest.dependencies) {
8128181281
if (pattern.test(dep)) {
81282-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
81283-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
81282+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
81283+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
81284+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
8128481285
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
8128581286
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
8128681287
}

dist/publish-crates-debian-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128138,8 +128138,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128138128138
}
128139128139
for (const dep in manifest.dependencies) {
128140128140
if (pattern.test(dep)) {
128141-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
128142-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
128141+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
128142+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
128143+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
128143128144
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128144128145
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128145128146
}

dist/publish-crates-eclipse-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128219,8 +128219,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128219128219
}
128220128220
for (const dep in manifest.dependencies) {
128221128221
if (pattern.test(dep)) {
128222-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
128223-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
128222+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
128223+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
128224+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
128224128225
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128225128226
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128226128227
}

dist/publish-crates-github-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128219,8 +128219,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128219128219
}
128220128220
for (const dep in manifest.dependencies) {
128221128221
if (pattern.test(dep)) {
128222-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
128223-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
128222+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
128223+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
128224+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
128224128225
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128225128226
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128226128227
}

dist/publish-crates-homebrew-main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128123,8 +128123,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128123128123
}
128124128124
for (const dep in manifest.dependencies) {
128125128125
if (pattern.test(dep)) {
128126-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
128127-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
128126+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
128127+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
128128+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
128128128129
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128129128130
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128130128131
}

dist/set-git-branch-main.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81275,8 +81275,9 @@ async function setGitBranch(path, pattern, gitUrl, gitBranch) {
8127581275
}
8127681276
for (const dep in manifest.dependencies) {
8127781277
if (pattern.test(dep)) {
81278-
// if the dep has a path set, don't set the git/branch to avoid ambiguities
81279-
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path"))) {
81278+
// if the dep has a path set or is part of workspace, don't set the git/branch to avoid ambiguities
81279+
if (!toml.get(manifestPath, prefix.concat("dependencies", dep, "path")) ||
81280+
!toml.get(manifestPath, prefix.concat("dependencies", dep, "workspace"))) {
8128081281
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
8128181282
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
8128281283
}
@@ -81612,14 +81613,16 @@ async function main(input) {
8161281613
.filter(r => r);
8161381614
for (const path of cargoPaths) {
8161481615
await _cargo__WEBPACK_IMPORTED_MODULE_4__/* .setGitBranch */ .B0(path, input.depsRegExp, input.depsGitUrl, input.depsBranch);
81615-
(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git add .", { cwd: repo });
81616-
(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 });
81617-
(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`cargo check --manifest-path ${path}/Cargo.toml`);
81618-
(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git commit Cargo.lock --message 'chore: Update Cargo lockfile'", {
81619-
cwd: repo,
81620-
env: _config__WEBPACK_IMPORTED_MODULE_5__/* .gitEnv */ .B,
81621-
check: false,
81622-
});
81616+
if ((0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git diff", { cwd: repo, check: false })) {
81617+
(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git add .", { cwd: repo });
81618+
(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 });
81619+
(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`cargo check --manifest-path ${path}/Cargo.toml`);
81620+
(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)("git commit Cargo.lock --message 'chore: Update Cargo lockfile'", {
81621+
cwd: repo,
81622+
env: _config__WEBPACK_IMPORTED_MODULE_5__/* .gitEnv */ .B,
81623+
check: false,
81624+
});
81625+
}
8162381626
}
8162481627
(0,_command__WEBPACK_IMPORTED_MODULE_3__.sh)(`git push --force ${remote} eclipse-zenoh-bot/post-release-${input.version}`, { cwd: repo });
8162581628
await cleanup(input);

0 commit comments

Comments
 (0)