Skip to content

Commit d8d76f2

Browse files
Add GitLab CI Linux build target that produces an AppImage
1 parent f9a7648 commit d8d76f2

File tree

2 files changed

+94
-12
lines changed

2 files changed

+94
-12
lines changed

.gitlab-ci.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ before_script:
2525
#-----------------------------------------------------------------------#
2626
# Linux (AppImage) Build Target #
2727
#-----------------------------------------------------------------------#
28-
# build_linux:
29-
# image: ubuntu:bionic
30-
# stage: build
31-
# script:
32-
# - apt update
33-
# - apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git
34-
# - ./scripts/build-appimage.sh
35-
36-
# artifacts:
37-
# paths:
38-
# - OpenRGB-x86_64.AppImage
39-
# expire_in: 1337 years
28+
build_linux:
29+
image: ubuntu:bionic
30+
stage: build
31+
script:
32+
- apt update
33+
- apt install -y build-essential qtcreator qt5-default libopenal-dev pkgconf wget git
34+
- ./scripts/build-appimage.sh
35+
36+
artifacts:
37+
paths:
38+
- KeyboardVisualizer-x86_64.AppImage
39+
expire_in: 1337 years
4040

4141
#-----------------------------------------------------------------------#
4242
# Windows (32-bit) Build Target #

scripts/build-appimage.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
#-----------------------------------------------------------------------#
4+
# Keyboard Visualizer AppImage Build Script #
5+
#-----------------------------------------------------------------------#
6+
7+
set -x
8+
set -e
9+
10+
#-----------------------------------------------------------------------#
11+
# Build in a temporary directory to keep the system clean #
12+
# Use RAM disk if possible (if available and not building on a CI #
13+
# system like Travis) #
14+
#-----------------------------------------------------------------------#
15+
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
16+
TEMP_BASE=/dev/shm
17+
else
18+
TEMP_BASE=/tmp
19+
fi
20+
21+
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" appimage-build-XXXXXX)
22+
23+
#-----------------------------------------------------------------------#
24+
# Make sure to clean up build dir, even if errors occur #
25+
#-----------------------------------------------------------------------#
26+
cleanup () {
27+
if [ -d "$BUILD_DIR" ]; then
28+
rm -rf "$BUILD_DIR"
29+
fi
30+
}
31+
trap cleanup EXIT
32+
33+
#-----------------------------------------------------------------------#
34+
# Store repo root as variable #
35+
#-----------------------------------------------------------------------#
36+
REPO_ROOT=$(readlink -f $(dirname $(dirname $0)))
37+
OLD_CWD=$(readlink -f .)
38+
39+
#-----------------------------------------------------------------------#
40+
# Switch to build dir #
41+
#-----------------------------------------------------------------------#
42+
pushd "$BUILD_DIR"
43+
44+
#-----------------------------------------------------------------------#
45+
# Configure build files with qmake #
46+
# we need to explicitly set the install prefix, as qmake's default is #
47+
# /usr/local for some reason... #
48+
#-----------------------------------------------------------------------#
49+
qmake "$REPO_ROOT"
50+
51+
#-----------------------------------------------------------------------#
52+
# Build project and install files into AppDir #
53+
#-----------------------------------------------------------------------#
54+
make -j$(nproc)
55+
make install INSTALL_ROOT=AppDir
56+
57+
#-----------------------------------------------------------------------#
58+
# Now, build AppImage using linuxdeploy and linuxdeploy-plugin-qt #
59+
# Download linuxdeploy and its Qt plugin #
60+
#-----------------------------------------------------------------------#
61+
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
62+
wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
63+
64+
#-----------------------------------------------------------------------#
65+
# Make them executable #
66+
#-----------------------------------------------------------------------#
67+
chmod +x linuxdeploy*.AppImage
68+
69+
#-----------------------------------------------------------------------#
70+
# Make sure Qt plugin finds QML sources so it can deploy the imported #
71+
# files #
72+
export QML_SOURCES_PATHS="$REPO_ROOT"/src
73+
74+
./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir -e KeyboardVisualizer -i "$REPO_ROOT"/KeyboardVisualizerQT/KeyboardVisualizer.png -d "$REPO_ROOT"/KeyboardVisualizerQT/KeyboardVisualizer.desktop
75+
./linuxdeploy-plugin-qt-x86_64.AppImage --appimage-extract-and-run --appdir AppDir
76+
./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir --output appimage
77+
78+
#-----------------------------------------------------------------------#
79+
# Move built AppImage back into original CWD #
80+
#-----------------------------------------------------------------------#
81+
mv KeyboardVisualizer*.AppImage "$OLD_CWD"
82+

0 commit comments

Comments
 (0)