Generate Debian Packages #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate Debian Packages | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| types: [ opened, synchronize, reopened, ready_for_review ] | |
| workflow_dispatch: # Manual trigger | |
| inputs: | |
| ros_distros: | |
| description: 'ROS distributions to build (comma-separated: humble,iron,jazzy,kilted,rolling)' | |
| required: false | |
| default: 'humble,jazzy' | |
| schedule: | |
| - cron: '0 2 * * *' # Nightly at 2 AM UTC | |
| env: | |
| ROS_LOCALHOST_ONLY: 1 | |
| ROS_AUTOMATIC_DISCOVERY_RANGE: LOCALHOST | |
| jobs: | |
| # Only run if tests pass | |
| check-tests: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Wait for tests | |
| uses: lewagon/[email protected] | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| check-name: 'Test ROS2 humble' | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| wait-interval: 30 | |
| determine-distros: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| distros: ${{ steps.set-distros.outputs.distros }} | |
| steps: | |
| - name: Determine ROS distributions to build | |
| id: set-distros | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| # Manual trigger - use input or default | |
| DISTROS="${{ github.event.inputs.ros_distros || 'humble,jazzy' }}" | |
| elif [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| # PR - build key distributions | |
| DISTROS="humble,jazzy" | |
| else | |
| # Scheduled - build all distributions | |
| DISTROS="humble,iron,jazzy,kilted,rolling" | |
| fi | |
| echo "Building for distributions: $DISTROS" | |
| # Convert to JSON array for matrix | |
| JSON_ARRAY=$(echo $DISTROS | jq -R 'split(",") | map(select(length > 0))') | |
| echo "distros=$JSON_ARRAY" >> $GITHUB_OUTPUT | |
| generate-debian: | |
| name: Generate Debian packages for ROS2 ${{ matrix.ros_distro }} | |
| runs-on: ubuntu-latest | |
| needs: [determine-distros] | |
| if: always() && (needs.check-tests.result == 'success' || needs.check-tests.result == 'skipped') | |
| container: ros:${{ matrix.ros_distro }}-ros-base-${{ matrix.ubuntu_distro }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ros_distro: ${{ fromJson(needs.determine-distros.outputs.distros) }} | |
| include: | |
| - ros_distro: humble | |
| ubuntu_distro: jammy | |
| - ros_distro: iron | |
| ubuntu_distro: jammy | |
| - ros_distro: jazzy | |
| ubuntu_distro: noble | |
| - ros_distro: kilted | |
| ubuntu_distro: noble | |
| - ros_distro: rolling | |
| ubuntu_distro: noble | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup build environment | |
| run: | | |
| source /opt/ros/${{ matrix.ros_distro }}/setup.bash | |
| apt-get update -qq && apt-get install -y build-essential python3-pip python3-bloom python3-rosdep git lsb-release devscripts debhelper fakeroot | |
| - name: Install Python dependencies | |
| run: | | |
| if [[ "${{ matrix.ros_distro }}" == "jazzy" || \ | |
| "${{ matrix.ros_distro }}" == "kilted" || \ | |
| "${{ matrix.ros_distro }}" == "rolling" ]]; then | |
| pip3 install --break-system-packages -I pygments -r requirements.txt | |
| python3 -m pip install -U --break-system-packages bloom | |
| else | |
| pip3 install -r requirements.txt | |
| python3 -m pip install -U bloom | |
| fi | |
| - name: Build workspace | |
| run: | | |
| source /opt/ros/${{ matrix.ros_distro }}/setup.bash | |
| colcon build --packages-up-to r2s_gw | |
| source install/setup.bash | |
| - name: Setup rosdep mappings | |
| run: | | |
| echo "Adding local rosdep mappings..." | |
| mkdir -p /root/.ros/rosdep | |
| cat >/root/.ros/rosdep/local.yaml <<EOF | |
| greenwave_monitor_interfaces: | |
| ubuntu: | |
| jammy: [ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces] | |
| noble: [ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces] | |
| greenwave_monitor: | |
| ubuntu: | |
| jammy: [ros-${{ matrix.ros_distro }}-greenwave-monitor] | |
| noble: [ros-${{ matrix.ros_distro }}-greenwave-monitor] | |
| EOF | |
| mkdir -p /etc/ros/rosdep/sources.list.d | |
| echo "yaml file:///root/.ros/rosdep/local.yaml" > /etc/ros/rosdep/sources.list.d/99-local.list | |
| rosdep init || true | |
| rosdep update --include-eol-distros | |
| - name: Generate Debian packages | |
| run: | | |
| set -eo pipefail | |
| mkdir -p debian_packages/${{ matrix.ros_distro }} | |
| # Generate debian packages for greenwave_monitor_interfaces | |
| echo "Generating debian for greenwave_monitor_interfaces..." | |
| cd greenwave_monitor_interfaces | |
| bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary | |
| cp ../ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces_*.deb ../debian_packages/${{ matrix.ros_distro }}/ | |
| cd .. | |
| # Install interfaces package | |
| echo "Installing greenwave_monitor_interfaces..." | |
| apt-get update && apt-get install -y ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces_*.deb | |
| # Generate debian packages for greenwave_monitor | |
| echo "Generating debian for greenwave_monitor..." | |
| cd greenwave_monitor | |
| bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary | |
| cp ../ros-${{ matrix.ros_distro }}-greenwave-monitor_*.deb ../debian_packages/${{ matrix.ros_distro }}/ | |
| cd .. | |
| apt-get update && apt-get install -y ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor*.deb | |
| # Generate debian packages for r2s_gw | |
| echo "Generating debian for r2s_gw..." | |
| cd r2s_gw | |
| bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary | |
| cp ../ros-${{ matrix.ros_distro }}-r2s-gw_*.deb ../debian_packages/${{ matrix.ros_distro }}/ | |
| cd .. | |
| echo "Generated debian packages:" | |
| ls -la debian_packages/${{ matrix.ros_distro }}/ | |
| - name: Upload Debian packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: debian-packages-${{ matrix.ros_distro }} | |
| path: debian_packages/${{ matrix.ros_distro }}/ | |
| retention-days: 30 |