Skip to content

Commit

Permalink
Merge pull request #67 from husarion/ros2-use-precommit
Browse files Browse the repository at this point in the history
used precommit
  • Loading branch information
KmakD authored May 20, 2024
2 parents ac6ee18 + 2800a14 commit afa55cf
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 153 deletions.
192 changes: 99 additions & 93 deletions .github/workflows/release-repository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,107 +2,113 @@
name: Release repository

on:
workflow_dispatch:
inputs:
target_branch:
description: Target branch for the release.
required: true
version:
description: New version (used for tag).
required: true
date:
description: Date stamp of the image to be used in the compose files.
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:
target_branch:
description: Target branch for the release.
required: true
version:
description: New version (used for tag).
required: true
date:
description: Date stamp of the image to be used in the compose files.
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 }}
RELEASE_BRANCH: release-${{ github.event.inputs.version }}
DOCKER_IMAGE_TAG: humble-${{ github.event.inputs.version }}-${{ github.event.inputs.date }}-stable
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 }}
RELEASE_BRANCH: release-${{ github.event.inputs.version }}
DOCKER_IMAGE_TAG: humble-${{ github.event.inputs.version }}-${{ github.event.inputs.date }}-stable
MAIN_BRANCH: ros2
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target_branch }}

- name: Update docker image version
uses: mikefarah/[email protected]
with:
cmd: |
yq -i '.services.panther_ros.image = "husarion/panther:${{ env.DOCKER_IMAGE_TAG }}" | (... | select(tag == "!!merge")) tag = ""' demo/compose.minimal-setup.yaml
yq -i '.services.panther_gazebo.image = "husarion/panther-gazebo:${{ env.DOCKER_IMAGE_TAG }}" | (... | select(tag == "!!merge")) tag = ""' demo/compose.simulation.yaml
- name: Update docker image version
uses: mikefarah/[email protected]
with:
cmd: |
yq -i '.services.panther_ros.image = "husarion/panther:${{ env.DOCKER_IMAGE_TAG }}" | (... | select(tag == "!!merge")) tag = ""' demo/compose.minimal-setup.yaml
yq -i '.services.panther_gazebo.image = "husarion/panther-gazebo:${{ env.DOCKER_IMAGE_TAG }}" | (... | select(tag == "!!merge")) tag = ""' demo/compose.simulation.yaml
- name: Commit changes to release branch
uses: EndBug/add-and-commit@v9
with:
message: Update docker image version
author_name: action-bot
author_email: [email protected]
new_branch: ${{ env.RELEASE_BRANCH }}
- name: Commit changes to release branch
uses: EndBug/add-and-commit@v9
with:
message: Update docker image version
author_name: action-bot
author_email: [email protected]
new_branch: ${{ env.RELEASE_BRANCH }}

- name: Create pull request
run: |
gh pr create \
--base ${{ github.event.inputs.target_branch }} \
--head $RELEASE_BRANCH \
--title "Release ${{ github.event.inputs.version }}" \
--body "This PR incorporates tag(s) update in docker compose files."
- name: Create pull request
run: |
gh pr create \
--base ${{ github.event.inputs.target_branch }} \
--head $RELEASE_BRANCH \
--title "Release ${{ github.event.inputs.version }}" \
--body "This PR incorporates tag(s) update in docker compose files."
- name: Merge pull request
if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }}
run: |
gh pr merge $RELEASE_BRANCH \
--merge --delete-branch
- name: Merge pull request
if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }}
run: |
gh pr merge $RELEASE_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
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: 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 tag(s) update in docker compose files."
- 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 tag(s) update in docker compose files."
- 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 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: Create prerelease
if: ${{ fromJSON(github.event.inputs.automatic_mode) == true && fromJSON(github.event.inputs.prerelease) == true}}
run: |
gh release create ${{ github.event.inputs.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 ${{ github.event.inputs.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 ${{ github.event.inputs.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 ${{ github.event.inputs.version }} \
--target ${{ env.MAIN_BRANCH }} \
--title ${{ github.event.inputs.release_name }} \
--generate-notes
113 changes: 55 additions & 58 deletions .github/workflows/ros-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,63 @@
name: Build/Publish ROS Docker Image

on:
workflow_dispatch:
inputs:
build_type:
description: Is it a "development" or a "stable" release?
required: true
default: development
type: choice
options:
- development
- stable
target_distro:
description:
In case of "stable" release specify the ROS distro of the existing docker image (eg.
humble)
type: string
default: humble
target_release:
description:
In case of "stable" release specify the version of the existing docker image (eg.
1.0.12)
type: string
default: 0.0.0
target_date:
description:
In case of "stable" release specify the date of the existing docker image in format
YYYYMMDD (eg. 20220124)
type: string
default: "20131206"
workflow_dispatch:
inputs:
build_type:
description: Is it a "development" or a "stable" release?
required: true
default: development
type: choice
options:
- development
- stable
target_distro:
description: In case of "stable" release specify the ROS distro of the existing docker image (eg.
humble)
type: string
default: humble
target_release:
description: In case of "stable" release specify the version of the existing docker image (eg.
1.0.12)
type: string
default: 0.0.0
target_date:
description: In case of "stable" release specify the date of the existing docker image in format
YYYYMMDD (eg. 20220124)
type: string
default: '20131206'

jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile.hardware
platforms: linux/arm64
ros_distro: humble
- dockerfile: Dockerfile.simulation
repo_name: panther-gazebo
platforms: linux/amd64
ros_distro: humble
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile.hardware
platforms: linux/arm64
ros_distro: humble
- dockerfile: Dockerfile.simulation
repo_name: panther-gazebo
platforms: linux/amd64
ros_distro: humble

steps:
- name: Checkout
uses: actions/checkout@v2
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build Docker Image
uses: husarion-ci/[email protected]
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
main_branch_name: ros2
dockerfile: ${{ matrix.dockerfile }}
repo_name: ${{ matrix.repo_name }}
build_type: ${{ inputs.build_type }}
ros_distro: ${{ matrix.ros_distro }}
platforms: ${{ matrix.platforms }}
- name: Build Docker Image
uses: husarion-ci/[email protected]
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
main_branch_name: ros2
dockerfile: ${{ matrix.dockerfile }}
repo_name: ${{ matrix.repo_name }}
build_type: ${{ inputs.build_type }}
ros_distro: ${{ matrix.ros_distro }}
platforms: ${{ matrix.platforms }}
# variables important only for stable release
target_distro: ${{ inputs.target_distro }}
target_release: ${{ inputs.target_release }}
target_date: ${{ inputs.target_date }}
target_distro: ${{ inputs.target_distro }}
target_release: ${{ inputs.target_release }}
target_date: ${{ inputs.target_date }}
1 change: 0 additions & 1 deletion demo/compose.minimal-setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ services:
stop_signal: SIGINT
command: >
bash -c "ros2 launch joy2twist gamepad_controller.launch.py joy2twist_params_file:=$(ros2 pkg prefix joy2twist)/share/joy2twist/config/joy2twist_panther.yaml namespace:=panther"
1 change: 0 additions & 1 deletion demo/compose.simulation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ services:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
command: >
ros2 launch panther_gazebo simulation.launch.py

0 comments on commit afa55cf

Please sign in to comment.