Skip to content

Commit

Permalink
merged master into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlamhauge committed Apr 27, 2024
2 parents 18809b7 + 124ec31 commit 87f1bb3
Show file tree
Hide file tree
Showing 682 changed files with 216,001 additions and 74,335 deletions.
24 changes: 24 additions & 0 deletions .github/actions/create-package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Create Package
inputs:
arch:
description: Architecture
required: true
qt:
description: Qt Version
required: true
outputs:
output-basename:
description: Output basename
value: ${{steps.create-package.outputs.output-basename}}
runs:
using: composite
steps:
- id: create-package
run: ${GITHUB_ACTION_PATH}/create-package.sh
working-directory: build
shell: bash
env:
RUNNER_OS: ${{runner.os}}
INPUT_ARCH: ${{inputs.arch}}
INPUT_QT: ${{inputs.qt}}
IS_RELEASE: ${{ github.ref == 'refs/heads/release' }}
173 changes: 173 additions & 0 deletions .github/actions/create-package/create-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#!/usr/bin/env bash

trap 'echo "::error::Command failed"' ERR
set -eE

harvest_files() {
echo "<?xml version='1.0' encoding='utf-8'?>"
echo "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>"
echo " <Fragment>"
echo " <ComponentGroup Id='$1' Directory='INSTALLDIR'>"

while IFS= read -r filepath; do
local subdirectory="$(dirname "${filepath}")"
if [ "${subdirectory}" = "." ]; then
echo " <Component>"
else
echo " <Component Subdirectory='${subdirectory}'>"
fi
echo " <File Source='${filepath}' />"
echo " </Component>"
done

echo " </ComponentGroup>"
echo " </Fragment>"
echo "</Wix>"
}

create_package_linux() {
echo "::group::Set up AppImage contents"
make install INSTALL_ROOT="${PWD}/Pencil2D"
echo "::endgroup::"

echo "::group::Create AppImage"
# "Downgrade" the desktop entry to version 1.0
sed -i "/^Keywords\(\[[a-zA-Z_.@]\+\]\)\?=/d;/^Version=/cVersion=1.0" \
Pencil2D/usr/share/applications/org.pencil2d.Pencil2D.desktop
install -Dm755 /usr/bin/ffmpeg Pencil2D/usr/plugins/ffmpeg
install -Dm755 "/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner" \
"Pencil2D/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
local gst_executables="-executable=Pencil2D/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
for plugin in adpcmdec alsa app audioconvert audioparsers audioresample \
autodetect coreelements gsm id3demux jack mpg123 mulaw playback \
pulse typefindfunctions wavparse apetag; do
install -Dm755 "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgst${plugin}.so" \
"Pencil2D/usr/lib/gstreamer-1.0/libgst${plugin}.so"
gst_executables="${gst_executables} -executable=Pencil2D/usr/lib/gstreamer-1.0/libgst${plugin}.so"
done
curl -fsSLO https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
chmod 755 linuxdeployqt-continuous-x86_64.AppImage
local update_info="" # Currently no appimageupdate support for nightly builds
if [ $IS_RELEASE = "true" ]; then
update_info="-updateinformation=gh-releases-zsync|${GITHUB_REPOSITORY/\//|}|latest|pencil2d-linux-amd64-*.AppImage.zsync"
fi
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib/x86_64-linux-gnu/pulseaudio" \
./linuxdeployqt-continuous-x86_64.AppImage \
Pencil2D/usr/share/applications/org.pencil2d.Pencil2D.desktop \
-executable=Pencil2D/usr/plugins/ffmpeg \
${gst_executables} \
-extra-plugins=platforms/libqwayland-egl.so,platforms/libqwayland-generic.so,\
platforms/libqwayland-xcomposite-egl.so,platforms/libqwayland-xcomposite-glx.so,\
wayland-decoration-client,wayland-graphics-integration-client,wayland-shell-integration \
${update_info} \
-appimage
local qtsuffix="-qt${INPUT_QT}"
local output_name="pencil2d${qtsuffix/-qt5/}-linux-$3"
mv Pencil2D*.AppImage "$output_name.AppImage"
mv Pencil2D*.AppImage.zsync "$output_name.AppImage.zsync" \
&& sed -i '1,/^$/s/^\(Filename\|URL\): .*$/\1: '"$output_name.AppImage/" "$output_name.AppImage.zsync" \
|| true
echo "output-basename=$output_name" >> "${GITHUB_OUTPUT}"
echo "::endgroup::"
}

