Skip to content

Commit 2663d27

Browse files
committed
Add github workflow
Create a new workflow + script that will build the app and deploy it for debian 13 Change files permissions Signed-off-by: Nicu Siderias <nicu.siderias@analog.com>
1 parent 166db99 commit 2663d27

File tree

3 files changed

+207
-0
lines changed

3 files changed

+207
-0
lines changed

.github/scripts/create_debian.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
version=$1
4+
architecture=$(dpkg --print-architecture)
5+
6+
source_code=$(basename "$PWD")
7+
8+
# Use sudo only if not running as root
9+
if [ "$(id -u)" -eq 0 ]; then
10+
apt-get update
11+
apt-get install -y build-essential cmake libiio-dev python3 python3-pip python3-setuptools dh-python devscripts debhelper
12+
else
13+
sudo apt-get update
14+
sudo apt-get install -y build-essential cmake libiio-dev python3 python3-pip python3-setuptools dh-python devscripts debhelper
15+
fi
16+
17+
# Replace placeholders inside the debian template files
18+
sed -i "s/@VERSION@/$version-1/" packaging/debian/changelog
19+
sed -i "s/@DATE@/$(date -R)/" packaging/debian/changelog
20+
sed -i "s/@ARCHITECTURE@/$architecture/" packaging/debian/control
21+
22+
cp -r packaging/debian .
23+
24+
rm -rf packaging
25+
26+
pushd ..
27+
tar czf ${source_code}_${version}.orig.tar.gz \
28+
--exclude='.git' \
29+
--exclude='debian' \
30+
$source_code
31+
popd
32+
33+
debuild

