-
Notifications
You must be signed in to change notification settings - Fork 1
202 lines (177 loc) · 6.36 KB
/
release-binaries.yml
File metadata and controls
202 lines (177 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: release binaries
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag_name:
description: "Release tag to create, for example v0.1.0-native.1"
required: true
type: string
prerelease:
description: "Mark the GitHub Release as a prerelease"
default: true
required: true
type: boolean
permissions:
contents: write
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: windows-x64
os: windows-latest
triplet: x64-windows
artifact: rembg-gui-windows-x64.zip
- name: linux-x64
os: ubuntu-22.04
triplet: x64-linux
artifact: rembg-gui-linux-x64.AppImage
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
steps:
- uses: actions/checkout@v4
- name: Install Linux build packages
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
autoconf \
autoconf-archive \
automake \
build-essential \
libfuse2 \
libgl1-mesa-dev \
libtool \
libx11-dev \
libxcb1-dev \
libxcb-cursor-dev \
libxcb-icccm4-dev \
libxcb-image0-dev \
libxcb-keysyms1-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-shape0-dev \
libxcb-shm0-dev \
libxcb-sync-dev \
libxcb-xfixes0-dev \
libxcb-xkb-dev \
libxkbcommon-dev \
libxkbcommon-x11-dev \
patchelf \
pkg-config
- name: Restore vcpkg cache
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/vcpkg
${{ github.workspace }}/vcpkg_installed
key: vcpkg-${{ matrix.triplet }}-${{ hashFiles('src_cpp/vcpkg.json') }}
- name: Bootstrap vcpkg on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
if (!(Test-Path vcpkg)) {
git clone https://github.com/microsoft/vcpkg.git
}
./vcpkg/bootstrap-vcpkg.bat
- name: Bootstrap vcpkg on Linux
if: runner.os == 'Linux'
run: |
if [ ! -d vcpkg ]; then
git clone https://github.com/microsoft/vcpkg.git
fi
./vcpkg/bootstrap-vcpkg.sh
- name: Configure
run: >
cmake -S src_cpp -B build
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed
- name: Build
run: cmake --build build --config Release --parallel
- name: Test
env:
REMBG_NATIVE_RUN_MODEL_TESTS: "1"
U2NET_HOME: ${{ github.workspace }}/build/model-cache
run: ctest --test-dir build --output-on-failure -C Release
- name: Install Windows bundle
if: runner.os == 'Windows'
run: cmake --install build --config Release --prefix ${{ github.workspace }}/dist/rembg-gui
- name: Package Windows bundle
if: runner.os == 'Windows'
shell: pwsh
run: Compress-Archive -Path dist/rembg-gui/* -DestinationPath ${{ matrix.artifact }}
- name: Install Linux AppDir
if: runner.os == 'Linux'
run: cmake --install build --config Release --prefix "$PWD/AppDir/usr"
- name: Build Linux AppImage
if: runner.os == 'Linux'
env:
APPIMAGE_EXTRACT_AND_RUN: "1"
QMAKE: ${{ github.workspace }}/vcpkg_installed/${{ matrix.triplet }}/tools/Qt6/bin/qmake
run: |
curl -L -o linuxdeploy-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
curl -L -o linuxdeploy-plugin-qt-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage linuxdeploy-plugin-qt-x86_64.AppImage
./linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--executable AppDir/usr/bin/rembg-gui \
--desktop-file src_cpp/packaging/rembg-gui.desktop \
--icon-file src_cpp/packaging/rembg-gui.svg \
--plugin qt \
--output appimage
generated_appimage="$(find . -maxdepth 1 -name '*.AppImage' ! -name 'linuxdeploy*.AppImage' -print -quit)"
test -n "$generated_appimage"
mv "$generated_appimage" "${{ matrix.artifact }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ matrix.artifact }}
publish:
name: publish GitHub release
needs: build
runs-on: ubuntu-22.04
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- name: Download binary artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref_name }}
IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }}
run: |
set -euo pipefail
assets=(
"release-assets/windows-x64/rembg-gui-windows-x64.zip"
"release-assets/linux-x64/rembg-gui-linux-x64.AppImage"
)
for asset in "${assets[@]}"; do
test -f "$asset"
done
release_flags=()
if [ "$IS_PRERELEASE" = "true" ]; then
release_flags+=(--prerelease)
fi
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
gh release upload "$TAG_NAME" "${assets[@]}" --clobber
else
gh release create "$TAG_NAME" "${assets[@]}" \
--target "$GITHUB_SHA" \
--title "$TAG_NAME" \
--generate-notes \
"${release_flags[@]}"
fi