Fix CI release race: use gh CLI + || true for idempotent creates #26
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: Build & Release Debian Packages | |
| on: | |
| push: | |
| tags: ['*'] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-deb: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - ros_distro: humble | |
| os_codename: jammy | |
| container: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest | |
| runner: ubuntu-22.04 | |
| - ros_distro: jazzy | |
| os_codename: noble | |
| container: rostooling/setup-ros-docker:ubuntu-noble-ros-jazzy-ros-base-latest | |
| runner: ubuntu-24.04 | |
| - ros_distro: kilted | |
| os_codename: noble | |
| container: rostooling/setup-ros-docker:ubuntu-noble-ros-kilted-ros-base-latest | |
| runner: ubuntu-24.04 | |
| runs-on: ${{ matrix.runner }} | |
| container: | |
| image: ${{ matrix.container }} | |
| env: | |
| HOME: /root | |
| ROS_HOME: /root/.ros | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| path: src/pj_bridge | |
| - name: Install build tools | |
| run: | | |
| apt-get update | |
| apt-get install -y python3-bloom fakeroot debhelper dh-python | |
| - name: Install IXWebSocket from source | |
| run: | | |
| cd /tmp | |
| wget -q https://github.com/machinezone/IXWebSocket/archive/refs/tags/v11.4.6.tar.gz | |
| tar xzf v11.4.6.tar.gz | |
| cd IXWebSocket-11.4.6 | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release -DUSE_TLS=OFF -DUSE_ZLIB=ON | |
| cmake --build build -j$(nproc) | |
| cmake --install build | |
| - name: Install ROS dependencies | |
| shell: bash | |
| run: | | |
| source /opt/ros/${{ matrix.ros_distro }}/setup.bash | |
| rosdep update --rosdistro ${{ matrix.ros_distro }} | |
| rosdep install --from-paths src/pj_bridge --ignore-src -y --rosdistro ${{ matrix.ros_distro }} | |
| - name: Clean previous builds | |
| shell: bash | |
| run: | | |
| cd src/pj_bridge | |
| rm -rf debian .obj-x86_64-linux-gnu | |
| - name: Generate debian packaging | |
| shell: bash | |
| run: | | |
| source /opt/ros/${{ matrix.ros_distro }}/setup.bash | |
| cd src/pj_bridge | |
| bloom-generate rosdebian \ | |
| --os-name ubuntu \ | |
| --os-version ${{ matrix.os_codename }} \ | |
| --ros-distro ${{ matrix.ros_distro }} | |
| - name: Build debian package | |
| shell: bash | |
| run: | | |
| source /opt/ros/${{ matrix.ros_distro }}/setup.bash | |
| cd src/pj_bridge | |
| fakeroot debian/rules binary | |
| - name: Upload deb artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: deb-${{ matrix.ros_distro }} | |
| path: src/ros-${{ matrix.ros_distro }}-*.deb | |
| release: | |
| needs: build-deb | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all deb artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: debs | |
| pattern: deb-* | |
| merge-multiple: true | |
| - name: Upload to GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} | |
| run: | | |
| tag="${{ github.ref_name }}" | |
| # Create release if it doesn't exist yet | |
| gh release view "$tag" >/dev/null 2>&1 || \ | |
| gh release create "$tag" --title "$tag" --generate-notes || true | |
| # Upload assets (--clobber overwrites if re-run) | |
| gh release upload "$tag" debs/*.deb --clobber |