1+ name : Generate Debian Packages
2+
3+ on :
4+ pull_request :
5+ branches : [ main ]
6+ types : [ opened, synchronize, reopened, ready_for_review ]
7+ workflow_dispatch : # Manual trigger
8+ inputs :
9+ ros_distros :
10+ description : ' ROS distributions to build (comma-separated: humble,iron,jazzy,kilted,rolling)'
11+ required : false
12+ default : ' humble,jazzy'
13+ schedule :
14+ - cron : ' 0 2 * * *' # Nightly at 2 AM UTC
15+
16+ env :
17+ ROS_LOCALHOST_ONLY : 1
18+ ROS_AUTOMATIC_DISCOVERY_RANGE : LOCALHOST
19+
20+ jobs :
21+ # Only run if tests pass
22+ check-tests :
23+ if : github.event_name == 'pull_request'
24+ runs-on : ubuntu-latest
25+ steps :
26+ - name : Wait for tests
27+ 28+ with :
29+ ref : ${{ github.event.pull_request.head.sha }}
30+ check-name : ' Test ROS2 humble'
31+ repo-token : ${{ secrets.GITHUB_TOKEN }}
32+ wait-interval : 30
33+
34+ determine-distros :
35+ runs-on : ubuntu-latest
36+ outputs :
37+ distros : ${{ steps.set-distros.outputs.distros }}
38+ steps :
39+ - name : Determine ROS distributions to build
40+ id : set-distros
41+ run : |
42+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
43+ # Manual trigger - use input or default
44+ DISTROS="${{ github.event.inputs.ros_distros || 'humble,jazzy' }}"
45+ elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
46+ # PR - build key distributions
47+ DISTROS="humble,jazzy"
48+ else
49+ # Scheduled - build all distributions
50+ DISTROS="humble,iron,jazzy,kilted,rolling"
51+ fi
52+ echo "Building for distributions: $DISTROS"
53+ # Convert to JSON array for matrix
54+ JSON_ARRAY=$(echo $DISTROS | jq -R 'split(",") | map(select(length > 0))')
55+ echo "distros=$JSON_ARRAY" >> $GITHUB_OUTPUT
56+
57+ generate-debian :
58+ name : Generate Debian packages for ROS2 ${{ matrix.ros_distro }}
59+ runs-on : ubuntu-latest
60+ needs : [determine-distros]
61+ if : always() && (needs.check-tests.result == 'success' || needs.check-tests.result == 'skipped')
62+ container : ros:${{ matrix.ros_distro }}-ros-base-${{ matrix.ubuntu_distro }}
63+
64+ strategy :
65+ fail-fast : false
66+ matrix :
67+ ros_distro : ${{ fromJson(needs.determine-distros.outputs.distros) }}
68+ include :
69+ - ros_distro : humble
70+ ubuntu_distro : jammy
71+ - ros_distro : iron
72+ ubuntu_distro : jammy
73+ - ros_distro : jazzy
74+ ubuntu_distro : noble
75+ - ros_distro : kilted
76+ ubuntu_distro : noble
77+ - ros_distro : rolling
78+ ubuntu_distro : noble
79+
80+ steps :
81+ - name : Checkout code
82+ uses : actions/checkout@v4
83+ with :
84+ submodules : recursive
85+
86+ - name : Setup build environment
87+ run : |
88+ source /opt/ros/${{ matrix.ros_distro }}/setup.bash
89+ apt-get update -qq && apt-get install -y build-essential python3-pip python3-bloom python3-rosdep git lsb-release devscripts debhelper fakeroot
90+
91+ - name : Install Python dependencies
92+ run : |
93+ if [[ "${{ matrix.ros_distro }}" == "jazzy" || \
94+ "${{ matrix.ros_distro }}" == "kilted" || \
95+ "${{ matrix.ros_distro }}" == "rolling" ]]; then
96+ pip3 install --break-system-packages -I pygments -r requirements.txt
97+ python3 -m pip install -U --break-system-packages bloom
98+ else
99+ pip3 install -r requirements.txt
100+ python3 -m pip install -U bloom
101+ fi
102+
103+ - name : Build workspace
104+ run : |
105+ source /opt/ros/${{ matrix.ros_distro }}/setup.bash
106+ colcon build --packages-up-to r2s_gw
107+ source install/setup.bash
108+
109+ - name : Setup rosdep mappings
110+ run : |
111+ echo "Adding local rosdep mappings..."
112+ mkdir -p /root/.ros/rosdep
113+ cat >/root/.ros/rosdep/local.yaml <<EOF
114+ greenwave_monitor_interfaces:
115+ ubuntu:
116+ jammy: [ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces]
117+ noble: [ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces]
118+ greenwave_monitor:
119+ ubuntu:
120+ jammy: [ros-${{ matrix.ros_distro }}-greenwave-monitor]
121+ noble: [ros-${{ matrix.ros_distro }}-greenwave-monitor]
122+ EOF
123+ mkdir -p /etc/ros/rosdep/sources.list.d
124+ echo "yaml file:///root/.ros/rosdep/local.yaml" > /etc/ros/rosdep/sources.list.d/99-local.list
125+ rosdep init || true
126+ rosdep update --include-eol-distros
127+
128+ - name : Generate Debian packages
129+ run : |
130+ set -eo pipefail
131+ mkdir -p debian_packages/${{ matrix.ros_distro }}
132+
133+ # Generate debian packages for greenwave_monitor_interfaces
134+ echo "Generating debian for greenwave_monitor_interfaces..."
135+ cd greenwave_monitor_interfaces
136+ bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary
137+ cp ../ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces_*.deb ../debian_packages/${{ matrix.ros_distro }}/
138+ cd ..
139+
140+ # Install interfaces package
141+ echo "Installing greenwave_monitor_interfaces..."
142+ apt-get update && apt-get install -y ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor-interfaces_*.deb
143+
144+ # Generate debian packages for greenwave_monitor
145+ echo "Generating debian for greenwave_monitor..."
146+ cd greenwave_monitor
147+ bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary
148+ cp ../ros-${{ matrix.ros_distro }}-greenwave-monitor_*.deb ../debian_packages/${{ matrix.ros_distro }}/
149+ cd ..
150+ apt-get update && apt-get install -y ./debian_packages/${{ matrix.ros_distro }}/ros-${{ matrix.ros_distro }}-greenwave-monitor*.deb
151+
152+ # Generate debian packages for r2s_gw
153+ echo "Generating debian for r2s_gw..."
154+ cd r2s_gw
155+ bloom-generate rosdebian --ros-distro ${{ matrix.ros_distro }} && apt-get build-dep . -y && fakeroot debian/rules binary
156+ cp ../ros-${{ matrix.ros_distro }}-r2s-gw_*.deb ../debian_packages/${{ matrix.ros_distro }}/
157+ cd ..
158+
159+ echo "Generated debian packages:"
160+ ls -la debian_packages/${{ matrix.ros_distro }}/
161+
162+ - name : Upload Debian packages
163+ uses : actions/upload-artifact@v4
164+ with :
165+ name : debian-packages-${{ matrix.ros_distro }}
166+ path : debian_packages/${{ matrix.ros_distro }}/
167+ retention-days : 30
0 commit comments