Skip to content

Commit 83a7665

Browse files
author
Vladimir Vilimaitis
committed
Mirror Linux release packaging locally
1 parent ad544af commit 83a7665

4 files changed

Lines changed: 49 additions & 32 deletions

File tree

.github/workflows/release-binaries.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ jobs:
9898
fi
9999
./vcpkg/bootstrap-vcpkg.sh
100100
101+
- name: Build and package Linux AppImage
102+
if: runner.os == 'Linux'
103+
env:
104+
ARTIFACT_NAME: ${{ matrix.artifact }}
105+
run: bash src_cpp/scripts/ci-linux.sh
106+
101107
- name: Configure
108+
if: runner.os == 'Windows'
102109
run: >
103110
cmake -S src_cpp -B build
104111
-DCMAKE_BUILD_TYPE=Release
@@ -107,9 +114,11 @@ jobs:
107114
-DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed
108115
109116
- name: Build
117+
if: runner.os == 'Windows'
110118
run: cmake --build build --config Release --parallel
111119

112120
- name: Test
121+
if: runner.os == 'Windows'
113122
env:
114123
REMBG_NATIVE_RUN_MODEL_TESTS: "1"
115124
U2NET_HOME: ${{ github.workspace }}/build/model-cache
@@ -124,34 +133,6 @@ jobs:
124133
shell: pwsh
125134
run: Compress-Archive -Path dist/rembg-gui/* -DestinationPath ${{ matrix.artifact }}
126135

127-
- name: Install Linux AppDir
128-
if: runner.os == 'Linux'
129-
run: cmake --install build --config Release --prefix "$PWD/AppDir/usr"
130-
131-
- name: Build Linux AppImage
132-
if: runner.os == 'Linux'
133-
env:
134-
APPIMAGE_EXTRACT_AND_RUN: "1"
135-
QMAKE: ${{ github.workspace }}/vcpkg_installed/${{ matrix.triplet }}/tools/Qt6/bin/qmake
136-
run: |
137-
curl -L -o linuxdeploy-x86_64.AppImage \
138-
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
139-
curl -L -o linuxdeploy-plugin-qt-x86_64.AppImage \
140-
https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
141-
chmod +x linuxdeploy-x86_64.AppImage linuxdeploy-plugin-qt-x86_64.AppImage
142-
143-
./linuxdeploy-x86_64.AppImage \
144-
--appdir AppDir \
145-
--executable AppDir/usr/bin/rembg-gui \
146-
--desktop-file src_cpp/packaging/rembg-gui.desktop \
147-
--icon-file src_cpp/packaging/rembg-gui.svg \
148-
--plugin qt \
149-
--output appimage
150-
151-
generated_appimage="$(find . -maxdepth 1 -name '*.AppImage' ! -name 'linuxdeploy*.AppImage' -print -quit)"
152-
test -n "$generated_appimage"
153-
mv "$generated_appimage" "${{ matrix.artifact }}"
154-
155136
- name: Upload artifact
156137
uses: actions/upload-artifact@v4
157138
with:

src_cpp/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ if(WIN32)
170170
set_target_properties(rembg-gui-native PROPERTIES WIN32_EXECUTABLE TRUE)
171171
elseif(APPLE)
172172
set_target_properties(rembg-gui-native PROPERTIES MACOSX_BUNDLE TRUE)
173+
elseif(UNIX)
174+
set_target_properties(rembg-gui-native PROPERTIES
175+
INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}"
176+
)
173177
endif()
174178

175179
install(TARGETS rembg-gui-native

src_cpp/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ in VS Code, choose "Reopen in Container", then run:
3232
bash src_cpp/scripts/ci-linux.sh
3333
```
3434

35-
That script uses Ubuntu 22.04 packages, vcpkg manifest mode, a Release build,
36-
and `REMBG_NATIVE_RUN_MODEL_TESTS=1`, matching the Linux release job closely
37-
enough to catch the model download path before pushing.
35+
That script is also what GitHub Actions runs for the Linux job. It configures,
36+
builds, runs `ctest` with `REMBG_NATIVE_RUN_MODEL_TESTS=1`, installs into
37+
`AppDir`, and builds the AppImage with linuxdeploy.
3838

3939
## Release layout
4040

src_cpp/scripts/ci-linux.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
55
repo_root="$(cd -- "${script_dir}/../.." && pwd)"
66

77
build_type="${CMAKE_BUILD_TYPE:-Release}"
8-
build_dir="${BUILD_DIR:-${repo_root}/build-linux-ci}"
8+
build_dir="${BUILD_DIR:-${repo_root}/build}"
99
vcpkg_root="${VCPKG_ROOT:-${repo_root}/vcpkg}"
10+
artifact_name="${ARTIFACT_NAME:-rembg-gui-linux-x64.AppImage}"
1011

1112
if [[ ! -x "${vcpkg_root}/vcpkg" ]]; then
1213
if [[ ! -d "${vcpkg_root}" ]]; then
@@ -28,3 +29,34 @@ cmake -S "${repo_root}/src_cpp" -B "${build_dir}" \
2829

2930
cmake --build "${build_dir}" --config "${build_type}" --parallel
3031
ctest --test-dir "${build_dir}" --output-on-failure -C "${build_type}"
32+
33+
rm -rf "${repo_root}/AppDir" "${repo_root:?}/${artifact_name}"
34+
cmake --install "${build_dir}" --config "${build_type}" --prefix "${repo_root}/AppDir/usr"
35+
36+
linuxdeploy="${repo_root}/linuxdeploy-x86_64.AppImage"
37+
linuxdeploy_qt="${repo_root}/linuxdeploy-plugin-qt-x86_64.AppImage"
38+
39+
curl -L -o "${linuxdeploy}" \
40+
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
41+
curl -L -o "${linuxdeploy_qt}" \
42+
https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
43+
chmod +x "${linuxdeploy}" "${linuxdeploy_qt}"
44+
45+
export APPIMAGE_EXTRACT_AND_RUN="${APPIMAGE_EXTRACT_AND_RUN:-1}"
46+
export QMAKE="${QMAKE:-${VCPKG_INSTALLED_DIR}/${VCPKG_DEFAULT_TRIPLET}/tools/Qt6/bin/qmake}"
47+
export LD_LIBRARY_PATH="${repo_root}/AppDir/usr/lib:${VCPKG_INSTALLED_DIR}/${VCPKG_DEFAULT_TRIPLET}/lib:${LD_LIBRARY_PATH:-}"
48+
49+
(
50+
cd "${repo_root}"
51+
"${linuxdeploy}" \
52+
--appdir AppDir \
53+
--executable AppDir/usr/bin/rembg-gui \
54+
--desktop-file src_cpp/packaging/rembg-gui.desktop \
55+
--icon-file src_cpp/packaging/rembg-gui.svg \
56+
--plugin qt \
57+
--output appimage
58+
59+
generated_appimage="$(find . -maxdepth 1 -name '*.AppImage' ! -name 'linuxdeploy*.AppImage' -print -quit)"
60+
test -n "${generated_appimage}"
61+
mv "${generated_appimage}" "${artifact_name}"
62+
)

0 commit comments

Comments
 (0)