From b2da1cbddcaa22e4cea0f8a32a8008fe74415d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Irzyk?= <108666440+pawelirh@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:28:11 +0200 Subject: [PATCH 1/3] Ros2 improve release process (#58) * Format workflows * Update release repository workflow * Add formatting * Description typo * Add updating devel branch * Update step name * Add branch protection workflow * Add coderabbit config --- .coderabbit.yaml | 17 ++ .github/workflows/colcon_test_build.yaml | 2 +- .github/workflows/protect-default-branch.yaml | 23 +++ .github/workflows/release-repository.yaml | 185 ++++++++++-------- 4 files changed, 143 insertions(+), 84 deletions(-) create mode 100644 .coderabbit.yaml create mode 100644 .github/workflows/protect-default-branch.yaml diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000..51c85f2 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,17 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +language: "en-US" +early_access: false +reviews: + profile: "chill" + request_changes_workflow: false + high_level_summary: true + poem: false + review_status: true + collapse_walkthrough: false + auto_review: + enabled: true + drafts: false + base_branches: + - "ros2-devel" +chat: + auto_reply: true \ No newline at end of file diff --git a/.github/workflows/colcon_test_build.yaml b/.github/workflows/colcon_test_build.yaml index e48e43b..c5116b2 100644 --- a/.github/workflows/colcon_test_build.yaml +++ b/.github/workflows/colcon_test_build.yaml @@ -3,7 +3,7 @@ name: ROS2 test build on: push: branches: - - 'ros2' + - "ros2" jobs: colcon-test-build: diff --git a/.github/workflows/protect-default-branch.yaml b/.github/workflows/protect-default-branch.yaml new file mode 100644 index 0000000..61f85f4 --- /dev/null +++ b/.github/workflows/protect-default-branch.yaml @@ -0,0 +1,23 @@ +name: Validate PR head branch +on: + pull_request: + branches: + - "ros2" + +jobs: + check-head-branch: + runs-on: ubuntu-latest + steps: + - name: Check allowed branches + run: | + pattern="^[0-9]+\.[0-9]+\.[0-9]+-[0-9]{8}$" # This regex matches the X.X.X-YYYYMMDD pattern + if [[ "${{ github.head_ref }}" == *"hotfix"* ]]; then + echo "PR from a branch containing 'hotfix' is allowed." + exit 0 + elif [[ "${{ github.head_ref }}" =~ $pattern ]]; then + echo "PR from a branch matching X.X.X-YYYYMMDD pattern is allowed." + exit 0 + else + echo "PRs must come from branches containing 'hotfix' phrase or matching X.X.X-YYYYMMDD pattern." + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index a89f9f2..a5375e5 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -2,96 +2,115 @@ name: Release repository on: - workflow_dispatch: - inputs: - target_branch: - description: Target branch for the release. - required: true - version: - description: New version (used for tag and package versioning). - required: true - release_name: - description: Name of the release to be created. Version in the first place is recommended (e.g. `2.0.0-alpha`). - required: true - automatic_mode: - type: boolean - default: false - description: Automatically merge PR and create release. - prerelease: - type: boolean - default: false - description: Mark the release as a prerelease. + workflow_dispatch: + inputs: + release_candidate: + description: Branch name of the release candidate. + required: true + version: + description: New version (used for tag and package versioning). + required: true + release_name: + description: Name of the release to be created. Version in the first place is recommended (e.g. + `2.0.0-alpha`). + required: true + automatic_mode: + type: boolean + default: false + description: Automatically merge PR and create release. + prerelease: + type: boolean + default: false + description: Mark the release as a prerelease. jobs: - release: - name: Release repository - runs-on: ubuntu-22.04 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - MAIN_BRANCH: ros2 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.target_branch }} + release: + name: Release repository + runs-on: ubuntu-22.04 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MAIN_BRANCH: ros2 + DEVEL_BRANCH: ros2-devel + steps: + - name: Checkout to rc branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.release_candidate }} - - name: Create release candidate - id: create_release_candidate - uses: at-wat/catkin-release-action@v1 - with: - version: ${{ github.event.inputs.version }} - git_user: action-bot - git_email: action-bot@action-bot.com - github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Catkin release + id: catkin_release + uses: at-wat/catkin-release-action@v1 + with: + version: ${{ github.event.inputs.version }} + git_user: action-bot + git_email: action-bot@action-bot.com + github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Create pull request - run: | - gh pr create \ - --base ${{ github.event.inputs.target_branch }} \ - --head ${{ steps.create_release_candidate.outputs.created_branch }} \ - --title "Release ${{ steps.create_release_candidate.outputs.version}}" \ - --body "This PR incorporates package(s) version and changelog update." + - name: Catkin release - create PR + run: | + gh pr create \ + --base ${{ github.event.inputs.release_candidate }} \ + --head ${{ steps.catkin_release.outputs.created_branch }} \ + --title "Release ${{ steps.catkin_release.outputs.version}}" \ + --body "This PR incorporates package(s) version and changelog update." - - name: Merge pull request - if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} - run: | - gh pr merge ${{ steps.create_release_candidate.outputs.created_branch }} \ - --merge --delete-branch + - name: Catkin release - merge PR + if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} + run: | + gh pr merge ${{ steps.catkin_release.outputs.created_branch }} \ + --merge --delete-branch - - name: Checkout to main - if: ${{ github.event.inputs.target_branch != env.MAIN_BRANCH && fromJSON(github.event.inputs.automatic_mode) == true }} - uses: actions/checkout@v4 - with: - ref: ${{ env.MAIN_BRANCH }} + - name: Checkout to main branch + if: ${{ github.event.inputs.release_candidate != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) + == true }} + uses: actions/checkout@v4 + with: + ref: ${{ env.MAIN_BRANCH }} - - name: Create pull request to main - if: ${{ github.event.inputs.target_branch != env.MAIN_BRANCH && fromJSON(github.event.inputs.automatic_mode) == true }} - run: | - gh pr create \ - --base ${{ env.MAIN_BRANCH }} \ - --head ${{ github.event.inputs.target_branch }} \ - --title "Release ${{ steps.create_release_candidate.outputs.version}} to ${{ env.MAIN_BRANCH }}" \ - --body "This PR incorporates package(s) version and changelog update." + - name: Create PR to main branch + if: ${{ github.event.inputs.release_candidate != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) + == true }} + run: | + gh pr create \ + --base ${{ env.MAIN_BRANCH }} \ + --head ${{ github.event.inputs.release_candidate }} \ + --title "Release ${{ steps.catkin_release.outputs.version}} to ${{ env.MAIN_BRANCH }}" \ + --body "This PR incorporates package(s) version and changelog update." - - name: Merge pull request to main - if: ${{ github.event.inputs.target_branch != env.MAIN_BRANCH && fromJSON(github.event.inputs.automatic_mode) == true }} - run: | - gh pr merge ${{ github.event.inputs.target_branch }} \ - --merge --delete-branch + - name: Merge PR to main branch + if: ${{ github.event.inputs.release_candidate != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) + == true }} + run: | + gh pr merge ${{ github.event.inputs.release_candidate }} \ + --merge --delete-branch - - name: Create prerelease - if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) == true}} - run: | - gh release create ${{ steps.create_release_candidate.outputs.version }} \ - --target ${{ env.MAIN_BRANCH }} \ - --title ${{ github.event.inputs.release_name }} \ - --generate-notes \ - --prerelease + - name: Create prerelease + if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) + == true}} + run: | + gh release create ${{ steps.catkin_release.outputs.version }} \ + --target ${{ env.MAIN_BRANCH }} \ + --title ${{ github.event.inputs.release_name }} \ + --generate-notes \ + --prerelease - - name: Create release - if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) == false}} - run: | - gh release create ${{ steps.create_release_candidate.outputs.version }} \ - --target ${{ env.MAIN_BRANCH }} \ - --title ${{ github.event.inputs.release_name }} \ - --generate-notes + - name: Create release + if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) + == false}} + run: | + gh release create ${{ steps.catkin_release.outputs.version }} \ + --target ${{ env.MAIN_BRANCH }} \ + --title ${{ github.event.inputs.release_name }} \ + --generate-notes + + - name: Checkout to devel branch + if: ${{ env.DEVEL_BRANCH != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) == true }} + uses: actions/checkout@v4 + with: + ref: ${{ env.DEVEL_BRANCH }} + + - name: Update devel branch + if: ${{ env.DEVEL_BRANCH != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) == true }} + run: | + git pull origin ${{ env.MAIN_BRANCH }} + git push origin ${{ env.DEVEL_BRANCH }} From a314ed12ed522b2698364d2708e1f9e4c437a67a Mon Sep 17 00:00:00 2001 From: action-bot Date: Thu, 6 Jun 2024 13:00:50 +0000 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 506e090..65b7b5f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package panther_msgs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Ros2 improve release process (`#58 `_) +* Contributors: Paweł Irzyk + 2.0.2 (2024-06-05) ------------------ From 41840b455fbe5b787fb09fec223f242502b57fa0 Mon Sep 17 00:00:00 2001 From: action-bot Date: Thu, 6 Jun 2024 13:00:51 +0000 Subject: [PATCH 3/3] 2.0.3 --- CHANGELOG.rst | 4 ++-- package.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 65b7b5f..55cdc92 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package panther_msgs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +2.0.3 (2024-06-06) +------------------ * Ros2 improve release process (`#58 `_) * Contributors: Paweł Irzyk diff --git a/package.xml b/package.xml index be3626a..85774ee 100644 --- a/package.xml +++ b/package.xml @@ -2,7 +2,7 @@ panther_msgs - 2.0.2 + 2.0.3 Custom messages for Panther robot. Husarion Apache License 2.0