forked from TransparentLC/realesrgan-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (163 loc) · 5.97 KB
/
build.yml
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
name: build
on:
push:
branches:
- master
workflow_dispatch:
inputs:
release:
description: Input something to release an automated build
jobs:
build:
runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: utf-8
PYTHONOPTIMIZE: 1
defaults:
run:
shell: bash
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
cache: pip
cache-dependency-path: requirements.txt
- name: Install pip dependencies
run: pip install -U -r requirements.txt
- name: Setup UPX
run: |
if [ $RUNNER_OS == "Windows" ]; then
choco install upx --no-progress
elif [ $RUNNER_OS == "Linux" ]; then
sudo apt install upx-ucl
elif [ $RUNNER_OS == "macOS" ]; then
brew install upx
fi
- name: Build executable
run: |
pip install pyinstaller==6.*
python -c "import time;open('define.py','a').write(f'\nBUILD_TIME={time.time():.0f}')"
if [[ $RUNNER_OS == "Windows" || $RUNNER_OS == "Linux" ]]; then
export REGUI_ONEFILE=1
fi
if [ $RUNNER_OS == "macOS" ]; then
chmod +x build-macos-app.sh
sh build-macos-app.sh
chmod u+x "dist/Real-ESRGAN GUI.app/Contents/MacOS/realesrgan-gui"
xattr -cr "dist/Real-ESRGAN GUI.app"
else
pyinstaller --clean --log-level WARN realesrgan-gui.spec
fi
- name: Upload result
uses: actions/upload-artifact@v4
with:
name: realesrgan-gui-${{ runner.os }}
path: dist
release:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.release }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: realesrgan-gui-Windows
path: dist-Windows
- uses: actions/download-artifact@v4
with:
name: realesrgan-gui-Linux
path: dist-Linux
- uses: actions/download-artifact@v4
with:
name: realesrgan-gui-macOS
path: dist-macOS
- name: Create release assets
id: vars
run: |
# https://github.com/xinntao/Real-ESRGAN/releases
REAL_ESRGAN_VERSION=v0.2.5.0
REAL_ESRGAN_RELEASE_TIME=20220424
REAL_ESRGAN_PLATFORM=
BUILD_TIME=$(date +%Y%m%d-%H%I%S)
echo "release_name=Automated build ${BUILD_TIME}" >> $GITHUB_OUTPUT
echo "tag_name=autobuild-${BUILD_TIME}" >> $GITHUB_OUTPUT
mkdir release
for BUILD_OS in "Windows" "Linux" "macOS"; do
if [ $BUILD_OS == "Windows" ]; then
REAL_ESRGAN_PLATFORM=windows
elif [ $BUILD_OS == "Linux" ]; then
REAL_ESRGAN_PLATFORM=ubuntu
elif [ $BUILD_OS == "macOS" ]; then
REAL_ESRGAN_PLATFORM=macos
fi
if [ $BUILD_OS == "macOS" ]; then
cd "dist-${BUILD_OS}/Real-ESRGAN GUI.app/Contents/MacOS"
else
cd "dist-${BUILD_OS}"
fi
wget \
-nv \
-O realesrgan-ncnn-vulkan.zip \
"https://github.com/xinntao/Real-ESRGAN/releases/download/${REAL_ESRGAN_VERSION}/realesrgan-ncnn-vulkan-${REAL_ESRGAN_RELEASE_TIME}-${REAL_ESRGAN_PLATFORM}.zip"
unzip -o realesrgan-ncnn-vulkan.zip
rm -f realesrgan-ncnn-vulkan.zip input.jpg input2.jpg onepiece_demo.mp4
if [ $BUILD_OS == "macOS" ]; then
cp ../../../../README.md README_gui.md
cp ../../../../README.en-US.md README_gui.en-US.md
cp ../../../../README.uk-UA.md README_gui.uk-UA.md
cp ../../../../README.tr-TR.md README_gui.tr-TR.md
else
cp ../README.md README_gui.md
cp ../README.en-US.md README_gui.en-US.md
cp ../README.uk-UA.md README_gui.uk-UA.md
cp ../README.tr-TR.md README_gui.tr-TR.md
fi
if [ $BUILD_OS == "Windows" ]; then
7z a \
../release/realesrgan-gui-${REAL_ESRGAN_PLATFORM}.7z \
realesrgan-gui.exe \
-mx9 -mfb256 -md1g -ms
7z a \
../release/realesrgan-gui-${REAL_ESRGAN_PLATFORM}-bundled-${REAL_ESRGAN_VERSION}.7z \
. \
-mx9 -mfb256 -md1g -ms
elif [ $BUILD_OS == "Linux" ]; then
chmod +x realesrgan-gui realesrgan-ncnn-vulkan
XZ_OPT=-e9 tar Jcvf \
../release/realesrgan-gui-${REAL_ESRGAN_PLATFORM}.tar.xz \
--transform "s,^\.,realesrgan-gui," \
./realesrgan-gui
XZ_OPT=-e9 tar Jcvf \
../release/realesrgan-gui-${REAL_ESRGAN_PLATFORM}-bundled-${REAL_ESRGAN_VERSION}.tar.xz \
--transform "s,^\.,realesrgan-gui," \
.
elif [ $BUILD_OS == "macOS" ]; then
chmod +x realesrgan-gui realesrgan-ncnn-vulkan
cd ../../../
XZ_OPT=-e9 tar Jcvf \
../release/realesrgan-gui-${REAL_ESRGAN_PLATFORM}-appbundle-${REAL_ESRGAN_VERSION}.tar.xz \
"Real-ESRGAN GUI.app"
fi
cd ..
done
echo "release_files<<EOF" >> $GITHUB_OUTPUT
find release -type f >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Release automated build
uses: softprops/action-gh-release@v1
if: ${{ github.event.inputs.release }}
with:
name: ${{ steps.vars.outputs.release_name }}
tag_name: ${{ steps.vars.outputs.tag_name }}
files: ${{ steps.vars.outputs.release_files }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}