Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deb builder for ArduPilot version #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This workflow will build deb binary

name: Build deb binary

on:
release:
types: [published]

workflow_dispatch:

jobs:
get-ref-name:
runs-on: ubuntu-latest
outputs:
ref_name: ${{ steps.get-ref-name.outputs.ref_name }}
steps:
- name: Get ref_name
id: get-ref-name
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
sanitized_ref=$(echo ${{ github.head_ref }} | sed 's/[^a-zA-Z0-9.]/-/g')
else
sanitized_ref=$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9.]/-/g')
fi
echo "ref_name=$sanitized_ref"
echo "ref_name=$sanitized_ref" >> $GITHUB_OUTPUT || exit 1
build:
needs: get-ref-name
name: Build deb
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v3
- uses: actions/checkout@v4

v3 is EOL soon I think

with:
path: src/microxrceddsgen
submodules: recursive

- uses: ./src/microxrceddsgen/.github/actions/install-apt-packages

- name: Get minimum supported version of CMake
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need cmake to build it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied the current ci rules, I think it is used for the test as it download dds clients

uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.16.3
- name: Use cmake
run: cmake --version

- name: Build microxrceddsgen
run: |
cd src/microxrceddsgen
./gradlew assemble

- name: Test microxrceddsgen
run: |
cd src/microxrceddsgen
./gradlew test -Dbranch=v2.3.0

- name : Build deb
run: |
cd src/microxrceddsgen
rm -rf .github
./build-ap-microxrceddsgen-deb.sh ${{ needs.get-ref-name.outputs.ref_name }}

- name: "Publish to GitHub"
uses: softprops/action-gh-release@v2
with:
files: src/microxrceddsgen/ap_microxrceddsgen_*.deb
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ gradle-app.setting

# VSC
.devcontainer

# deb
*.deb
12 changes: 12 additions & 0 deletions ap-microxrceddsgen/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Package: ap-microxrceddsgen
Version: 0.0.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally,this matches the version of the tool. Currently, it's not set, but official releases will have a version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, we can update this one, when you use the build script it update the Version to the right one's

Priority: optional
Architecture: all
Section: misc
Depends: default-jre | openjdk-11-jre
Maintainer: ArduPilot <[email protected]>
Description: eProsima Fast DDS Gen ArduPilot patched
eProsima Fast DDS Gen with ArduPilot Patch
Homepage: https://github.com/ArduPilot/Micro-XRCE-DDS-Gen
Conflicts: ap-microxrceddsgen
Provides: ap-microxrceddsgen
Empty file.
9 changes: 9 additions & 0 deletions ap-microxrceddsgen/usr/share/doc/ap-microxrceddsgen/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

Files: *
Copyright: 2022, Proyectos y Sistemas de Mantenimiento SL (eProsima) <[email protected]>
License: Apache-2.0

License: Apache-2.0
On Debian systems, the full text of the Apache-2.0 license
can be found in the file '/usr/share/common-licenses/Apache-2.0'
32 changes: 32 additions & 0 deletions build-ap-microxrceddsgen-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

if [ -z "$1" ]; then
echo "Usage: $0 <version>"
exit 1
fi

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -euf -o pipefail

Catch errors earlier with this protection in shell.

VERSION="$1"

echo "Updating control file with version $VERSION"
sed -i "s/^Version: .*/Version: $VERSION/" ap-microxrceddsgen/DEBIAN/control

echo "Copying launcher"
cp scripts/microxrceddsgen ap-microxrceddsgen/opt/ardupilot/Micro-XRCE-DDS-Gen/bin/microxrceddsgen

echo "Setting permissions for the launcher"
chmod 755 ap-microxrceddsgen/opt/ardupilot/Micro-XRCE-DDS-Gen/bin/microxrceddsgen

echo "Copying jar"
cp share/microxrceddsgen/java/microxrceddsgen.jar ap-microxrceddsgen/opt/ardupilot/Micro-XRCE-DDS-Gen/share/microxrceddsgen/java

echo "Setting permissions for the jar"
chmod 644 ap-microxrceddsgen/opt/ardupilot/Micro-XRCE-DDS-Gen/share/microxrceddsgen/java/microxrceddsgen.jar

echo "Generating .deb"
dpkg-deb --root-owner-group --build ap-microxrceddsgen "ap_microxrceddsgen_${VERSION}_all.deb"

echo "Package information:"
dpkg-deb --info "ap_microxrceddsgen_${VERSION}_all.deb"

echo "Package contents:"
dpkg-deb --contents "ap_microxrceddsgen_${VERSION}_all.deb"
Loading