diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
new file mode 100644
index 0000000..b8b1f01
--- /dev/null
+++ b/.github/workflows/pre-commit.yml
@@ -0,0 +1,27 @@
+---
+name: Pre-commit
+
+on:
+ pull_request:
+ push:
+ branches: [main]
+
+jobs:
+ run-pre-commit:
+ name: Pre-commit Check
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.x'
+
+ - name: Install pre-commit
+ run: |
+ python -m pip install --upgrade pip
+ pip install pre-commit
+
+ - name: Run pre-commit hooks
+ run: pre-commit run --all-files
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..bb89475
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,138 @@
+name: Test Action
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+ workflow_dispatch:
+
+jobs:
+ test-all-packages:
+ runs-on: ubuntu-${{ matrix.ubuntu_version }}
+
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - ros_distro: rolling
+ debian_distro: noble
+ ubuntu_version: '24.04'
+ packages_dir: test
+
+ - ros_distro: kilted
+ debian_distro: noble
+ ubuntu_version: '24.04'
+ packages_dir: test
+
+ - ros_distro: jazzy
+ debian_distro: noble
+ ubuntu_version: '24.04'
+ packages_dir: test
+
+ - ros_distro: humble
+ debian_distro: jammy
+ ubuntu_version: '22.04'
+ packages_dir: test
+
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Test ${{ matrix.ros_distro }} - All packages
+ uses: ./
+ with:
+ ros_distro: ${{ matrix.ros_distro }}
+ debian_distro: ${{ matrix.debian_distro }}
+ packages_dir: ${{ matrix.packages_dir }}
+
+ test-whitelist:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Test whitelist - Only package_a and package_b
+ uses: ./
+ with:
+ ros_distro: humble
+ debian_distro: jammy
+ packages_dir: test
+ package_whitelist: '^.*/package_[ab]$'
+ artifact_name: bloom-test-whitelist
+
+ - name: Verify only package_a and package_b built
+ shell: bash
+ run: |
+ echo "Checking generated packages..."
+ ls -la ./bloom-build/output/
+
+ # Should have package_a and package_b
+ test -f ./bloom-build/output/ros-humble-package-a*.deb || (echo "Missing package_a" && exit 1)
+ test -f ./bloom-build/output/ros-humble-package-b*.deb || (echo "Missing package_b" && exit 1)
+
+ # Should NOT have package_c, package_d, or package_test
+ ! ls ./bloom-build/output/ros-humble-package-c*.deb 2>/dev/null && echo "✓ No package_c (correct)"
+ ! ls ./bloom-build/output/ros-humble-package-d*.deb 2>/dev/null && echo "✓ No package_d (correct)"
+ ! ls ./bloom-build/output/ros-humble-package-test*.deb 2>/dev/null && echo "✓ No package_test (correct)"
+
+ test-blacklist:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Test blacklist - Exclude *_test packages
+ uses: ./
+ with:
+ ros_distro: humble
+ debian_distro: jammy
+ packages_dir: test
+ package_blacklist: '.*_test$'
+ artifact_name: bloom-test-blacklist
+
+ - name: Verify package_test was excluded
+ shell: bash
+ run: |
+ echo "Checking generated packages..."
+ ls -la ./bloom-build/output/
+
+ # Should NOT have package_test
+ ! ls ./bloom-build/output/ros-humble-package-test*.deb 2>/dev/null && echo "✓ package_test excluded (correct)"
+
+ # Should have other packages
+ test -f ./bloom-build/output/ros-humble-package-a*.deb || (echo "Missing package_a" && exit 1)
+ test -f ./bloom-build/output/ros-humble-package-c*.deb || (echo "Missing package_c" && exit 1)
+
+ test-whitelist-and-blacklist:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Test combined whitelist and blacklist
+ uses: ./
+ with:
+ ros_distro: humble
+ debian_distro: jammy
+ packages_dir: test
+ package_whitelist: '^.*/package_[abc]$'
+ package_blacklist: '^.*/package_c$'
+ artifact_name: bloom-test-whitelist-blacklist
+
+ - name: Verify correct filtering
+ shell: bash
+ run: |
+ echo "Checking generated packages..."
+ ls -la ./bloom-build/output/
+
+ # Should have package_a and package_b
+ test -f ./bloom-build/output/ros-humble-package-a*.deb || (echo "Missing package_a" && exit 1)
+ test -f ./bloom-build/output/ros-humble-package-b*.deb || (echo "Missing package_b" && exit 1)
+
+ # Should NOT have package_c, package_d, or package_test
+ ! ls ./bloom-build/output/ros-humble-package-c*.deb 2>/dev/null && echo "✓ No package_c (correct)"
+ ! ls ./bloom-build/output/ros-humble-package-d*.deb 2>/dev/null && echo "✓ No package_d (correct)"
+ ! ls ./bloom-build/output/ros-humble-package-test*.deb 2>/dev/null && echo "✓ No package_test (correct)"
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..128c5aa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+# Build artifacts
+*.deb
+*.ddeb
+*.changes
+*.dsc
+*.tar.gz
+*.buildinfo
+
+# IDE
+.vscode/
+.idea/
+*.swp
+*.swo
+*~
+
+# OS
+.DS_Store
+Thumbs.db
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..f2c9e71
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,36 @@
+---
+repos:
+ # General-purpose sanity checks
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v5.0.0
+ hooks:
+ - id: check-added-large-files
+ - id: check-case-conflict
+ - id: check-merge-conflict
+ - id: check-shebang-scripts-are-executable
+ - id: check-symlinks
+ - id: check-xml
+ - id: end-of-file-fixer
+ - id: mixed-line-ending
+ - id: trailing-whitespace
+ - id: check-yaml
+
+ # Bash / Shell scripts
+ - repo: https://github.com/shellcheck-py/shellcheck-py
+ rev: v0.10.0.1
+ hooks:
+ - id: shellcheck
+
+ # Markdown linting
+ - repo: https://github.com/jackdewinter/pymarkdown
+ rev: v0.9.28
+ hooks:
+ - id: pymarkdown
+ args: [-d, MD013, scan]
+
+ # YAML linting
+ - repo: https://github.com/adrienverge/yamllint.git
+ rev: v1.35.1
+ hooks:
+ - id: yamllint
+ args: [-d, '{extends: default, rules: {line-length: {max: 120}, document-start: disable}}']
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5f53fb2
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2023 WATonomous
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/README.md b/README.md
index b8b8ec6..5403837 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,115 @@
# bloom-release-ros
+
+A GitHub Action for automatically building and packaging ROS 2 packages into Debian packages using [bloom](https://wiki.ros.org/bloom).
+
+**IMPORTANT** This action does not support End of Life ROS distributions.
+
+## Features
+
+- Automatically discovers and builds all ROS 2 packages in your repository
+- Filter packages using whitelist/blacklist regex patterns
+- Supports ROS 2 (Humble, Jazzy, Kilted, Rolling)
+- Outputs ready-to-deploy .deb files
+
+## Quick Start
+
+```yaml
+name: Build ROS Packages
+
+on:
+ push:
+ branches: [ main ]
+
+jobs:
+ build:
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: watonomous/bloom-release-ros@v1
+ with:
+ ros_distro: 'humble'
+ debian_distro: 'jammy'
+ packages_dir: '.' # Optional: directory to search for packages
+ package_whitelist: '.*' # Optional: regex to whitelist packages
+ package_blacklist: '' # Optional: regex to blacklist packages
+```
+
+Artifacts are automatically uploaded as `bloom-debian-packages-{distro}-{job}-{run_id}` and can be downloaded from the Actions tab.
+
+## Inputs
+
+| Input | Description | Required | Default |
+|-------|-------------|----------|---------|
+| `ros_distro` | ROS 2 distribution (humble, jazzy, kilted, rolling) | Yes | - |
+| `debian_distro` | Debian/Ubuntu distribution (jammy, noble) | Yes | - |
+| `packages_dir` | Directory to search for ROS packages | No | `.` |
+| `package_whitelist` | Regex to whitelist package names | No | `.*` |
+| `package_blacklist` | Regex to blacklist package names | No | `''` |
+| `artifact_name` | Custom artifact name (avoids conflicts in parallel jobs) | No | `bloom-debian-packages-{distro}-{job}-{run_id}` |
+
+## Filtering Packages
+
+```yaml
+# Build only packages starting with "myproject_"
+package_whitelist: '^myproject_.*'
+
+# Exclude test packages
+package_blacklist: '.*_test$'
+
+# Combine filters
+package_whitelist: '^myproject_.*'
+package_blacklist: '.*_(test|sim)$'
+```
+
+## Avoiding Artifact Conflicts
+
+When running multiple jobs in parallel with the same ROS distro, use custom artifact names:
+
+```yaml
+jobs:
+ build-all:
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+ - uses: watonomous/bloom-release-ros@v1
+ with:
+ ros_distro: humble
+ debian_distro: jammy
+ artifact_name: bloom-all-packages
+
+ build-filtered:
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+ - uses: watonomous/bloom-release-ros@v1
+ with:
+ ros_distro: humble
+ debian_distro: jammy
+ package_whitelist: '^myproject_.*'
+ artifact_name: bloom-myproject-packages
+```
+
+## How It Works
+
+1. Searches for all `package.xml` files in `packages_dir`
+2. Filters packages using whitelist/blacklist patterns
+3. Builds all packages together in a workspace using colcon (handles inter-package dependencies)
+4. For each package: runs bloom-generate and builds .deb
+5. Collects all .deb files into output directory
+
+## Requirements
+
+- Must checkout repository with `actions/checkout@v4` first
+- Each package needs valid `package.xml`
+- Dependencies should be available via apt or rosdep
+
+## Troubleshooting
+
+**Bloom generation fails**: Ensure `package.xml` has all required fields (name, version, description, maintainer, license)
+
+**Build dependencies not found**: Ensure all dependencies are properly declared in `package.xml` and available via rosdep
+
+## License
+
+Apache 2.0 License - see [LICENSE](LICENSE)
diff --git a/action.yml b/action.yml
new file mode 100644
index 0000000..25db592
--- /dev/null
+++ b/action.yml
@@ -0,0 +1,85 @@
+name: 'ROS 2 Bloom Release'
+description: 'Build and package ROS 2 packages into Debian packages using bloom'
+author: 'WATonomous'
+
+branding:
+ icon: 'package'
+ color: 'blue'
+
+inputs:
+ ros_distro:
+ description: 'ROS 2 distribution (humble, jazzy, kilted, rolling)'
+ required: true
+ packages_dir:
+ description: 'Directory to search for ROS 2 packages'
+ required: false
+ default: '.'
+ package_whitelist:
+ description: 'Regex pattern to whitelist package names. Default: all packages'
+ required: false
+ default: '.*'
+ package_blacklist:
+ description: 'Regex pattern to blacklist package names. Default: none'
+ required: false
+ default: ''
+ debian_distro:
+ description: 'Debian/Ubuntu distribution (jammy, noble)'
+ required: true
+ artifact_name:
+ description: 'Custom artifact name. Default: bloom-debian-packages-{ros_distro}-{job}-{run_id}'
+ required: false
+ default: ''
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Setup ROS environment
+ uses: ros-tooling/setup-ros@v0.7
+ with:
+ required-ros-distributions: ${{ inputs.ros_distro }}
+
+ - name: Install bloom and build dependencies
+ shell: bash
+ run: |
+ echo "Installing bloom and build dependencies..."
+ sudo apt-get update
+ sudo apt-get install -y \
+ python3-bloom \
+ python3-colcon-common-extensions \
+ build-essential \
+ debhelper \
+ devscripts \
+ fakeroot \
+ dh-python
+
+ - name: Build Debian packages
+ id: build
+ shell: bash
+ env:
+ ROS_DISTRO: ${{ inputs.ros_distro }}
+ PACKAGES_DIR: ${{ inputs.packages_dir }}
+ PACKAGE_WHITELIST: ${{ inputs.package_whitelist }}
+ PACKAGE_BLACKLIST: ${{ inputs.package_blacklist }}
+ DEBIAN_DISTRO: ${{ inputs.debian_distro }}
+ run: |
+ ${{ github.action_path }}/scripts/build.sh
+
+ - name: Set artifact name
+ id: artifact-name
+ shell: bash
+ run: |
+ if [ -n "${{ inputs.artifact_name }}" ]; then
+ echo "name=${{ inputs.artifact_name }}" >> $GITHUB_OUTPUT
+ else
+ DISTRO="${{ inputs.ros_distro }}"
+ JOB="${{ github.job }}"
+ RUN="${{ github.run_id }}"
+ echo "name=bloom-debian-packages-${DISTRO}-${JOB}-${RUN}" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Upload Debian packages
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ steps.artifact-name.outputs.name }}
+ path: ./bloom-build/output/*.deb
+ if-no-files-found: error
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100755
index 0000000..e7f1c0f
--- /dev/null
+++ b/scripts/build.sh
@@ -0,0 +1,311 @@
+#!/bin/bash
+
+set -e # Exit on error
+
+# ============================================================================
+# Logging
+# ============================================================================
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m'
+
+log_info() {
+ echo -e "${GREEN}[INFO]${NC} $1"
+}
+
+log_warn() {
+ echo -e "${YELLOW}[WARN]${NC} $1"
+}
+
+log_error() {
+ echo -e "${RED}[ERROR]${NC} $1"
+}
+
+log_section() {
+ echo -e "\n${BLUE}========================================${NC}"
+ echo -e "${BLUE}$1${NC}"
+ echo -e "${BLUE}========================================${NC}\n"
+}
+
+# ============================================================================
+# Package Discovery
+# ============================================================================
+
+discover_packages() {
+ local search_dir="$1"
+ local whitelist="$2"
+ local blacklist="$3"
+
+ log_info "Discovering ROS packages in: $search_dir"
+
+ local package_xml_files
+ package_xml_files=$(find "$search_dir" -name "package.xml" -type f)
+
+ if [ -z "$package_xml_files" ]; then
+ log_error "No ROS packages found in $search_dir"
+ exit 1
+ fi
+
+ PACKAGE_PATHS=()
+
+ for package_xml in $package_xml_files; do
+ local package_dir
+ package_dir=$(dirname "$package_xml")
+
+ # Apply whitelist filter on directory path
+ if ! echo "$package_dir" | grep -qE "$whitelist"; then
+ log_info "Package at '$package_dir' excluded by whitelist"
+ continue
+ fi
+
+ # Apply blacklist filter on directory path
+ if [ -n "$blacklist" ] && echo "$package_dir" | grep -qE "$blacklist"; then
+ log_info "Package at '$package_dir' excluded by blacklist"
+ continue
+ fi
+
+ log_info "Found package at: $package_dir"
+ PACKAGE_PATHS+=("$package_dir")
+ done
+
+ if [ ${#PACKAGE_PATHS[@]} -eq 0 ]; then
+ log_error "No packages matched the whitelist/blacklist filters"
+ exit 1
+ fi
+}
+
+# ============================================================================
+# Workspace Build
+# ============================================================================
+
+build_workspace() {
+ log_section "Building workspace with all packages"
+
+ local workspace_src="$WORKSPACE/workspace/src"
+ mkdir -p "$workspace_src"
+
+ # Copy all packages into workspace
+ log_info "Copying packages into workspace..."
+ for source_dir in "${PACKAGE_PATHS[@]}"; do
+ local pkg_name
+ pkg_name=$(basename "$source_dir")
+ log_info " - $pkg_name"
+ cp -r "$source_dir" "$workspace_src/$pkg_name"
+ done
+
+ cd "$WORKSPACE/workspace"
+
+ # Install all dependencies
+ log_info "Installing workspace dependencies..."
+ rosdep install --from-paths src --ignore-src -y -r --rosdistro "$ROS_DISTRO" 2>&1 || {
+ log_warn "Some dependencies could not be installed, continuing..."
+ }
+
+ # Build workspace with colcon (ROS2)
+ log_info "Building workspace with colcon..."
+ # shellcheck disable=SC1090
+ source /opt/ros/"$ROS_DISTRO"/setup.bash
+ if ! colcon build --symlink-install 2>&1; then
+ log_error "Workspace build failed"
+ return 1
+ fi
+ # shellcheck disable=SC1091
+ source install/setup.bash
+
+ log_info "Workspace built successfully"
+ return 0
+}
+
+# ============================================================================
+# Single Package Bloom
+# ============================================================================
+
+bloom_package() {
+ local source_dir="$1"
+ local index="$2"
+ local total="$3"
+
+ log_section "Generating debian for package $index/$total"
+
+ local pkg_name
+ pkg_name=$(basename "$source_dir")
+ log_info "Package: $pkg_name"
+
+ # Create bloom workspace for this package
+ local bloom_dir="$WORKSPACE/bloom/$pkg_name"
+ mkdir -p "$bloom_dir"
+ cd "$bloom_dir"
+
+ # Initialize git repo with package source
+ git init -q
+ cp -r "$source_dir"/* .
+
+ # Generate debian files
+ log_info "Generating debian files with bloom..."
+ if ! bloom-generate rosdebian \
+ --os-name ubuntu \
+ --os-version "$DEBIAN_DISTRO" \
+ --ros-distro "$ROS_DISTRO" 2>&1; then
+ log_error "Bloom generation failed"
+ return 1
+ fi
+
+ # Build debian package
+ log_info "Building debian package..."
+ if [ ! -d "debian" ]; then
+ log_error "Debian directory not found"
+ return 1
+ fi
+
+ if ! fakeroot debian/rules binary 2>&1; then
+ log_error "Debian build failed"
+ return 1
+ fi
+
+ # Collect .deb files
+ local deb_files
+ deb_files=$(find "$WORKSPACE/bloom" -maxdepth 2 -name "*.deb" -type f)
+
+ if [ -z "$deb_files" ]; then
+ log_error "No debian packages were generated"
+ return 1
+ fi
+
+ log_info "Collecting debian packages..."
+ for deb in $deb_files; do
+ cp "$deb" "$OUTPUT_DIR/"
+ log_info "Generated: $(basename "$deb")"
+ done
+
+ log_info "Successfully generated debian for $pkg_name"
+ return 0
+}
+
+# ============================================================================
+# Main
+# ============================================================================
+
+main() {
+ # Validate environment
+ if [ -z "$ROS_DISTRO" ] || [ -z "$DEBIAN_DISTRO" ]; then
+ log_error "Missing required environment variables"
+ log_error "Required: ROS_DISTRO, DEBIAN_DISTRO"
+ exit 1
+ fi
+
+ # Set defaults
+ PACKAGES_DIR="${PACKAGES_DIR:-.}"
+ PACKAGE_WHITELIST="${PACKAGE_WHITELIST:-.*}"
+ PACKAGE_BLACKLIST="${PACKAGE_BLACKLIST:-}"
+ WORKING_DIR="./bloom-build"
+
+ log_section "ROS Bloom Release - Multi-Package Build"
+ log_info "ROS Distro: $ROS_DISTRO"
+ log_info "Debian Distro: $DEBIAN_DISTRO"
+ log_info "Packages Directory: $PACKAGES_DIR"
+ log_info "Whitelist Pattern: $PACKAGE_WHITELIST"
+ log_info "Blacklist Pattern: $PACKAGE_BLACKLIST"
+
+ # Setup paths
+ ORIGINAL_DIR="$(pwd)"
+ WORKSPACE="$ORIGINAL_DIR/$WORKING_DIR"
+ OUTPUT_DIR="$WORKSPACE/output"
+ mkdir -p "$WORKSPACE" "$OUTPUT_DIR"
+
+ log_info "Working directory: $WORKSPACE"
+
+ # Resolve search directory
+ if [[ "$PACKAGES_DIR" = /* ]]; then
+ SEARCH_DIR="$PACKAGES_DIR"
+ else
+ SEARCH_DIR="$ORIGINAL_DIR/$PACKAGES_DIR"
+ fi
+
+ if [ ! -d "$SEARCH_DIR" ]; then
+ log_error "Package search directory not found: $SEARCH_DIR"
+ exit 1
+ fi
+
+ # Discover packages
+ discover_packages "$SEARCH_DIR" "$PACKAGE_WHITELIST" "$PACKAGE_BLACKLIST"
+
+ log_section "Processing ${#PACKAGE_PATHS[@]} package(s)"
+
+ # Setup git for bloom (only used for scripting, does not appear in debian)
+ git config --global user.name "Bloom Release Bot"
+ git config --global user.email "bloom@github-actions"
+
+ # Initialize rosdep
+ log_info "Initializing rosdep..."
+ sudo rosdep init 2>&1 || log_warn "rosdep already initialized"
+
+ log_info "Updating rosdep..."
+ if ! rosdep update 2>&1; then
+ log_error "rosdep update failed"
+ exit 1
+ fi
+
+ log_info "Verifying rosdep sources..."
+ if [ ! -f "/etc/ros/rosdep/sources.list.d/20-default.list" ]; then
+ log_error "rosdep sources not found after initialization"
+ exit 1
+ fi
+
+ # Build workspace with all packages together
+ if ! build_workspace; then
+ log_error "Workspace build failed"
+ exit 1
+ fi
+
+ # Source the built workspace for bloom to use
+ log_info "Sourcing built workspace..."
+ # shellcheck disable=SC1091
+ source "$WORKSPACE/workspace/install/setup.bash"
+
+ # Generate debian packages for each package
+ local bloom_success=0
+ local bloom_failed=0
+
+ for i in "${!PACKAGE_PATHS[@]}"; do
+ local source_dir="${PACKAGE_PATHS[$i]}"
+
+ if bloom_package "$source_dir" "$((i+1))" "${#PACKAGE_PATHS[@]}"; then
+ bloom_success=$((bloom_success + 1))
+ else
+ bloom_failed=$((bloom_failed + 1))
+ fi
+ done
+
+ # Summary
+ log_section "Build Summary"
+ log_info "Total packages: ${#PACKAGE_PATHS[@]}"
+ log_info "Successful: $bloom_success"
+ log_info "Failed: $bloom_failed"
+
+ # Check for output
+ local all_deb_files
+ all_deb_files=$(find "$OUTPUT_DIR" -name "*.deb" -type f)
+
+ if [ -z "$all_deb_files" ]; then
+ log_error "No debian packages were generated!"
+ exit 1
+ fi
+
+ log_section "Generated Debian Packages"
+ while IFS= read -r deb; do
+ log_info " - $(basename "$deb")"
+ done < <(find "$OUTPUT_DIR" -name "*.deb" -type f)
+
+ if [ $bloom_failed -gt 0 ]; then
+ log_warn "Some packages failed to build"
+ exit 1
+ fi
+
+ log_info "All builds completed successfully!"
+}
+
+# Run main
+main
diff --git a/test/package_a/CMakeLists.txt b/test/package_a/CMakeLists.txt
new file mode 100644
index 0000000..9274483
--- /dev/null
+++ b/test/package_a/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.8)
+project(package_a)
+
+find_package(ament_cmake REQUIRED)
+
+ament_package()
diff --git a/test/package_a/package.xml b/test/package_a/package.xml
new file mode 100644
index 0000000..c1afda7
--- /dev/null
+++ b/test/package_a/package.xml
@@ -0,0 +1,14 @@
+
+
+ package_a
+ 1.0.0
+ Test package A
+ Test User
+ MIT
+
+ ament_cmake
+
+
+ ament_cmake
+
+
diff --git a/test/package_b/CMakeLists.txt b/test/package_b/CMakeLists.txt
new file mode 100644
index 0000000..673231b
--- /dev/null
+++ b/test/package_b/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.8)
+project(package_b)
+
+find_package(ament_cmake REQUIRED)
+
+ament_package()
diff --git a/test/package_b/package.xml b/test/package_b/package.xml
new file mode 100644
index 0000000..fe69ff5
--- /dev/null
+++ b/test/package_b/package.xml
@@ -0,0 +1,14 @@
+
+
+ package_b
+ 2.0.0
+ Test package B
+ Test User
+ Apache-2.0
+
+ ament_cmake
+
+
+ ament_cmake
+
+
diff --git a/test/package_c/CMakeLists.txt b/test/package_c/CMakeLists.txt
new file mode 100644
index 0000000..d605f88
--- /dev/null
+++ b/test/package_c/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.8)
+project(package_c)
+
+find_package(ament_cmake REQUIRED)
+
+ament_package()
diff --git a/test/package_c/package.xml b/test/package_c/package.xml
new file mode 100644
index 0000000..8847c7c
--- /dev/null
+++ b/test/package_c/package.xml
@@ -0,0 +1,14 @@
+
+
+ package_c
+ 3.0.0
+ Test package C
+ Test User
+ MIT
+
+ ament_cmake
+
+
+ ament_cmake
+
+
diff --git a/test/package_d/CMakeLists.txt b/test/package_d/CMakeLists.txt
new file mode 100644
index 0000000..5143c68
--- /dev/null
+++ b/test/package_d/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.8)
+project(package_d)
+
+find_package(ament_cmake REQUIRED)
+
+ament_package()
diff --git a/test/package_d/package.xml b/test/package_d/package.xml
new file mode 100644
index 0000000..a26a88f
--- /dev/null
+++ b/test/package_d/package.xml
@@ -0,0 +1,14 @@
+
+
+ package_d
+ 4.0.0
+ Test package D
+ Test User
+ BSD
+
+ ament_cmake
+
+
+ ament_cmake
+
+
diff --git a/test/package_test/CMakeLists.txt b/test/package_test/CMakeLists.txt
new file mode 100644
index 0000000..d7fa62d
--- /dev/null
+++ b/test/package_test/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.8)
+project(package_test)
+
+find_package(ament_cmake REQUIRED)
+
+ament_package()
diff --git a/test/package_test/package.xml b/test/package_test/package.xml
new file mode 100644
index 0000000..f5115f7
--- /dev/null
+++ b/test/package_test/package.xml
@@ -0,0 +1,14 @@
+
+
+ package_test
+ 0.1.0
+ Test package for blacklist testing
+ Test User
+ MIT
+
+ ament_cmake
+
+
+ ament_cmake
+
+