Skip to content

Commit 9a02639

Browse files
Set git branch action (#270)
* feat: add action to set git branch in zenoh deps * fix: update merge-release-branch to use action * chore: disable auto-merge while testing * chore: update action URL * chore: change inputs to matrix.repo * fix: fix regex for compute branch * chore: add missing params to docs
1 parent 3ea7ddb commit 9a02639

14 files changed

+84196
-29
lines changed

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

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,13 @@ on:
88
type: string
99
description: The release branch version to merge into main
1010
required: true
11-
repo:
12-
type: string
13-
description: The repository to create the PR (org/repo format)
14-
required: true
1511

1612
workflow_dispatch:
1713
inputs:
1814
version:
1915
type: string
2016
description: The release branch version to merge into main
2117
required: true
22-
repo:
23-
type: string
24-
description: The repository to create the PR (org/repo format)
25-
required: true
2618

2719
defaults:
2820
run:
@@ -32,36 +24,79 @@ jobs:
3224
merge-release-branch:
3325
name: Submit PR to merge release branch into main
3426
runs-on: ubuntu-latest
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
repo:
31+
- eclipse-zenoh/zenoh
32+
- eclipse-zenoh/zenoh-pico
33+
- eclipse-zenoh/zenoh-cpp
34+
- eclipse-zenoh/zenoh-c
35+
- eclipse-zenoh/zenoh-python
36+
- eclipse-zenoh/zenoh-java
37+
- eclipse-zenoh/zenoh-kotlin
38+
- eclipse-zenoh/zenoh-plugin-dds
39+
- eclipse-zenoh/zenoh-plugin-mqtt
40+
- eclipse-zenoh/zenoh-plugin-ros2dds
41+
- eclipse-zenoh/zenoh-plugin-webserver
42+
- eclipse-zenoh/zenoh-backend-filesystem
43+
- eclipse-zenoh/zenoh-backend-influxdb
44+
- eclipse-zenoh/zenoh-backend-rocksdb
45+
- eclipse-zenoh/zenoh-backend-s3
46+
- eclipse-zenoh/zenoh-ts
47+
- eclipse-zenoh/zenoh-dissector
3548
steps:
49+
- name: Update git/branch in release branch
50+
if: ${{ !contains(fromJSON('["eclipse-zenoh/zenoh", "eclipse-zenoh/zenoh-pico", "eclipse-zenoh/zenoh-cpp"]'), matrix.repo) }}
51+
uses: ZettaScaleLabs/ci/set-git-branch@set-git-branch-action
52+
with:
53+
version: ${{ inputs.version }}
54+
release-branch: release/${{ inputs.version }}
55+
repo: ${{ matrix.repo }}
56+
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
57+
deps-pattern: zenoh.*
58+
deps-git-url: https://github.com/eclipse-zenoh/zenoh.git
59+
deps-branch: main
60+
61+
- name: Compute branch
62+
id: compute-branch
63+
run:
64+
if [ "${{ matrix.repo }}" =~ eclipse-zenoh\/zenoh(?:-(pico|cpp))? ]] ; then
65+
echo "branch=release/${{ inputs.version }}" >> $GITHUB_OUTPUT
66+
else
67+
echo "branch=eclipse-zenoh-bot/post-release-${{ inputs.version }}" >> $GITHUB_OUTPUT
68+
fi
69+
3670
- name: Create PR
3771
id: cpr
3872
run: |
3973
pr_url=$(gh pr create \
4074
--title "chore: Merge release/${{ inputs.version }} into main" \
4175
--body "Open new development line" \
42-
--head release/${{ inputs.version }} \
76+
--head ${{ steps.compute-branch.outputs.branch }}
4377
--base main \
4478
--label internal \
45-
-R ${{ inputs.repo }} \
79+
-R ${{ matrix.repo }} \
4680
)
4781
echo "pull-request-operation=created" >> $GITHUB_OUTPUT
4882
pr_number="${pr_url##*/pull/}"
4983
echo "pull-request-number=$pr_number" >> $GITHUB_OUTPUT
5084
env:
5185
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
5286