.github/workflows/build.yaml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Build and Deploy libad9361-iio
2+
3+
permissions:
4+
contents: read
5+
6+
env:
7+
APP_NAME: libad9361
8+
9+
on:
10+
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
14+
- '20[1-9][0-9]_R[1-9]'
15+
- staging/*
16+
tags:
17+
- 'v*'
18+
pull_request:
19+
branches:
20+
- main
21+
- '20[1-9][0-9]_R[1-9]'
22+
23+
jobs:
24+
identify_version:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
app-version: ${{ steps.set_version.outputs.version }}
28+
steps:
29+
- name: Checkout code repository
30+
uses: actions/checkout@v4
31+
- name: Set app version
32+
id: set_version
33+
run: |
34+
# Extract version from CMakeLists.txt project() line
35+
cmake_version=$(grep -oP 'project\s*\([^)]*VERSION\s+\K[0-9]+\.[0-9]+(\.[0-9]+)?' CMakeLists.txt)
36+
37+
if [[ -z "$cmake_version" ]]; then
38+
echo "Failed to extract version from CMakeLists.txt, using default"
39+
cmake_version="0.0.1+${{ github.sha }}"
40+
fi
41+
42+
echo "Version to use: $cmake_version"
43+
echo "version=$cmake_version" >> "$GITHUB_OUTPUT"
44+
45+
build_arm64_native:
46+
runs-on: ubuntu-24.04-arm
47+
needs: identify_version
48+
env:
49+
architecture: arm64
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
include:
54+
- docker_image: arm64v8/debian:trixie
55+
distro: debian13
56+
57+
steps:
58+
- name: Checkout code repository
59+
uses: actions/checkout@v4
60+
with:
61+
path: ${{env.APP_NAME}}
62+
63+
- name: Start persistent container
64+
run: |
65+
docker run -d \
66+
--name ${{matrix.distro}}-${{env.architecture}} \
67+
-v "$GITHUB_WORKSPACE/${{env.APP_NAME}}:/workspace/${{env.APP_NAME}}" \
68+
-w /workspace/${{env.APP_NAME}} \
69+
${{matrix.docker_image}} tail -f /dev/null
70+
71+
- name: Create debian package
72+
run: |
73+
docker exec ${{matrix.distro}}-${{env.architecture}} sh -c ".github/scripts/create_debian.sh ${{needs.identify_version.outputs.app-version}}"
74+
75+
- name: Copy debian artifacts from container to host
76+
run: |
77+
docker cp ${{matrix.distro}}-${{env.architecture}}:/workspace/. ./artifacts/
78+
ls -la ./artifacts/
79+
80+
- name: Upload debian artifacts to github
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: ${{env.APP_NAME}}-${{matrix.distro}}-${{env.architecture}}
84+
path: |
85+
artifacts/*.deb
86+
artifacts/*.dsc
87+
artifacts/*.debian.tar.xz
88+
artifacts/*.orig.tar.gz
89+
if-no-files-found: error
90+
91+
build_armhf_qemu:
92+
runs-on: ubuntu-latest
93+
needs: identify_version
94+
env:
95+
architecture: armhf
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
include:
100+
- docker_image: arm32v7/debian:trixie
101+
distro: debian13
102+
103+
steps:
104+
- name: Checkout code repository
105+
uses: actions/checkout@v4
106+
with:
107+
path: ${{env.APP_NAME}}
108+
109+
- name: Set up QEMU
110+
uses: docker/setup-qemu-action@v3
111+
112+
- name: Start persistent container
113+
run: |
114+
docker run -d \
115+
--platform linux/arm/v7 \
116+
--name ${{matrix.distro}}-${{env.architecture}} \
117+
-v "$GITHUB_WORKSPACE/${{env.APP_NAME}}:/workspace/${{env.APP_NAME}}" \
118+
-w /workspace/${{env.APP_NAME}} \
119+
${{matrix.docker_image}} tail -f /dev/null
120+
121+
- name: Create debian package
122+
run: |
123+
docker exec ${{matrix.distro}}-${{env.architecture}} sh -c ".github/scripts/create_debian.sh ${{needs.identify_version.outputs.app-version}}"
124+
125+
- name: Copy debian artifacts from container to host
126+
run: |
127+
docker cp ${{matrix.distro}}-${{env.architecture}}:/workspace/. ./artifacts/
128+
ls -la ./artifacts/
129+
130+
- name: Upload debian artifacts to github
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: ${{env.APP_NAME}}-${{matrix.distro}}-${{env.architecture}}
134+
path: |
135+
artifacts/*.deb
136+
artifacts/*.dsc
137+
artifacts/*.debian.tar.xz
138+
artifacts/*.orig.tar.gz
139+
if-no-files-found: error
140+
141+
build_ubuntu:
142+
runs-on: ubuntu-latest
143+
needs: identify_version
144+
env:
145+
architecture: amd64
146+
defaults:
147+
run:
148+
working-directory: ${{env.APP_NAME}}
149+
steps:
150+
- name: Checkout code repository
151+
uses: actions/checkout@v4
152+
with:
153+
path: ${{env.APP_NAME}}
154+
155+
- name: Create .deb package
156+
run: |
157+
.github/scripts/create_debian.sh ${{needs.identify_version.outputs.app-version}}
158+
159+
- name: Copy debian artifacts
160+
run: |
161+
mkdir -p artifacts
162+
cp ../*.deb ../*.dsc ../*.debian.tar.xz ../*.orig.tar.gz artifacts/
163+
ls -la artifacts/
164+
165+
- name: Upload debian artifacts to github
166+
uses: actions/upload-artifact@v4
167+
with:
168+
name: ${{env.APP_NAME}}-ubuntu
169+
path: |
170+
${{env.APP_NAME}}/artifacts/*.deb
171+
${{env.APP_NAME}}/artifacts/*.dsc
172+
${{env.APP_NAME}}/artifacts/*.debian.tar.xz
173+
${{env.APP_NAME}}/artifacts/*.orig.tar.gz
174+
if-no-files-found: error

packaging/debian/rules

100644100755
File mode changed.

0 commit comments

Comments
 (0)