Skip to content

Merge release branch into main #74

Merge release branch into main

Merge release branch into main #74

name: Merge release branch into main
on:
workflow_call:
inputs:
version:
type: string
description: The release branch version to merge into main
required: true
workflow_dispatch:
inputs:
version:
type: string
description: The release branch version to merge into main
required: true
defaults:
run:
shell: bash
jobs:
merge-release-branch:
name: Submit PR to merge release branch into main
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repo:
- eclipse-zenoh/zenoh
- eclipse-zenoh/zenoh-pico
- eclipse-zenoh/zenoh-cpp
- eclipse-zenoh/zenoh-c
- eclipse-zenoh/zenoh-python
- eclipse-zenoh/zenoh-java
- eclipse-zenoh/zenoh-kotlin
- eclipse-zenoh/zenoh-plugin-dds
- eclipse-zenoh/zenoh-plugin-mqtt
- eclipse-zenoh/zenoh-plugin-ros2dds
- eclipse-zenoh/zenoh-plugin-webserver
- eclipse-zenoh/zenoh-backend-filesystem
- eclipse-zenoh/zenoh-backend-influxdb
- eclipse-zenoh/zenoh-backend-rocksdb
- eclipse-zenoh/zenoh-backend-s3
- 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: Install dependencies for zenoh-dissector
if: ${{ matrix.repo == 'eclipse-zenoh/zenoh-dissector' }}
run: |
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:wireshark-dev/stable
sudo apt install -y wireshark-dev
sudo apt install -y --allow-change-held-packages wireshark
- name: Update git/branch in release branch
if: ${{ !contains(fromJSON('["eclipse-zenoh/zenoh", "eclipse-zenoh/zenoh-pico", "eclipse-zenoh/zenoh-cpp"]'), matrix.repo) }}
uses: eclipse-zenoh/ci/set-git-branch@main
with:
version: ${{ inputs.version }}
release-branch: release/${{ inputs.version }}
repo: ${{ matrix.repo }}
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
deps-pattern: zenoh.*
deps-git-url: https://github.com/eclipse-zenoh/zenoh.git
deps-branch: main
- name: Compute branch
id: compute-branch
run: |
if [[ "${{ matrix.repo }}" =~ ^eclipse-zenoh/zenoh(-cpp|-pico)?$ ]] ; then
echo "branch=release/${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "branch=eclipse-zenoh-bot/post-release-${{ inputs.version }}" >> $GITHUB_OUTPUT
fi
- name: Create PR
id: cpr
run: |
output=$(gh pr create \
--title "chore: Merge release/${{ inputs.version }} into main" \
--body ":warning: This needs to be a merge commit :warning:" \
--head ${{ steps.compute-branch.outputs.branch }} \
--base main \
--label internal \
-R ${{ matrix.repo }} \
2>&1) && exit_code=$? || exit_code=$?
echo "Exit code: ${exit_code} Output: ${output}"
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
exit 0
fi
fi
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
- name: Enable auto merge for the pull request
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
run: >
gh pr merge "${{ steps.cpr.outputs.pull-request-number }}"
--subject "chore: Merge release/${{ inputs.version }} into main (#${{ steps.cpr.outputs.pull-request-number }})"
--repo "${{ matrix.repo }}"
--auto
--merge
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
- name: Add the PR as annotation to workflow run
if: contains(fromJSON('["created", "updated"]'), steps.cpr.outputs.pull-request-operation)
run: >
echo "::notice:: PR ${{ steps.cpr.outputs.pull-request-operation }}: https://github.com/${{ matrix.repo }}/pull/${{ steps.cpr.outputs.pull-request-number }}"