create_package_macos() {
echo "::group::Clean"
make clean
mkdir Pencil2D
mv app/Pencil2D.app Pencil2D/
pushd Pencil2D >/dev/null
echo "::endgroup::"

echo "::group::Copy FFmpeg plugin"
mkdir Pencil2D.app/Contents/MacOS/plugins
curl -fsSLo ffmpeg.7z https://evermeet.cx/ffmpeg/getrelease/7z
curl -fsSLo ffmpeg.7z.sig https://evermeet.cx/ffmpeg/getrelease/7z/sig
mkdir -m700 ~/.gnupg
echo "trusted-key 0x476C4B611A660874" > ~/.gnupg/gpg.conf
curl -fsSL https://evermeet.cx/ffmpeg/0x1A660874.asc | gpg --import
gpg --verify ffmpeg.7z.sig ffmpeg.7z
bsdtar xfC ffmpeg.7z Pencil2D.app/Contents/MacOS/plugins
rm ffmpeg.7z ffmpeg.7z.sig
echo "::endgroup::"

echo "::group::Deploy Qt libraries"
macdeployqt Pencil2D.app
echo "::endgroup::"

popd >/dev/null
echo "Create ZIP"
local qtsuffix="-qt${INPUT_QT}"
bsdtar caf "pencil2d${qtsuffix/-qt5/}-mac-$3.zip" Pencil2D
echo "output-basename=pencil2d${qtsuffix/-qt5/}-mac-$3" > "${GITHUB_OUTPUT}"
}

