Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros2 hotfix test #330

Closed
wants to merge 13 commits into from
23 changes: 23 additions & 0 deletions .github/workflows/protect-default-branch.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .github/workflows/release-candidate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -58,7 +58,7 @@ jobs:
wait_interval: 10
client_payload: |
{
"target_branch": "${{ env.RC_BRANCH_NAME }}",
"branch_name": "${{ env.RC_BRANCH_NAME }}",
"image_tag": "humble-${{ env.RC_BRANCH_NAME }}"
}

Expand Down
43 changes: 32 additions & 11 deletions .github/workflows/release-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
wait_interval: 10
client_payload: |
{
"target_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 }}",
Expand All @@ -63,23 +63,44 @@ 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 }}",
"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 }}",
"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/[email protected]
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
Expand All @@ -93,16 +114,16 @@ jobs:
wait_interval: 10
client_payload: |
{
"target_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 }}",
"automatic_mode": "${{ github.event.inputs.automatic_mode }}",
"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
Expand Down Expand Up @@ -143,7 +164,7 @@ jobs:
wait_interval: 10
client_payload: |
{
"target_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 }}",
Expand Down
59 changes: 36 additions & 23 deletions .github/workflows/release-repository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: Release repository
on:
workflow_dispatch:
inputs:
target_branch:
description: Target branch for the release.
release_candidate:
description: Branch name of the release candidate.
required: true
version:
description: New version (used for tag and package versioning).
Expand All @@ -30,64 +30,65 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAIN_BRANCH: ros2
DEVEL_BRANCH: ros2-devel
steps:
- name: Checkout
- name: Checkout to rc branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ github.event.inputs.release_candidate }}

- 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 }}
git_user: action-bot
git_email: [email protected]
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create pull request
- name: Catkin release - 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.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
- name: Catkin release - 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)
- 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)
- 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.target_branch }} \
--title "Release ${{ steps.create_release_candidate.outputs.version}} to ${{ 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)
- 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.target_branch }} \
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 }} \
gh release create ${{ steps.catkin_release.outputs.version }} \
--target ${{ env.MAIN_BRANCH }} \
--title ${{ github.event.inputs.release_name }} \
--generate-notes \
Expand All @@ -97,7 +98,19 @@ jobs:
if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease)
== false}}
run: |
gh release create ${{ steps.create_release_candidate.outputs.version }} \
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 }}