From 61934cdb3888fb12712c10cd7f14882b49c8161d Mon Sep 17 00:00:00 2001 From: pawelirh Date: Tue, 4 Jun 2024 13:15:01 +0000 Subject: [PATCH 01/13] Update release repository workflow --- .github/workflows/release-project.yaml | 15 +++-- .github/workflows/release-repository.yaml | 69 ++++++++++++----------- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index 132de2de..4c90925a 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -5,15 +5,18 @@ on: workflow_dispatch: inputs: version: - description: Release version, must match release candidate version. IMPORTANT - required format + description: + Release version, must match release candidate version. IMPORTANT - required format `X.X.X`, eg `2.0.1`. required: true date: - description: Release date stamp, must match release candidate date. IMPORTANT - required format + description: + Release date stamp, must match release candidate date. IMPORTANT - required format `YYYYMMDD`, eg `20240430`. required: true release_name: - description: Name of the release to be created. Version in the first place is recommended (e.g. + 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: @@ -45,7 +48,7 @@ jobs: wait_interval: 10 client_payload: | { - "target_branch": "${{ env.RC_BRANCH_NAME }}", + "source_branch": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "release_name": "${{ github.event.inputs.release_name }}", "automatic_mode": "${{ github.event.inputs.automatic_mode }}", @@ -63,13 +66,13 @@ jobs: with: owner: husarion repo: panther_ros - github_token: ${{ secrets.GITHUB_TOKEN }} # Use the default GITHUB_TOKEN for local repository + github_token: ${{ secrets.GITHUB_TOKEN }} # Use the default GITHUB_TOKEN for local repository workflow_file_name: release-repository.yaml ref: ${{ env.RC_BRANCH_NAME }} wait_interval: 10 client_payload: | { - "target_branch": "${{ env.RC_BRANCH_NAME }}", + "source_branch": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "release_name": "${{ github.event.inputs.release_name }}", "automatic_mode": "${{ github.event.inputs.automatic_mode }}", diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index ed1b53d3..7d9b9660 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -4,14 +4,19 @@ name: Release repository on: workflow_dispatch: inputs: - target_branch: - description: Target branch for the release. + source_branch: + description: "Source branch for the release" required: true + target_branch: + description: "Target branch for the release" + required: false + default: "ros2" 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. + 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: @@ -29,15 +34,14 @@ jobs: 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 }} + ref: ${{ github.event.inputs.source_branch }} - - name: Create release candidate - id: create_release_candidate + - name: Catkin release + id: catkin_release uses: at-wat/catkin-release-action@v1 with: version: ${{ github.event.inputs.version }} @@ -45,59 +49,58 @@ jobs: git_email: action-bot@action-bot.com github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Create pull request + - name: Create PR 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}}" \ + --base ${{ github.event.inputs.source_branch }} \ + --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 + - name: Merge PR if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} run: | - gh pr merge ${{ steps.create_release_candidate.outputs.created_branch }} \ + 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 }} + - name: Checkout to target branch + if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) == true }} uses: actions/checkout@v4 with: - ref: ${{ env.MAIN_BRANCH }} + ref: ${{ github.event.inputs.target_branch }} - - name: Create pull request to main - if: ${{ github.event.inputs.target_branch != env.MAIN_BRANCH && fromJSON(github.event.inputs.automatic_mode) - == true }} + - name: Create PR to target branch + if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(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 }}" \ + --base ${{ github.event.inputs.target_branch }} \ + --head ${{ github.event.inputs.source_branch }} \ + --title "Release ${{ steps.catkin_release.outputs.version}} to ${{ github.event.inputs.target_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 }} + - name: Merge PR to target branch + if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) == true }} run: | - gh pr merge ${{ github.event.inputs.target_branch }} \ + gh pr merge ${{ github.event.inputs.source_branch }} \ --merge --delete-branch - name: Create prerelease - if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.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 }} \ + gh release create ${{ steps.catkin_release.outputs.version }} \ + --target ${{ github.event.inputs.target_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) + 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 }} \ + gh release create ${{ steps.catkin_release.outputs.version }} \ + --target ${{ github.event.inputs.target_branch }} \ --title ${{ github.event.inputs.release_name }} \ --generate-notes From 1f3fb8cf181bf43624cc55da4281aa85052e0813 Mon Sep 17 00:00:00 2001 From: pawelirh Date: Tue, 4 Jun 2024 13:16:32 +0000 Subject: [PATCH 02/13] Add pre commit format --- .github/workflows/release-project.yaml | 9 +++------ .github/workflows/release-repository.yaml | 24 +++++++++++------------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index 4c90925a..d4c932e6 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -5,18 +5,15 @@ on: workflow_dispatch: inputs: version: - description: - Release version, must match release candidate version. IMPORTANT - required format + description: Release version, must match release candidate version. IMPORTANT - required format `X.X.X`, eg `2.0.1`. required: true date: - description: - Release date stamp, must match release candidate date. IMPORTANT - required format + description: Release date stamp, must match release candidate date. IMPORTANT - required format `YYYYMMDD`, eg `20240430`. required: true release_name: - description: - Name of the release to be created. Version in the first place is recommended (e.g. + 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: diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index 7d9b9660..efbc24d7 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -5,18 +5,17 @@ on: workflow_dispatch: inputs: source_branch: - description: "Source branch for the release" + description: Source branch for the release required: true target_branch: - description: "Target branch for the release" + description: Target branch for the release required: false - default: "ros2" + default: ros2 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. + 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: @@ -64,13 +63,15 @@ jobs: --merge --delete-branch - name: Checkout to target branch - if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) == true }} + if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) + == true }} uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.target_branch }} - name: Create PR to target branch - if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) == true }} + if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) + == true }} run: | gh pr create \ --base ${{ github.event.inputs.target_branch }} \ @@ -79,14 +80,14 @@ jobs: --body "This PR incorporates package(s) version and changelog update." - name: Merge PR to target branch - if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) == true }} + if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) + == true }} run: | gh pr merge ${{ github.event.inputs.source_branch }} \ --merge --delete-branch - name: Create prerelease - if: - ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) + if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) == true}} run: | gh release create ${{ steps.catkin_release.outputs.version }} \ @@ -96,8 +97,7 @@ jobs: --prerelease - name: Create release - if: - ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) + if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) == false}} run: | gh release create ${{ steps.catkin_release.outputs.version }} \ From 163de5bc8d9e94c8332cd0f8e5ce445beaecc8fc Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 09:34:28 +0000 Subject: [PATCH 03/13] Update branch naming in release workflows --- .github/workflows/release-candidate.yaml | 4 +-- .github/workflows/release-project.yaml | 31 +++++++++++++++++++---- .github/workflows/release-repository.yaml | 4 +-- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-candidate.yaml b/.github/workflows/release-candidate.yaml index 1b8888a6..f9d06160 100644 --- a/.github/workflows/release-candidate.yaml +++ b/.github/workflows/release-candidate.yaml @@ -38,7 +38,7 @@ jobs: repository_owner: husarion repository_name: ${{ matrix.repo }} new_branch_name: ${{ env.RC_BRANCH_NAME }} - new_branch_ref: ros2 + new_branch_ref: ros2-devel access_token: ${{ secrets.GH_PAT}} update_tags_in_compose: @@ -58,7 +58,7 @@ jobs: wait_interval: 10 client_payload: | { - "target_branch": "${{ env.RC_BRANCH_NAME }}", + "source_branch": "${{ env.RC_BRANCH_NAME }}", "image_tag": "humble-${{ env.RC_BRANCH_NAME }}" } diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index d4c932e6..728fb602 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -76,10 +76,31 @@ jobs: "prerelease": "${{ github.event.inputs.prerelease }}" } + rebuild_and_push_docker_images: + name: Rebuild panther docker images with new version + runs-on: ubuntu-22.04 + needs: + - release_panther_ros + steps: + - name: Trigger repository build workflow + uses: convictional/trigger-workflow-and-wait@v1.6.1 + with: + owner: husarion + repo: panther-docker + github_token: ${{ secrets.GH_PAT }} + workflow_file_name: ros-docker-image.yaml + ref: ${{ env.RC_BRANCH_NAME }} + wait_interval: 10 + client_payload: | + { + "build_type": "development", + "target_distro": "humble" + } + release_panther_docker: name: Release panther-docker repository needs: - - release_panther_ros + - rebuild_and_push_docker_images runs-on: ubuntu-22.04 steps: - name: Trigger repository release workflow @@ -93,7 +114,7 @@ jobs: wait_interval: 10 client_payload: | { - "target_branch": "${{ env.RC_BRANCH_NAME }}", + "source_branch": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "date": "${{ github.event.inputs.date }}", "release_name": "${{ github.event.inputs.release_name }}", @@ -101,8 +122,8 @@ jobs: "prerelease": "${{ github.event.inputs.prerelease }}" } - build_and_push_docker_images: - name: Build panther docker images + tag_docker_images: + name: Tag panther docker images as stable if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} needs: - release_panther_docker @@ -143,7 +164,7 @@ jobs: wait_interval: 10 client_payload: | { - "target_branch": "${{ env.RC_BRANCH_NAME }}", + "source_branch": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "release_name": "${{ github.event.inputs.release_name }}", "automatic_mode": "${{ github.event.inputs.automatic_mode }}", diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index efbc24d7..2ea2556d 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -5,10 +5,10 @@ on: workflow_dispatch: inputs: source_branch: - description: Source branch for the release + description: Source branch for the release. required: true target_branch: - description: Target branch for the release + description: Target branch for the release. required: false default: ros2 version: From 7d8e70c27ef6e80ef2da2df0ff5624b9393c64dc Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 10:18:55 +0000 Subject: [PATCH 04/13] Use feature branches for testing --- .github/workflows/release-candidate.yaml | 3 ++- .github/workflows/release-project.yaml | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-candidate.yaml b/.github/workflows/release-candidate.yaml index f9d06160..b5435bc0 100644 --- a/.github/workflows/release-candidate.yaml +++ b/.github/workflows/release-candidate.yaml @@ -54,7 +54,8 @@ jobs: repo: panther-docker github_token: ${{ secrets.GH_PAT }} workflow_file_name: update-tags-in-compose.yaml - ref: ${{ env.RC_BRANCH_NAME }} + # ref: ${{ env.RC_BRANCH_NAME }} + ref: ros2-improve-release-process wait_interval: 10 client_payload: | { diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index 728fb602..03768d76 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -41,7 +41,8 @@ jobs: repo: panther_msgs github_token: ${{ secrets.GH_PAT }} workflow_file_name: release-repository.yaml - ref: ${{ env.RC_BRANCH_NAME }} + # ref: ${{ env.RC_BRANCH_NAME }} + ref: ros2-improve-release-process wait_interval: 10 client_payload: | { @@ -65,7 +66,8 @@ jobs: repo: panther_ros github_token: ${{ secrets.GITHUB_TOKEN }} # Use the default GITHUB_TOKEN for local repository workflow_file_name: release-repository.yaml - ref: ${{ env.RC_BRANCH_NAME }} + # ref: ${{ env.RC_BRANCH_NAME }} + ref: ros2-improve-release-process wait_interval: 10 client_payload: | { @@ -110,7 +112,8 @@ jobs: repo: panther-docker github_token: ${{ secrets.GH_PAT }} workflow_file_name: release-repository.yaml - ref: ${{ env.RC_BRANCH_NAME }} + # ref: ${{ env.RC_BRANCH_NAME }} + ref: ros2-improve-release-process wait_interval: 10 client_payload: | { @@ -160,7 +163,8 @@ jobs: repo: panther-rpi-os-img github_token: ${{ secrets.GH_PAT }} workflow_file_name: release-repository.yaml - ref: ${{ env.RC_BRANCH_NAME }} + # ref: ${{ env.RC_BRANCH_NAME }} + ref: ros2-improve-release-process wait_interval: 10 client_payload: | { From 227e24789d11d4a8fef97911dab51edad7fb77ee Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 12:24:57 +0000 Subject: [PATCH 05/13] Improve arguments description --- .github/workflows/release-project.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index 03768d76..b8bc1182 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -6,15 +6,15 @@ on: inputs: version: description: Release version, must match release candidate version. IMPORTANT - required format - `X.X.X`, eg `2.0.1`. + `X.X.X`, (e.g. `2.0.1`). required: true date: description: Release date stamp, must match release candidate date. IMPORTANT - required format - `YYYYMMDD`, eg `20240430`. + `YYYYMMDD`, (e.g. `20240430`). 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`). + `2.0.1-alpha`). required: true automatic_mode: type: boolean From 270d199b8441cd11d608a29094715bc9317c2e68 Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 13:19:20 +0000 Subject: [PATCH 06/13] Implement devel branch update --- .github/workflows/release-repository.yaml | 143 ++++++++++++---------- 1 file changed, 76 insertions(+), 67 deletions(-) diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index 2ea2556d..eb82b76e 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -4,13 +4,9 @@ name: Release repository on: workflow_dispatch: inputs: - source_branch: - description: Source branch for the release. + release_candidate: + description: Branch name of the release candidate. required: true - target_branch: - description: Target branch for the release. - required: false - default: ros2 version: description: New version (used for tag and package versioning). required: true @@ -33,74 +29,87 @@ jobs: runs-on: ubuntu-22.04 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MAIN_BRANCH: ros2 + DEVEL_BRANCH: ros2-devel steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.source_branch }} + # - name: Checkout to rc branch + # uses: actions/checkout@v4 + # with: + # ref: ${{ github.event.inputs.release_candidate }} - - 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: 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 PR - run: | - gh pr create \ - --base ${{ github.event.inputs.source_branch }} \ - --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: 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 PR - if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} - run: | - gh pr merge ${{ steps.catkin_release.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 target branch - if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) - == true }} - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.target_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 PR to target branch - if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) - == true }} - run: | - gh pr create \ - --base ${{ github.event.inputs.target_branch }} \ - --head ${{ github.event.inputs.source_branch }} \ - --title "Release ${{ steps.catkin_release.outputs.version}} to ${{ github.event.inputs.target_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 PR to target branch - if: ${{ github.event.inputs.source_branch != github.event.inputs.target_branch && fromJSON(inputs.automatic_mode) - == true }} - run: | - gh pr merge ${{ github.event.inputs.source_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.catkin_release.outputs.version }} \ - --target ${{ github.event.inputs.target_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.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: Create release - if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) - == false}} + - name: Update version in devel branch + if: ${{ env.DEVEL_BRANCH != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) == true }} run: | - gh release create ${{ steps.catkin_release.outputs.version }} \ - --target ${{ github.event.inputs.target_branch }} \ - --title ${{ github.event.inputs.release_name }} \ - --generate-notes + git pull origin ${{ env.MAIN_BRANCH }} From 32501e0629f65d076dd17ca44edf74abc913571e Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 13:22:44 +0000 Subject: [PATCH 07/13] Push updated devel branch --- .github/workflows/release-repository.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index eb82b76e..9571bfef 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -103,13 +103,15 @@ jobs: # --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: 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 version in devel branch if: ${{ env.DEVEL_BRANCH != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) == true }} run: | + git checkout ${{ env.DEVEL_BRANCH }} git pull origin ${{ env.MAIN_BRANCH }} + git push origin ${{ env.DEVEL_BRANCH }} From e010864d89760b9bf9fa626644a83afedb3c20d9 Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 13:24:50 +0000 Subject: [PATCH 08/13] Restore separate checkout --- .github/workflows/release-repository.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index 9571bfef..6fd15a31 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -103,15 +103,14 @@ jobs: # --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: 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 version in devel branch if: ${{ env.DEVEL_BRANCH != env.MAIN_BRANCH && fromJSON(inputs.automatic_mode) == true }} run: | - git checkout ${{ env.DEVEL_BRANCH }} git pull origin ${{ env.MAIN_BRANCH }} git push origin ${{ env.DEVEL_BRANCH }} From ccd99d27409e4d373dcdf6f8202f05be4f3b1d4b Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 13:26:53 +0000 Subject: [PATCH 09/13] Uncomment changes --- .github/workflows/release-repository.yaml | 124 +++++++++++----------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index 6fd15a31..12ca009c 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -32,76 +32,76 @@ jobs: 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: Checkout to rc branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.release_candidate }} - # - 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: 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: 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: 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: 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: 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 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: 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 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: 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 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: 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.catkin_release.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.catkin_release.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 }} From cf77e31b6461e971281ca7ba9edaa03c81e81c23 Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 14:24:49 +0000 Subject: [PATCH 10/13] Update argument names --- .github/workflows/release-candidate.yaml | 2 +- .github/workflows/release-project.yaml | 8 ++++---- .github/workflows/release-repository.yaml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-candidate.yaml b/.github/workflows/release-candidate.yaml index b5435bc0..d13a73be 100644 --- a/.github/workflows/release-candidate.yaml +++ b/.github/workflows/release-candidate.yaml @@ -59,7 +59,7 @@ jobs: wait_interval: 10 client_payload: | { - "source_branch": "${{ env.RC_BRANCH_NAME }}", + "branch_name": "${{ env.RC_BRANCH_NAME }}", "image_tag": "humble-${{ env.RC_BRANCH_NAME }}" } diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index b8bc1182..18e166c8 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -46,7 +46,7 @@ jobs: wait_interval: 10 client_payload: | { - "source_branch": "${{ env.RC_BRANCH_NAME }}", + "release_candidate": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "release_name": "${{ github.event.inputs.release_name }}", "automatic_mode": "${{ github.event.inputs.automatic_mode }}", @@ -71,7 +71,7 @@ jobs: wait_interval: 10 client_payload: | { - "source_branch": "${{ env.RC_BRANCH_NAME }}", + "release_candidate": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "release_name": "${{ github.event.inputs.release_name }}", "automatic_mode": "${{ github.event.inputs.automatic_mode }}", @@ -117,7 +117,7 @@ jobs: wait_interval: 10 client_payload: | { - "source_branch": "${{ env.RC_BRANCH_NAME }}", + "release_candidate": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "date": "${{ github.event.inputs.date }}", "release_name": "${{ github.event.inputs.release_name }}", @@ -168,7 +168,7 @@ jobs: wait_interval: 10 client_payload: | { - "source_branch": "${{ env.RC_BRANCH_NAME }}", + "release_candidate": "${{ env.RC_BRANCH_NAME }}", "version": "${{ github.event.inputs.version }}", "release_name": "${{ github.event.inputs.release_name }}", "automatic_mode": "${{ github.event.inputs.automatic_mode }}", diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index 12ca009c..a5375e55 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -109,7 +109,7 @@ jobs: with: ref: ${{ env.DEVEL_BRANCH }} - - name: Update version in 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 }} From b99243866cd2624197ba130144d7256a32369cd0 Mon Sep 17 00:00:00 2001 From: pawelirh Date: Wed, 5 Jun 2024 19:54:58 +0000 Subject: [PATCH 11/13] Restore branches --- .github/workflows/release-candidate.yaml | 3 +-- .github/workflows/release-project.yaml | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release-candidate.yaml b/.github/workflows/release-candidate.yaml index d13a73be..98bc79b9 100644 --- a/.github/workflows/release-candidate.yaml +++ b/.github/workflows/release-candidate.yaml @@ -54,8 +54,7 @@ jobs: repo: panther-docker github_token: ${{ secrets.GH_PAT }} workflow_file_name: update-tags-in-compose.yaml - # ref: ${{ env.RC_BRANCH_NAME }} - ref: ros2-improve-release-process + ref: ${{ env.RC_BRANCH_NAME }} wait_interval: 10 client_payload: | { diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index 18e166c8..48b98d95 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -41,8 +41,7 @@ jobs: repo: panther_msgs github_token: ${{ secrets.GH_PAT }} workflow_file_name: release-repository.yaml - # ref: ${{ env.RC_BRANCH_NAME }} - ref: ros2-improve-release-process + ref: ${{ env.RC_BRANCH_NAME }} wait_interval: 10 client_payload: | { @@ -66,8 +65,7 @@ jobs: repo: panther_ros github_token: ${{ secrets.GITHUB_TOKEN }} # Use the default GITHUB_TOKEN for local repository workflow_file_name: release-repository.yaml - # ref: ${{ env.RC_BRANCH_NAME }} - ref: ros2-improve-release-process + ref: ${{ env.RC_BRANCH_NAME }} wait_interval: 10 client_payload: | { @@ -112,8 +110,7 @@ jobs: repo: panther-docker github_token: ${{ secrets.GH_PAT }} workflow_file_name: release-repository.yaml - # ref: ${{ env.RC_BRANCH_NAME }} - ref: ros2-improve-release-process + ref: ${{ env.RC_BRANCH_NAME }} wait_interval: 10 client_payload: | { @@ -163,8 +160,7 @@ jobs: repo: panther-rpi-os-img github_token: ${{ secrets.GH_PAT }} workflow_file_name: release-repository.yaml - # ref: ${{ env.RC_BRANCH_NAME }} - ref: ros2-improve-release-process + ref: ${{ env.RC_BRANCH_NAME }} wait_interval: 10 client_payload: | { From 20a60576c71fa3636d0050a3a0078b776e856f9e Mon Sep 17 00:00:00 2001 From: pawelirh Date: Thu, 6 Jun 2024 07:37:50 +0000 Subject: [PATCH 12/13] Add branch protection rule --- .github/workflows/protect-default-branch.yaml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/protect-default-branch.yaml diff --git a/.github/workflows/protect-default-branch.yaml b/.github/workflows/protect-default-branch.yaml new file mode 100644 index 00000000..3f305644 --- /dev/null +++ b/.github/workflows/protect-default-branch.yaml @@ -0,0 +1,25 @@ +name: Validate PR head branch +on: + pull_request: + types: + - opened + 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 From d5085a7fb2e4edef93f9b7a8ff8dbe628c26ffb3 Mon Sep 17 00:00:00 2001 From: pawelirh Date: Thu, 6 Jun 2024 07:52:46 +0000 Subject: [PATCH 13/13] Update workflow trigger --- .github/workflows/protect-default-branch.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/protect-default-branch.yaml b/.github/workflows/protect-default-branch.yaml index 3f305644..61f85f45 100644 --- a/.github/workflows/protect-default-branch.yaml +++ b/.github/workflows/protect-default-branch.yaml @@ -1,10 +1,8 @@ name: Validate PR head branch on: pull_request: - types: - - opened branches: - - ros2 + - "ros2" jobs: check-head-branch: