Skip to content

Commit b81c532

Browse files
committed
Create build workflow
Necessary files for creating the debian package were added. Makefile was updated to support the debian package creation Signed-off-by: Nicu Siderias <nicu.siderias@analog.com>
1 parent fc0ba06 commit b81c532

File tree

10 files changed

+283
-0
lines changed

10 files changed

+283
-0
lines changed

.github/scripts/create_debian.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
version=$1
4+
architecture=$2
5+
6+
source_code=$(basename "$PWD")
7+
8+
sudo apt update
9+
sudo apt install -y build-essential make devscripts debhelper pybuild-plugin-pyproject python3 python3-gi
10+
11+
#Replace placeholders inside the debian template files
12+
sed -i "s/@VERSION@/$version-1/" packaging/debian/changelog
13+
sed -i "s/@DATE@/$(date -R)/" packaging/debian/changelog
14+
sed -i "s/@ARCHITECTURE@/$architecture/" packaging/debian/control
15+
16+
cp -r packaging/debian .
17+
18+
pushd ..
19+
tar czf $source_code\_$version.orig.tar.gz $source_code
20+
popd
21+
22+
debuild

.github/scripts/verify_install.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
install_location="${1:-/usr}"
4+
5+
if [ ! -d "$install_location/share/adi_diagnostic_report/" ] || \
6+
[ ! -d "$install_location/share/applications" ]; then
7+
echo "Installation directories not found!"
8+
exit 1
9+
fi
10+
11+
if [ ! -f "$install_location/bin/adi_diagnostic_report" ] || \
12+
[ ! -f "$install_location/share/adi_diagnostic_report/adi_diagnostic_report.glade" ] || \
13+
[ ! -f "$install_location/share/applications/adi-diagnostic-report.desktop" ]; then
14+
echo "Installation files not found!"
15+
exit 1
16+
fi
17+
18+
echo "Diagnostic Report installed successfully."
19+

.github/workflows/build.yaml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: Build and Deploy Diagnostic Report
2+
3+
env:
4+
APP_NAME: diagnostic-report
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
- '20[1-9][0-9]_R[1-9]'
12+
- staging/*
13+
tags:
14+
- 'v*'
15+
pull_request:
16+
branches:
17+
- main
18+
- '20[1-9][0-9]_R[1-9]'
19+
20+
jobs:
21+
identify_version:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
app-version: ${{ steps.set_version.outputs.version }}
25+
can-create-release: ${{ steps.set_version.outputs.can_create_release}}
26+
steps:
27+
- name: Checkout code repository
28+
uses: actions/checkout@v4
29+
- name: Set app version
30+
id: set_version
31+
run: |
32+
# Regex to match semantic versioning (from semver.org)
33+
# Regex will match valid version number https://regex101.com/r/jPSdnV/1
34+
regex='^(v|)((0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?)$'
35+
app_version=""
36+
create_release=false
37+
latest_released_tag=$(curl "https://api.github.com/repos/${{github.repository}}/releases/latest" | jq -r .tag_name)
38+
39+
if [[ "${{github.ref_type}}" == "tag" ]]; then
40+
pushed_tag="${{github.ref_name}}"
41+
if [[ "$pushed_tag" =~ $regex ]]; then
42+
app_version="${BASH_REMATCH[2]}"
43+
if [[ "$latest_released_tag" =~ $regex ]]; then
44+
IFS='.' read -r major minor patch <<< "${BASH_REMATCH[2]}"
45+
next_patch="$major.$minor.$((patch + 1))"
46+
next_minor="$major.$((minor + 1)).0"
47+
next_major="$((major + 1)).0.0"
48+
if [[ "$app_version" == "$next_patch" || "$app_version" == "$next_minor" || "$app_version" == "$next_major" ]]; then
49+
create_release=true
50+
else
51+
echo "Valid tag, but invalid version incrementation, release will NOT be created"
52+
fi
53+
else
54+
echo "Invalid relesed version, skip incrementation validation! Release will be created"
55+
create_release=true
56+
fi
57+
else
58+
echo "Invalid tag format, release will NOT be created"
59+
app_version=0.0.1+${{ github.sha }}
60+
fi
61+
else
62+
if [[ "$latest_released_tag" =~ $regex ]]; then
63+
app_version=${BASH_REMATCH[2]}+${{ github.sha }}
64+
else
65+
echo "Invalid relesed version. Setting default version"
66+
app_version=0.0.1+${{ github.sha }}
67+
fi
68+
fi
69+
70+
echo "Version to use $app_version"
71+
echo "version=$app_version" >> "$GITHUB_OUTPUT"
72+
echo "can_create_release=$create_release" >> "$GITHUB_OUTPUT"
73+
build_and_deploy_for_kuiper:
74+
runs-on: ubuntu-latest
75+
needs: identify_version
76+
env:
77+
CONTAINER_BASE_NAME: kuiper-container-basic
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
include:
82+
- docker_image: aandrisa/kuiper_basic_64:latest
83+
image_arch: linux/arm64
84+
architecture: arm64
85+
- docker_image: aandrisa/kuiper_basic_32:latest
86+
image_arch: linux/arm/v7
87+
architecture: armhf
88+
steps:
89+
- name: Checkout code repository
90+
uses: actions/checkout@v4
91+
with:
92+
path: ${{env.APP_NAME}}
93+
94+
- name: Set up QEMU
95+
uses: docker/setup-qemu-action@v3
96+
97+
- name: Start persistent container
98+
run: |
99+
docker run -d \
100+
--platform ${{matrix.image_arch}} \
101+
--name ${{env.CONTAINER_BASE_NAME}}-${{matrix.architecture}} \
102+
-v "$GITHUB_WORKSPACE/${{env.APP_NAME}}:/workspace/${{env.APP_NAME}}" \
103+
-w /workspace/${{env.APP_NAME}} \
104+
${{matrix.docker_image}} tail -f /dev/null
105+
106+
- name: Create debian package
107+
run: |
108+
docker exec ${{env.CONTAINER_BASE_NAME}}-${{matrix.architecture}} sh -c ".github/scripts/create_debian.sh ${{needs.identify_version.outputs.app-version}} ${{matrix.architecture}}"
109+
110+
- name: Install application
111+
env:
112+
DEB_FILE_NAME: ${{env.APP_NAME}}_${{needs.identify_version.outputs.app-version}}-1_${{matrix.architecture}}
113+
run: |
114+
docker exec ${{env.CONTAINER_BASE_NAME}}-${{matrix.architecture}} sh -c "sudo dpkg -i ../${{env.DEB_FILE_NAME}}.deb"
115+
116+
- name: Verify install locations
117+
run: |
118+
docker exec ${{env.CONTAINER_BASE_NAME}}-${{matrix.architecture}} sh -c ".github/scripts/verify_install.sh"
119+
120+
- name: Copy .deb from container to host
121+
env:
122+
DEB_FILE_NAME: ${{env.APP_NAME}}_${{needs.identify_version.outputs.app-version}}-1_${{matrix.architecture}}
123+
run: |
124+
docker cp ${{env.CONTAINER_BASE_NAME}}-${{matrix.architecture}}:/workspace/${{env.DEB_FILE_NAME}}.deb ./${{env.DEB_FILE_NAME}}.deb
125+
126+
- name: Upload .deb artifacts to github
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: ${{env.APP_NAME}}-${{matrix.architecture}}
130+
path: ${{env.APP_NAME}}_${{needs.identify_version.outputs.app-version}}-1_${{matrix.architecture}}.deb
131+
if-no-files-found: error
132+
build_and_deploy_for_ubuntu:
133+
runs-on: ubuntu-latest
134+
needs: identify_version
135+
env:
136+
architecture: amd64
137+
defaults:
138+
run:
139+
working-directory: ${{env.APP_NAME}}
140+
steps:
141+
- name: Checkout code repository
142+
uses: actions/checkout@v4
143+
with:
144+
path: ${{env.APP_NAME}}
145+
146+
- name: Create .deb package
147+
run: |
148+
.github/scripts/create_debian.sh ${{needs.identify_version.outputs.app-version}} ${{env.architecture}}
149+
150+
- name: Install application
151+
env:
152+
DEB_FILE_NAME: ${{env.APP_NAME}}_${{needs.identify_version.outputs.app-version}}-1_${{env.architecture}}
153+
run: |
154+
sudo dpkg -i ../${{env.DEB_FILE_NAME}}.deb
155+
156+
- name: Verify install locations
157+
run: |
158+
.github/scripts/verify_install.sh
159+
160+
- name: Upload .deb artifacts to github
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: ${{env.APP_NAME}}-ubuntu
164+
path: ${{env.APP_NAME}}_${{needs.identify_version.outputs.app-version}}-1_${{env.architecture}}.deb
165+
if-no-files-found: error
166+
create_release_from_tag:
167+
needs:
168+
- build_and_deploy_for_kuiper
169+
- build_and_deploy_for_ubuntu
170+
- identify_version
171+
runs-on: ubuntu-latest
172+
if: ${{needs.identify_version.outputs.can-create-release == 'true'}}
173+
steps:
174+
- name: Download all artifacts
175+
uses: actions/download-artifact@v4
176+
with:
177+
merge-multiple: true
178+
- name: Release
179+
uses: ncipollo/release-action@v1
180+
with:
181+
token: ${{secrets.TOKEN_GITHUB}}
182+
name: Release ${{github.ref_name}}
183+
artifacts: ${{env.APP_NAME}}_*.deb
184+

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
PREFIX ?= /usr/local
2+
DEB_BUILD ?=0# default: manual install mode
23

34
.PHONY : all
45
all: adi-diagnostic-report.desktop
@@ -15,10 +16,20 @@ install: all
1516
install -d $(DESTDIR)$(PREFIX)/share/adi_diagnostic_report/
1617
install ./adi_diagnostic_report $(DESTDIR)$(PREFIX)/bin/
1718
install ./adi_diagnostic_report.glade $(DESTDIR)$(PREFIX)/share/adi_diagnostic_report/
19+
ifeq ($(DEB_BUILD),0)
1820
xdg-desktop-menu install adi-diagnostic-report.desktop
21+
else
22+
install -d $(DESTDIR)$(PREFIX)/share/applications/
23+
install -m 644 ./adi-diagnostic-report.desktop \
24+
$(DESTDIR)/usr/share/applications/
25+
endif
1926

2027
uninstall:
2128
rm -f $(DESTDIR)$(PREFIX)/bin/adi_diagnostic_report
2229
rm -rf $(DESTDIR)$(PREFIX)/share/adi_diagnostic_report/
30+
ifeq ($(DEB_BUILD),0)
2331
xdg-desktop-menu uninstall adi-diagnostic-report.desktop
32+
else
33+
rm -f $(DESTDIR)$(PREFIX)/share/applications/adi-diagnostic-report.desktop
34+
endif
2435

packaging/debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
diagnostic-report (@VERSION@) UNRELEASED; urgency=low
2+
3+
* CI release.
4+
5+
-- Engineerzone <https://ez.analog.com/sw-interface-tools> @DATE@

packaging/debian/control

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Source: diagnostic-report
2+
Section: devel
3+
Priority: optional
4+
Maintainer: Engineerzone <https://ez.analog.com/sw-interface-tools>
5+
Build-Depends: debhelper-compat (= 13), dh-python, python3, python3-setuptools, pybuild-plugin-pyproject
6+
Standards-Version: 4.5.1
7+
Homepage: https://github.com/analogdevicesinc/diagnostic_report
8+
Rules-Requires-Root: no
9+
10+
Package: diagnostic-report
11+
Architecture: @ARCHITECTURE@
12+
Multi-Arch: foreign
13+
Depends: ${misc:Depends}, ${shlibs:Depends}, ${python3:Depends}
14+
Description: ADI Diagnostic Report Application
15+
Documentation at
16+
https://wiki.analog.com/resources/tools-software/linux-software/diagnostic_report

packaging/debian/copyright

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: diagnostic-report
3+
Upstream-Contact: Engineerzone <https://ez.analog.com/sw-interface-tools>
4+
Source: https://github.com/analogdevicesinc/diagnostic_report
5+
#
6+
# Please double check copyright with the licensecheck(1) command.
7+
8+
Files: *
9+
Copyright: 2014-2018 Analog Devices, Inc.
10+
License: ADIBSD
11+
This software is licensed under the terms described in
12+
/usr/share/doc/adi_diagnostic_report/LICENSE.txt

packaging/debian/install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LICENSE.txt usr/share/doc/adi_diagnostic-report/

packaging/debian/rules

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/make -f
2+
3+
%:
4+
dh $@
5+
6+
override_dh_auto_build:
7+
dh_auto_build -- PREFIX=/usr
8+
9+
override_dh_auto_install:
10+
dh_auto_install -- PREFIX=/usr DEB_BUILD=1
11+

packaging/debian/source/format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3.0 (quilt)
2+

0 commit comments

Comments
 (0)