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 }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 506e090..55cdc92 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package panther_msgs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2.0.3 (2024-06-06) +------------------ +* Ros2 improve release process (`#58 `_) +* Contributors: Paweł Irzyk + 2.0.2 (2024-06-05) ------------------ 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