Skip to content

Update realesrgan-gui.spec #104

Update realesrgan-gui.spec

Update realesrgan-gui.spec #104

Workflow file for this run

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 }}