53-
- name: Enable auto merge for the pull request
54-
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
55-
run: >
56-
gh pr merge "${{ steps.cpr.outputs.pull-request-number }}"
57-
--subject "chore: Merge release/${{ inputs.version }} into main (#${{ steps.cpr.outputs.pull-request-number }})"
58-
--repo "${{ inputs.repo }}"
59-
--auto
60-
--merge
61-
env:
62-
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
87+
# Disable auto merge while testing
88+
#- name: Enable auto merge for the pull request
89+
# if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
90+
# run: >
91+
# gh pr merge "${{ steps.cpr.outputs.pull-request-number }}"
92+
# --subject "chore: Merge release/${{ inputs.version }} into main (#${{ steps.cpr.outputs.pull-request-number }})"
93+
# --repo "${{ matrix.repo }}"
94+
# --auto
95+
# --merge
96+
# env:
97+
# GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
6398

6499
- name: Add the PR as annotation to workflow run
65100
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
66101
run: >
67-
echo "::notice:: Created PR: https://github.com/${{ inputs.repo }}/pull/${{ steps.cpr.outputs.pull-request-number }}"
102+
echo "::notice:: Created PR: https://github.com/${{ matrix.repo }}/pull/${{ steps.cpr.outputs.pull-request-number }}"

dist/build-crates-debian-main.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127950,7 +127950,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
127950127950
/* harmony export */ "ib": () => (/* binding */ packagesDebian),
127951127951
/* harmony export */ "lY": () => (/* binding */ buildDebian)
127952127952
/* harmony export */ });
127953-
/* unused harmony exports packages, packagesOrdered, bump, bumpDependencies, setRegistry, configRegistry, installBinaryFromGit, build, hostTarget, isPublished */
127953+
/* unused harmony exports packages, packagesOrdered, bump, bumpDependencies, setRegistry, setGitBranch, configRegistry, installBinaryFromGit, build, hostTarget, isPublished */
127954127954
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(22037);
127955127955
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
127956127956
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(71017);
@@ -128134,6 +128134,39 @@ async function setRegistry(path, pattern, registry) {
128134128134
}
128135128135
core.endGroup();
128136128136
}
128137+
/**
128138+
* Sets the git/branch config of select dependencies.
128139+
*
128140+
* @param path Path to the Cargo workspace.
128141+
* @param pattern A regular expression that matches the dependencies to be
128142+
* @param gitUrl git url to set in Cargo.toml dependency
128143+
* @param gitBranch git branch to set in Cargo.toml dependency
128144+
* updated
128145+
*/
128146+
async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128147+
core.startGroup(`Setting ${pattern} dependencies' git/branch config`);
128148+
const manifestPath = `${path}/Cargo.toml`;
128149+
const manifestRaw = toml.get(manifestPath);
128150+
let manifest;
128151+
let prefix;
128152+
if ("workspace" in manifestRaw) {
128153+
prefix = ["workspace"];
128154+
manifest = manifestRaw["workspace"];
128155+
}
128156+
else {
128157+
prefix = [];
128158+
manifest = manifestRaw;
128159+
}
128160+
for (const dep in manifest.dependencies) {
128161+
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"))) {
128164+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128165+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128166+
}
128167+
}
128168+
}
128169+
}
128137128170
/**
128138128171
* Stores Cargo registry configuration in `.cargo/config.toml`.
128139128172
* @param path Path to the Cargo workspace.

dist/build-crates-standalone-main.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127934,7 +127934,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
127934127934
/* harmony export */ "KD": () => (/* binding */ hostTarget),
127935127935
/* harmony export */ "Mj": () => (/* binding */ installBinaryCached)
127936127936
/* harmony export */ });
127937-
/* unused harmony exports packages, packagesOrdered, bump, bumpDependencies, setRegistry, configRegistry, packagesDebian, installBinaryFromGit, buildDebian, toDebianVersion, isPublished */
127937+
/* unused harmony exports packages, packagesOrdered, bump, bumpDependencies, setRegistry, setGitBranch, configRegistry, packagesDebian, installBinaryFromGit, buildDebian, toDebianVersion, isPublished */
127938127938
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(22037);
127939127939
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
127940127940
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(71017);
@@ -128118,6 +128118,39 @@ async function setRegistry(path, pattern, registry) {
128118128118
}
128119128119
core.endGroup();
128120128120
}
128121+
/**
128122+
* Sets the git/branch config of select dependencies.
128123+
*
128124+
* @param path Path to the Cargo workspace.
128125+
* @param pattern A regular expression that matches the dependencies to be
128126+
* @param gitUrl git url to set in Cargo.toml dependency
128127+
* @param gitBranch git branch to set in Cargo.toml dependency
128128+
* updated
128129+
*/
128130+
async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128131+
core.startGroup(`Setting ${pattern} dependencies' git/branch config`);
128132+
const manifestPath = `${path}/Cargo.toml`;
128133+
const manifestRaw = toml.get(manifestPath);
128134+
let manifest;
128135+
let prefix;
128136+
if ("workspace" in manifestRaw) {
128137+
prefix = ["workspace"];
128138+
manifest = manifestRaw["workspace"];
128139+
}
128140+
else {
128141+
prefix = [];
128142+
manifest = manifestRaw;
128143+
}
128144+
for (const dep in manifest.dependencies) {
128145+
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"))) {
128148+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128149+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128150+
}
128151+
}
128152+
}
128153+
}
128121128154
/**
128122128155
* Stores Cargo registry configuration in `.cargo/config.toml`.
128123128156
* @param path Path to the Cargo workspace.

dist/bump-crates-main.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81185,7 +81185,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
8118581185
/* harmony export */ "Mj": () => (/* binding */ installBinaryCached),
8118681186
/* harmony export */ "UR": () => (/* binding */ bumpDependencies)
8118781187
/* harmony export */ });
81188-
/* unused harmony exports packages, packagesOrdered, setRegistry, configRegistry, packagesDebian, installBinaryFromGit, build, hostTarget, buildDebian, isPublished */
81188+
/* unused harmony exports packages, packagesOrdered, setRegistry, setGitBranch, configRegistry, packagesDebian, installBinaryFromGit, build, hostTarget, buildDebian, isPublished */
8118981189
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(2037);
8119081190
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
8119181191
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(1017);
@@ -81369,6 +81369,39 @@ async function setRegistry(path, pattern, registry) {
8136981369
}
8137081370
core.endGroup();
8137181371
}
81372+
/**
81373+
* Sets the git/branch config of select dependencies.
81374+
*
81375+
* @param path Path to the Cargo workspace.
81376+
* @param pattern A regular expression that matches the dependencies to be
81377+
* @param gitUrl git url to set in Cargo.toml dependency
81378+
* @param gitBranch git branch to set in Cargo.toml dependency
81379+
* updated
81380+
*/
81381+
async function setGitBranch(path, pattern, gitUrl, gitBranch) {
81382+
core.startGroup(`Setting ${pattern} dependencies' git/branch config`);
81383+
const manifestPath = `${path}/Cargo.toml`;
81384+
const manifestRaw = toml.get(manifestPath);
81385+
let manifest;
81386+
let prefix;
81387+
if ("workspace" in manifestRaw) {
81388+
prefix = ["workspace"];
81389+
manifest = manifestRaw["workspace"];
81390+
}
81391+
else {
81392+
prefix = [];
81393+
manifest = manifestRaw;
81394+
}
81395+
for (const dep in manifest.dependencies) {
81396+
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"))) {
81399+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
81400+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
81401+
}
81402+
}
81403+
}
81404+
}
8137281405
/**
8137381406
* Stores Cargo registry configuration in `.cargo/config.toml`.
8137481407
* @param path Path to the Cargo workspace.

dist/publish-crates-cargo-main.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81070,7 +81070,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
8107081070
/* harmony export */ "s9": () => (/* binding */ isPublished),
8107181071
/* harmony export */ "wS": () => (/* binding */ installBinaryFromGit)
8107281072
/* harmony export */ });
81073-
/* unused harmony exports packages, bump, bumpDependencies, packagesDebian, build, hostTarget, buildDebian, toDebianVersion */
81073+
/* unused harmony exports packages, bump, bumpDependencies, setGitBranch, packagesDebian, build, hostTarget, buildDebian, toDebianVersion */
8107481074
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(2037);
8107581075
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
8107681076
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(1017);
@@ -81254,6 +81254,39 @@ async function setRegistry(path, pattern, registry) {
8125481254
}
8125581255
_actions_core__WEBPACK_IMPORTED_MODULE_2__.endGroup();
8125681256
}
81257+
/**
81258+
* Sets the git/branch config of select dependencies.
81259+
*
81260+
* @param path Path to the Cargo workspace.
81261+
* @param pattern A regular expression that matches the dependencies to be
81262+
* @param gitUrl git url to set in Cargo.toml dependency
81263+
* @param gitBranch git branch to set in Cargo.toml dependency
81264+
* updated
81265+
*/
81266+
async function setGitBranch(path, pattern, gitUrl, gitBranch) {
81267+
core.startGroup(`Setting ${pattern} dependencies' git/branch config`);
81268+
const manifestPath = `${path}/Cargo.toml`;
81269+
const manifestRaw = toml.get(manifestPath);
81270+
let manifest;
81271+
let prefix;
81272+
if ("workspace" in manifestRaw) {
81273+
prefix = ["workspace"];
81274+
manifest = manifestRaw["workspace"];
81275+
}
81276+
else {
81277+
prefix = [];
81278+
manifest = manifestRaw;
81279+
}
81280+
for (const dep in manifest.dependencies) {
81281+
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"))) {
81284+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
81285+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
81286+
}
81287+
}
81288+
}
81289+
}
8125781290
/**
8125881291
* Stores Cargo registry configuration in `.cargo/config.toml`.
8125981292
* @param path Path to the Cargo workspace.

dist/publish-crates-debian-main.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127929,7 +127929,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
127929127929
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
127930127930
/* harmony export */ "Mj": () => (/* binding */ installBinaryCached)
127931127931
/* harmony export */ });
127932-
/* unused harmony exports packages, packagesOrdered, bump, bumpDependencies, setRegistry, configRegistry, packagesDebian, installBinaryFromGit, build, hostTarget, buildDebian, toDebianVersion, isPublished */
127932+
/* unused harmony exports packages, packagesOrdered, bump, bumpDependencies, setRegistry, setGitBranch, configRegistry, packagesDebian, installBinaryFromGit, build, hostTarget, buildDebian, toDebianVersion, isPublished */
127933127933
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(22037);
127934127934
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
127935127935
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(71017);
@@ -128113,6 +128113,39 @@ async function setRegistry(path, pattern, registry) {
128113128113
}
128114128114
core.endGroup();
128115128115
}
128116+
/**
128117+
* Sets the git/branch config of select dependencies.
128118+
*
128119+
* @param path Path to the Cargo workspace.
128120+
* @param pattern A regular expression that matches the dependencies to be
128121+
* @param gitUrl git url to set in Cargo.toml dependency
128122+
* @param gitBranch git branch to set in Cargo.toml dependency
128123+
* updated
128124+
*/
128125+
async function setGitBranch(path, pattern, gitUrl, gitBranch) {
128126+
core.startGroup(`Setting ${pattern} dependencies' git/branch config`);
128127+
const manifestPath = `${path}/Cargo.toml`;
128128+
const manifestRaw = toml.get(manifestPath);
128129+
let manifest;
128130+
let prefix;
128131+
if ("workspace" in manifestRaw) {
128132+
prefix = ["workspace"];
128133+
manifest = manifestRaw["workspace"];
128134+
}
128135+
else {
128136+
prefix = [];
128137+
manifest = manifestRaw;
128138+
}
128139+
for (const dep in manifest.dependencies) {
128140+
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"))) {
128143+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "git"), gitUrl);
128144+
await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), gitBranch);
128145+
}
128146+
}
128147+
}
128148+
}
128116128149
/**
128117128150
* Stores Cargo registry configuration in `.cargo/config.toml`.
128118128151
* @param path Path to the Cargo workspace.

0 commit comments

Comments
 (0)