Skip to content

Commit

Permalink
Ros2 reorganize release candidate workflow (#281)
Browse files Browse the repository at this point in the history
* Reorganize the release candidate workflow

* Add pr trigger

* Remove pr trigger

* Improve description

* Add date argument

* disable deleting branches

* Update releaser repository workflow
  • Loading branch information
pawelirh authored Apr 30, 2024
1 parent cbb9daa commit 400a75d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
---
name: Test before release
name: Release candidate

on:
workflow_dispatch:
inputs:
target_branch:
description: Target branch for the release.
ref_branch:
description: Release candidate reference branch (candidates will branch from the reference branch).
required: true
test_tag:
description: Test tag name (used for images tagging).
version:
description: Release candidate version. IMPORTANT - required format `X.X.X`, eg `2.0.1`.
required: true
date:
description: Release candidate date stamp. IMPORTANT - required format `YYYYMMDD`, eg `20240430`.
required: true

env:
RC_BRANCH_NAME: ${{ github.event.inputs.version }}-${{ github.event.inputs.date }}

jobs:
# TODO: Add unit testing for panther_ros when ready
Expand All @@ -20,50 +26,50 @@ jobs:
- name: Trigger repository build workflow
run: echo "Unit tests for panther_ros are not fully implemented yet -> SKIPPING!"

prepare_test_branches_ros:
name: Prepare test branch for ROS repositories
create_release_candidate_branches:
name: Create release candidate branches
runs-on: ubuntu-22.04
needs:
- unit_test_panther_ros
strategy:
matrix:
repo: [panther_ros, panther_msgs]
repo: [panther_ros, panther_msgs, panther-docker, panther-rpi-os-img]
steps:
- name: Create test branch
uses: GuillaumeFalourd/create-other-repo-branch-action@v1.5
with:
repository_owner: husarion
repository_name: ${{ matrix.repo }}
new_branch_name: ${{ github.event.inputs.test_tag }}
new_branch_ref: ${{ github.event.inputs.target_branch }}
new_branch_name: ${{ env.RC_BRANCH_NAME }}
new_branch_ref: ${{ github.event.inputs.ref_branch }}
access_token: ${{ secrets.GH_PAT}}

prepare_test_branch_docker:
name: Prepare branch with test compose
update_tags_in_compose:
name: Update Docker image tags in compose
runs-on: ubuntu-22.04
needs:
- unit_test_panther_ros
- create_release_candidate_branches
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: prepare-test-branch.yaml
ref: ${{ github.event.inputs.target_branch }}
workflow_file_name: update-tags-in-compose.yaml
ref: ${{ env.RC_BRANCH_NAME }}
wait_interval: 10
client_payload: |
{
"target_branch": "${{ github.event.inputs.target_branch }}",
"test_branch": "${{ github.event.inputs.test_tag }}"
"target_branch": "${{ env.RC_BRANCH_NAME }}",
"image_tag": "humble-${{ env.RC_BRANCH_NAME }}"
}
build_and_push_docker_images:
name: Build panther docker images
runs-on: ubuntu-22.04
needs:
- prepare_test_branch_docker
- update_tags_in_compose
steps:
- name: Trigger repository build workflow
uses: convictional/trigger-workflow-and-wait@v1.6.1
Expand All @@ -72,7 +78,7 @@ jobs:
repo: panther-docker
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: ros-docker-image.yaml
ref: ${{ github.event.inputs.test_tag }}
ref: ${{ env.RC_BRANCH_NAME }}
wait_interval: 10
client_payload: |
{
Expand All @@ -83,8 +89,7 @@ jobs:
build_and_publish_rpi_image:
name: Build panther system image
needs:
- prepare_test_branches_ros
- prepare_test_branch_docker
- update_tags_in_compose
runs-on: ubuntu-22.04
steps:
- name: Trigger repository build workflow
Expand All @@ -94,30 +99,11 @@ jobs:
repo: panther-rpi-os-img
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: build_and_deploy_image.yaml
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ env.RC_BRANCH_NAME }}
wait_interval: 10
client_payload: |
{
"dev_image": "true",
"panther_codebase_version": "${{ github.event.inputs.test_tag }}",
"image_tag": "${{ github.event.inputs.test_tag }}"
"panther_codebase_version": "${{ env.RC_BRANCH_NAME }}",
"image_tag": "${{ github.event.inputs.version }}"
}
delete_test_branches:
name: Delete test branches
runs-on: ubuntu-22.04
needs:
- build_and_push_docker_images
- build_and_publish_rpi_image
if: always() # Always delete test branches, even if previous jobs failed
strategy:
matrix:
repo: [panther_ros, panther_msgs, panther-docker]
steps:
- name: Delete test branch
uses: dawidd6/action-delete-branch@v3
with:
owner: husarion
repository: ${{ matrix.repo }}
branches: ${{ github.event.inputs.test_tag }}
github_token: ${{ secrets.GH_PAT}}
50 changes: 23 additions & 27 deletions .github/workflows/release-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ on:
description: Target branch for the release.
required: true
version:
description: New version (used for tag and package versioning).
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 `YYYYMMDD`, eg `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`).
Expand All @@ -22,17 +25,11 @@ on:
default: false
description: Mark the release as a prerelease.

