Skip to content

build deb

build deb #133

Workflow file for this run

name: build deb
on:
workflow_dispatch:
release:
types: [ published ]
jobs:
build-deb-package:
strategy:
fail-fast: false
matrix:
include:
- ros_distribution: noetic
arch: amd64
distro: focal
label: ubuntu-latest
- ros_distribution: noetic
arch: arm64
distro: focal
label: [ linux-arm-64-8c-32g-300gb ]
- ros_distribution: melodic
arch: amd64
distro: bionic
label: ubuntu-latest
- ros_distribution: melodic
arch: arm64
distro: bionic
label: [ linux-arm-64-8c-32g-300gb ]
- ros_distribution: foxy
arch: amd64
distro: focal
label: ubuntu-latest
- ros_distribution: foxy
arch: arm64
distro: focal
label: [ linux-arm-64-8c-32g-300gb ]
- ros_distribution: humble
arch: amd64
distro: jammy
label: ubuntu-latest
- ros_distribution: humble
arch: arm64
distro: jammy
label: [ linux-arm-64-8c-32g-300gb ]
- ros_distribution: jazzy
arch: amd64
distro: noble
label: ubuntu-latest
- ros_distribution: jazzy
arch: arm64
distro: noble
label: [ linux-arm-64-8c-32g-300gb ]
- ros_distribution: indigo
arch: amd64
distro: trusty
label: ubuntu-latest
- ros_distribution: indigo
arch: armhf
distro: trusty
label: [ linux-arm-64-8c-32g-300gb ]
name: Build deb (ROS ${{ matrix.ros_distribution }} - ${{ matrix.arch }})
runs-on: ${{ matrix.label }}
container: cobridge/ros-${{ matrix.ros_distribution }}:latest
outputs:
matrix_result_noetic_amd64: ${{ steps.build_deb.outputs.matrix_result_noetic_amd64 }}
matrix_result_noetic_arm64: ${{ steps.build_deb.outputs.matrix_result_noetic_arm64 }}
matrix_result_melodic_amd64: ${{ steps.build_deb.outputs.matrix_result_melodic_amd64 }}
matrix_result_melodic_arm64: ${{ steps.build_deb.outputs.matrix_result_melodic_arm64 }}
matrix_result_foxy_amd64: ${{ steps.build_deb.outputs.matrix_result_foxy_amd64 }}
matrix_result_foxy_arm64: ${{ steps.build_deb.outputs.matrix_result_foxy_arm64 }}
matrix_result_humble_amd64: ${{ steps.build_deb.outputs.matrix_result_humble_amd64 }}
matrix_result_humble_arm64: ${{ steps.build_deb.outputs.matrix_result_humble_arm64 }}
matrix_result_jazzy_amd64: ${{ steps.build_deb.outputs.matrix_result_jazzy_amd64 }}
matrix_result_jazzy_arm64: ${{ steps.build_deb.outputs.matrix_result_jazzy_arm64 }}
matrix_result_indigo_amd64: ${{ steps.build_deb.outputs.matrix_result_indigo_amd64 }}
matrix_result_indigo_armhf: ${{ steps.build_deb.outputs.matrix_result_indigo_armhf }}
steps:
- name: Checkout code
if: matrix.ros_distribution != 'indigo' && matrix.ros_distribution != 'melodic'
uses: actions/checkout@v4
- name: Checkout code (indigo/melodic)
if: matrix.ros_distribution == 'indigo' || matrix.ros_distribution == 'melodic'
shell: bash
run: |
echo "current sha: ${{ github.sha}}, current ref: ${{ github.ref }}"
git config --global url."https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
git config --global --add safe.directory /__w/cobridge/cobridge
git clone https://github.com/${{ github.repository }}.git .
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "PR number: ${{ github.event.pull_request.number }}"
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch
git checkout pr-branch
else
git checkout ${{ github.sha }}
fi
- name: Apply patches
run: |
./patch_apply.sh
- name: Update package version
if: github.event_name == 'release'
run: |
VERSION=$(echo $GITHUB_REF | sed 's#refs/tags/v##')
echo "Version: $VERSION"
echo "GITHUB_REF: $GITHUB_REF"
sed -i "s#<version>.*</version>#<version>$VERSION</version>#" ./package.xml
- name: Generate debian/ directory and build .deb package
id: build_deb
run: |
rosdep update --rosdistro=${{ matrix.ros_distribution }} --include-eol-distros
bloom-generate rosdebian --ros-distro ${{ matrix.ros_distribution }}
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -us -uc -a${{ matrix.arch }}
mkdir -p $GITHUB_WORKSPACE/artifacts
cp ../*.deb $GITHUB_WORKSPACE/artifacts/
DEB_FILENAME=$(basename $(ls $GITHUB_WORKSPACE/artifacts/*.deb))
echo "DEB_FILENAME=$DEB_FILENAME" >> $GITHUB_ENV
if [ "${{ github.event_name }}" = "release" ]; then
URL_PREFIX="https://apt.coscene.cn"
else
URL_PREFIX="https://download.coscene.cn"
fi
download_url="${URL_PREFIX}/dists/${{ matrix.distro }}/main/binary-${{ matrix.arch }}/${DEB_FILENAME}"
matrix_key="${{ matrix.ros_distribution }}_${{ matrix.arch }}"
echo "matrix_result_${matrix_key}=${{ matrix.arch }},${{ matrix.ros_distribution }},${{ matrix.distro }},$download_url" >> $GITHUB_OUTPUT
echo "download url: $download_url"
- name: Update APT Source (AWS)
uses: coscene-io/update-apt-source@main
with:
ubuntu_distro: ${{ matrix.distro }}
deb_paths: ${{ github.workspace }}/artifacts/${{ env.DEB_FILENAME }}
architectures: ${{ matrix.platform }}
storage_type: aws
endpoint: https://s3.us-east-1.amazonaws.com
region: us-east-1
bucket_name: coscene-apt
access_key_id: ${{ secrets.S3_ARTIFACTS_ACCESS_KEY }}
access_key_secret: ${{ secrets.S3_ARTIFACTS_ACCESS_SECRET }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Update APT Source ( OSS )
if: github.event_name == 'release'
uses: coscene-io/update-apt-source@main
with:
ubuntu_distro: ${{ matrix.distro }}
deb_paths: ${{ github.workspace }}/artifacts/${{ env.DEB_FILENAME }}
architectures: ${{ matrix.arch }}
storage_type: oss
endpoint: https://oss-cn-hangzhou.aliyuncs.com
region: cn-hangzhou
bucket_name: coscene-apt
access_key_id: ${{ secrets.OSS_ARTIFACTS_ACCESS_KEY }}
access_key_secret: ${{ secrets.OSS_ARTIFACTS_ACCESS_SECRET }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Update APT Source ( OSS, TEST ONLY )
if: github.event_name != 'release'
uses: coscene-io/update-apt-source@main
with:
ubuntu_distro: ${{ matrix.distro }}
deb_paths: ${{ github.workspace }}/artifacts/${{ env.DEB_FILENAME }}
architectures: ${{ matrix.arch }}
storage_type: oss
endpoint: https://oss-cn-hangzhou.aliyuncs.com
region: cn-hangzhou
bucket_name: coscene-download
access_key_id: ${{ secrets.OSS_ARTIFACTS_ACCESS_KEY }}
access_key_secret: ${{ secrets.OSS_ARTIFACTS_ACCESS_SECRET }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
Download-list:
needs: build-deb-package
runs-on: ubuntu-latest
steps:
- name: Create workflow summary
run: |
echo "## All Download URLs" >> $GITHUB_STEP_SUMMARY
echo "| Platform | ROS Distro | Ubuntu Distro | URL |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY
URLS=""
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_melodic_amd64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_melodic_arm64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_noetic_amd64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_noetic_arm64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_foxy_amd64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_foxy_arm64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_humble_amd64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_humble_arm64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_jazzy_amd64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_jazzy_arm64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_indigo_amd64 }};"
URLS="${URLS}${{ needs.build-deb-package.outputs.matrix_result_indigo_armhf }};"
IFS=';' read -ra URL_ARRAY <<< "$URLS"
for url_item in "${URL_ARRAY[@]}"; do
if [ -n "$url_item" ]; then
IFS=',' read -ra ITEM <<< "$url_item"
echo "| ${ITEM[0]} | ${ITEM[1]} | ${ITEM[2]} | [${ITEM[3]}](${ITEM[3]}) |" >> $GITHUB_STEP_SUMMARY
fi
done