create_package_windows() {
echo "::group::Set up application files"
nmake install INSTALL_ROOT="$(cygpath -w "${PWD}/Pencil2D")"
echo "::endgroup::"

echo "Copy FFmpeg plugin"
local platform="${INPUT_ARCH%%_*}"
local ffmpeg="ffmpeg-${platform}.zip"
curl -fsSLO "https://github.com/pencil2d/pencil2d-deps/releases/download/ffmpge-v4.1.1/$ffmpeg"
"${WINDIR}\\System32\\tar" xf "${ffmpeg}"
mkdir Pencil2D/plugins
mv "ffmpeg.exe" Pencil2D/plugins/
rm -rf "${ffmpeg}"

echo "Remove files"
find \( -name '*.pdb' -o -name '*.ilk' \) -delete
echo "Deploy Qt libraries"
# windeployqt lists some translation files that it doesn't actually copy, and the MSVC redistributable is handled by the bundle, so skip those
windeployqt --list relative Pencil2D/pencil2d.exe | grep -v '^translations\\qtbase_' | grep -v '^translations\\qtmultimedia_' | grep -v '^vc_' | harvest_files windeployqt > windeployqt.wxs
echo "Copy OpenSSL DLLs"
curl -fsSLO https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-1.1.1w.zip
"${WINDIR}\\System32\\tar" xf openssl-1.1.1w.zip
local wordsize="${platform#win}"
local xbits="x${wordsize}"
local _xbits="-x${wordsize}"
cp "openssl-1.1\\${xbits/32/86}\\bin\\lib"{ssl,crypto}"-1_1${_xbits/-x32/}.dll" Pencil2D/
echo "::group::Create Installer"
env -C ../util/installer qmake CONFIG-=debug_and_release CONFIG+=release
env -C ../util/installer "PATH=${PATH/\/usr\/bin:/}" nmake
env -C Pencil2D find resources/ -type f | harvest_files resources > resources.wxs
for i in ../util/installer/translations/pencil2d_*.wxl.xlf; do
local basename="$(basename -s .wxl.xlf "$i")"
local locale="${basename#*_}"
local culture="${locale/_/-}"
local lcid="$(pwsh -c "(Get-Culture -Name ${culture}).LCID")"
sed "s/Culture=\"en\"/Culture=\"${culture}\"/;s/Language=\"9\"/Language=\"${lcid}\"/" ../util/installer/pencil2d.wxl > "../util/installer/pencil2d_${locale}.wxl"
tikal.bat -m -fc ../util/installer/okf_xml_wxl -ie utf-8 -oe utf-8 -sd ../util/installer -od ../util/installer "${i}"
done
local versiondefines="-d Edition=Nightly -d NightlyBuildNumber=$1 -d NightlyBuildTimestamp=$(date +%F)"
if [ "$IS_RELEASE" = "true" ]; then
versiondefines="-d Edition=Release -d Version=$2"
fi
wix build -pdbtype none -arch "x${wordsize/32/86}" -dcl high -b ../util/installer -b Pencil2D \
-d "ProductCode=$(python -c "import uuid; print(str(uuid.uuid5(uuid.NAMESPACE_URL, '-Nhttps://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}#${platform}')).upper())")" \
$versiondefines \
-out "pencil2d-${platform}-$3.msi" \
../util/installer/pencil2d.wxs windeployqt.wxs resources.wxs
wix build -pdbtype none -arch "x${wordsize/32/86}" -dcl high -sw1133 -b ../util/installer -b Pencil2D \
-ext WixToolset.Util.wixext -ext WixToolset.Bal.wixext \
$versiondefines \
-out "pencil2d-${platform}-$3.exe" \
../util/installer/pencil2d.bundle.wxs
echo "::endgroup::"
echo "Create ZIP"
local qtsuffix="-qt${INPUT_QT}"
"${WINDIR}\\System32\\tar" caf "pencil2d${qtsuffix/-qt5/}-${platform}-$3.zip" Pencil2D
# This basename pattern deliberately does not include the installer for the Qt 6 build.
# Should this ever be changed so that more than one installer is uploaded per workflow run,
# absolutely make sure not to break any Windows Installer rules.
echo "output-basename=pencil2d${qtsuffix/-qt5/}-${platform}-$3" > "${GITHUB_OUTPUT}"
}

eval "$(grep '^VERSION =' ../util/common.pri | tr -d '[:blank:]')"
buildversion="${GITHUB_RUN_NUMBER}-$(date +%F)"
if [ "$IS_RELEASE" = "true" ]; then
buildversion="${VERSION}"
fi

"create_package_$(echo $RUNNER_OS | tr '[A-Z]' '[a-z]')" "${GITHUB_RUN_NUMBER}" "${VERSION}" "${buildversion}"
23 changes: 23 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Install dependencies
inputs:
arch:
description: Architecture
required: true
qt:
description: Qt Version
required: true
runs:
using: composite
steps:
- if: runner.os == 'Windows'
uses: jurplel/install-qt-action@v3
with:
arch: ${{inputs.arch}}
version: ${{matrix.qt == 6 && '6.4.2' || '5.15.2'}}
modules: ${{matrix.qt == 6 && 'qtmultimedia' || ''}}
- run: ${GITHUB_ACTION_PATH}/install-dependencies.sh
shell: bash
env:
RUNNER_OS: ${{runner.os}}
INPUT_ARCH: ${{inputs.arch}}
INPUT_QT: ${{inputs.qt}}
65 changes: 65 additions & 0 deletions .github/actions/install-dependencies/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