jobs:
get_date:
name: Get current date
runs-on: ubuntu-22.04
outputs:
date: ${{ steps.get_current_date.outputs.date }}
steps:
- name: Get current date
id: get_current_date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
env:
RC_BRANCH_NAME: ${{ github.event.inputs.version }}-${{ github.event.inputs.date }}
MAIN_BRANCH: ros2

jobs:
release_panther_msgs:
name: Release panther_msgs repository
runs-on: ubuntu-22.04
Expand All @@ -44,11 +41,11 @@ jobs:
repo: panther_msgs
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: release-repository.yaml
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ env.RC_BRANCH_NAME }}
wait_interval: 10
client_payload: |
{
"target_branch": "${{ github.event.inputs.target_branch }}",
"target_branch": "${{ 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 @@ -57,7 +54,8 @@ jobs:
release_panther_ros:
name: Release panther_ros repository
needs: release_panther_msgs
needs:
- release_panther_msgs
runs-on: ubuntu-22.04
steps:
- name: Trigger panther_ros release workflow
Expand All @@ -67,11 +65,11 @@ jobs:
repo: panther_ros
github_token: ${{ secrets.GITHUB_TOKEN }} # Use the default GITHUB_TOKEN for local repository
workflow_file_name: release-repository.yaml
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ env.RC_BRANCH_NAME }}
wait_interval: 10
client_payload: |
{
"target_branch": "${{ github.event.inputs.target_branch }}",
"target_branch": "${{ 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 @@ -82,7 +80,6 @@ jobs:
name: Release panther-docker repository
needs:
- release_panther_ros
- get_date
runs-on: ubuntu-22.04
steps:
- name: Trigger repository release workflow
Expand All @@ -92,13 +89,13 @@ jobs:
repo: panther-docker
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: release-repository.yaml
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ env.RC_BRANCH_NAME }}
wait_interval: 10
client_payload: |
{
"target_branch": "${{ github.event.inputs.target_branch }}",
"target_branch": "${{ env.RC_BRANCH_NAME }}",
"version": "${{ github.event.inputs.version }}",
"date": "${{ needs.get_date.outputs.date }}",
"date": "${{ github.event.inputs.date }}",
"release_name": "${{ github.event.inputs.release_name }}",
"automatic_mode": ${{ github.event.inputs.automatic_mode }},
"prerelease": ${{ github.event.inputs.prerelease }}
Expand All @@ -108,7 +105,6 @@ jobs:
name: Build panther docker images
needs:
- release_panther_docker
- get_date
runs-on: ubuntu-22.04
steps:
- name: Trigger repository build workflow
Expand All @@ -118,14 +114,14 @@ jobs:
repo: panther-docker
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: ros-docker-image.yaml
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ env.MAIN_BRANCH }}
wait_interval: 10
client_payload: |
{
"build_type": "stable",
"target_distro": "humble",
"target_release": "${{ github.event.inputs.version }}",
"target_date": "${{ needs.get_date.outputs.date }}"
"target_date": "${{ github.event.inputs.date }}"
}
release_panther_rpi_os_image:
Expand All @@ -141,11 +137,11 @@ jobs:
repo: panther-rpi-os-image
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: release-repository.yaml
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ env.RC_BRANCH_NAME }}
wait_interval: 10
client_payload: |
{
"target_branch": "${{ github.event.inputs.target_branch }}",
"target_branch": "${{ 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 @@ -165,11 +161,11 @@ jobs:
repo: panther-rpi-os-image
github_token: ${{ secrets.GH_PAT }}
workflow_file_name: build_and_deploy_image.yaml
ref: ${{ github.event.inputs.target_branch }}
ref: ${{ env.MAIN_BRANCH }}
wait_interval: 10
client_payload: |
{
"dev_image": "false",
"panther_codebase_version": "${{ github.event.inputs.version }}",
"image_tag": "${{ github.event.inputs.release_name }}",
"image_tag": "${{ github.event.inputs.version }}",
}
21 changes: 21 additions & 0 deletions .github/workflows/release-repository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
runs-on: ubuntu-22.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAIN_BRANCH: ros2
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -78,3 +79,23 @@ jobs:
gh release create ${{ steps.create_release_candidate.outputs.version }} \
--title ${{ github.event.inputs.release_name }} \
--notes-from-tag
- name: Create pull request to main branch
if: ${{ github.event.inputs.target_branch != env.MAIN_BRANCH }}
run: |
gh pr create \
--base ${{ env.MAIN_BRANCH }} \
--head ${{ github.event.inputs.target_branch }} \
--title "Release ${{ steps.create_release_candidate.outputs.version}} to main"
- name: Checkout to main
if: ${{ github.event.inputs.target_branch != env.MAIN_BRANCH && github.event.inputs.automatic_mode == true }}
uses: actions/checkout@v4
with:
ref: ${{ env.MAIN_BRANCH }}

- name: Merge pull request
if: ${{ github.event.inputs.target_branch != env.MAIN_BRANCH && github.event.inputs.automatic_mode == true }}
run: |
gh pr merge ${{ github.event.inputs.target_branch }} \
--delete-branch

0 comments on commit 400a75d

Please sign in to comment.