setup_linux() {
# Because of how bare-bones our docker image is
echo "::group::Install prerequisites"
apt-get -yq install software-properties-common
echo "::endgroup::"

echo "::group::Add APT sources"
for ppa in ppa:ubuntu-toolchain-r/test ppa:ubuntu-sdk-team/ppa \
ppa:git-core/ppa; do
apt-add-repository -y "${ppa}"
done
if [ "${INPUT_QT}" -eq 5 ]; then
apt-add-repository -y ppa:beineri/opt-qt-5.15.2-xenial
fi
echo "::endgroup::"

echo "::group::Fetch APT updates"
apt-get update -yq
echo "::endgroup::"

echo "::group::Install APT packages"
if [ "${INPUT_QT}" -eq 5 ]; then
apt-get install -yq --no-install-suggests --no-install-recommends \
build-essential qt515tools qt515base qt515multimedia qt515svg \
qt515wayland libgl1-mesa-dev bsdtar ffmpeg gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-alsa gstreamer1.0-pulseaudio git \
curl libfuse2
else
apt-get install -yq --no-install-suggests --no-install-recommends \
build-essential qt6-l10n-tools qt6-base-dev qt6-multimedia-dev \
libqt6svg6-dev qt6-wayland-dev libgl1-mesa-dev libarchive-tools ffmpeg \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-alsa \
gstreamer1.0-pulseaudio git curl libfuse2
fi
echo "::endgroup::"
}

setup_macos() {
echo "::group::Update Homebrew"
brew update
echo "::endgroup::"
echo "::group::Install Homebrew packages"
brew install libarchive qt@${INPUT_QT}
brew link qt@${INPUT_QT} --force
echo "/usr/local/opt/libarchive/bin" >> "${GITHUB_PATH}"
echo "::endgroup::"
}

setup_windows() {
pip install translate-toolkit[rc]
curl -fsSLO https://okapiframework.org/binaries/main/1.45.0/okapi-apps_win32-x86_64_1.45.0.zip
mkdir okapi
"${WINDIR}\\System32\\tar" xfC okapi-apps_win32-x86_64_1.45.0.zip okapi
dotnet tool install -g wix --version 4.0.4
wix extension add -g WixToolset.Util.wixext/4.0.4 WixToolset.Bal.wixext/4.0.4
nuget install -x -OutputDirectory util/installer WixToolset.BootstrapperCore.Native -Version 4.0.4
nuget install -x -OutputDirectory util/installer WixToolset.DUtil -Version 4.0.4
nuget install -x -OutputDirectory util/installer WixToolset.BalUtil -Version 4.0.4
}

"setup_$(echo "${RUNNER_OS}" | tr '[A-Z]' '[a-z]')"
13 changes: 13 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Set up environment
inputs:
arch:
description: Architecture
required: true
runs:
using: composite
steps:
- run: ${GITHUB_ACTION_PATH}/setup-environment.sh
shell: bash
env:
RUNNER_OS: ${{runner.os}}
INPUT_ARCH: ${{inputs.arch}}
26 changes: 26 additions & 0 deletions .github/actions/setup-environment/setup-environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

setup_linux() {
echo "MAKEFLAGS=-j2" >> "${GITHUB_ENV}"
# Our container image uses the non-Unicode C locale by default
echo "LANG=C.UTF-8" >> "${GITHUB_ENV}"
# Set up Qt environment variables and export them to the GitHub Actions workflow
if [ -f /opt/qt515/bin/qt515-env.sh ]; then
(printenv; (. /opt/qt515/bin/qt515-env.sh; printenv)) | sort -st= -k1,1 | uniq -u >> "${GITHUB_ENV}"
fi
}

setup_macos() {
echo "MAKEFLAGS=-j3" >> "${GITHUB_ENV}"
}

setup_windows() {
# Set up MSVC environment variables and export them to the GitHub Actions workflow
local platform="${INPUT_ARCH%%_*}"
local vcvars="C:\\Program^ Files^ ^(x86^)\\Microsoft^ Visual^ Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars${platform#win}.bat"
($(which cmd) //c set; $(which cmd) //c "${vcvars} 2>&1>nul && set") | sort -st= -k1,1 | uniq -u >> "${GITHUB_ENV}"
echo "${JAVA_HOME_17_X64}\\bin" >> "${GITHUB_PATH}"
realpath okapi/ >> "${GITHUB_PATH}"
}

"setup_$(echo "${RUNNER_OS}" | tr '[A-Z]' '[a-z]')"
Loading

0 comments on commit 87f1bb3

Please sign in to comment.