Skip to content

Commit

Permalink
ci:add build script
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Jul 2, 2022
1 parent e0663ed commit 687405e
Show file tree
Hide file tree
Showing 28 changed files with 459 additions and 3 deletions.
181 changes: 181 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: CI

on:
push:
branches: [ main ]
paths-ignore:
- 'doc/**'
- 'README.md'
- '.readthedocs.yaml'
pull_request:
branches: [ master ]
paths-ignore:
- 'doc/**'
- 'README.md'
- '.readthedocs.yaml'
workflow_dispatch:

jobs:
ubuntu-2004:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Install Qt
uses: jurplel/[email protected]

- name: Install prerequisites
run: |
sudo apt update
sudo apt install -y make gcc patchelf
- name: Build all
run: |
git fetch --tags --force
git describe --always --long --dirty --abbrev=10 --tags | awk '{print "\""$0"\""}' > git_tag.inc
sed -i 's/git_tag.inc/git_tag.ci.inc/g' TTFviewer.pro
sed -i 's/QT_DIR=\/opt/QT_DIR=$(cd "$(dirname "$0")";pwd)/g' build_deb.sh
sed -i 's/\/home\/qqm\/Desktop\/ttfviewer\/depend\/freetype/\/usr\/local\/ttfviewer/g' partform_unix.pri
cd depend
sudo ./build.sh
cd -
./build_deb.sh
- name: Upload build asserts
uses: actions/[email protected]
with:
name: TTFviewer_Ubuntu2004
path: |
./dpkg/*.deb
- name: Run tests
run: |
if ls ./dpkg | grep ".deb" ; then echo "Pass"; else echo "Failed" && exit 1; fi;
timeout --foreground -s SIGKILL 20s ./dpkg/TTFviewer_Linux_*/opt/TTFviewer/TTFviewer --version > >(tee run.log) || {
if cat run.log | grep "TTFviewer" ; then echo "Pass" && exit 0; else echo "Failed" && exit 1; fi;
}
ubuntu-1804:
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2

- name: Install Qt
uses: jurplel/[email protected]

- name: Install prerequisites
run: |
sudo apt update
sudo apt install -y make gcc patchelf
- name: Build all
run: |
git fetch --tags --force
git describe --always --long --dirty --abbrev=10 --tags | awk '{print "\""$0"\""}' > git_tag.inc
sed -i 's/git_tag.inc/git_tag.ci.inc/g' TTFviewer.pro
sed -i 's/QT_DIR=\/opt/QT_DIR=$(cd "$(dirname "$0")";pwd)/g' build_deb.sh
sed -i 's/\/home\/qqm\/Desktop\/ttfviewer\/depend\/freetype/\/usr\/local\/ttfviewer/g' partform_unix.pri
cd depend
sudo ./build.sh
cd -
./build_deb.sh
- name: Upload build asserts
uses: actions/[email protected]
with:
name: TTFviewer_Ubuntu1804
path: |
./dpkg/*.deb
- name: Run tests
run: |
if ls ./dpkg | grep ".deb" ; then echo "Pass"; else echo "Failed" && exit 1; fi;
timeout --foreground -s SIGKILL 20s ./dpkg/TTFviewer_Linux_*/opt/TTFviewer/TTFviewer --version > >(tee run.log) || {
if cat run.log | grep "TTFviewer" ; then echo "Pass" && exit 0; else echo "Failed" && exit 1; fi;
}
windows:
runs-on: windows-2019

steps:
- uses: actions/checkout@v2

- name: Install Qt
uses: jurplel/[email protected]
with:
arch: win64_mingw81

- name: Install prerequisites
run: |
Choco-Install -PackageName innosetup --force
Choco-Install -PackageName cmake --force
- uses: msys2/setup-msys2@v2

- name: Build depend
shell: msys2 {0}
run: |
pacman --noconfirm -S make gcc
cd depend
./build_ms.sh
- name: Build all
run: |
git fetch --tags --force
git describe --always --long --dirty --abbrev=10 --tags | ./tools/awk/awk.exe '{print \"\\\"\"$0\"\\\"\"}' > git_tag.inc
./tools/sed/sed.exe -i "s/git_tag.inc/git_tag.ci.inc/g" TTFviewer.pro
./tools/sed/sed.exe -i "s/QT_DIR=C:\/Qt\/Qt5.12.8\/5.12.8\/mingw73_32\/bin/QT_DIR=%Qt5_Dir%/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/QT_TOOLS_DIR=C:\/Qt\/Qt5.12.8\/Tools\/mingw730_32\/bin/QT_TOOLS_DIR=C:\/ProgramData\/Chocolatey\/lib\/mingw\/tools\/install\/mingw64\/x86_64-w64-mingw32\/bin/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/FREETPE2_DIR=D:\\ttfviewer\\depend\\freetype/FREETPE2_DIR=D:\\freetype/g" ./partform_win32.pri
./build_setup.bat
- name: Upload build asserts
uses: actions/[email protected]
with:
name: TTFviewer_windows
path: |
./InnoSetup/TTFviewer_setup.exe
- name: Run tests
run: |
./InnoSetup/build/TTFviewer.exe --version
macos:
runs-on: macos-10.15

steps:
- uses: actions/checkout@v2

- name: Install Qt
uses: jurplel/[email protected]

- name: Install prerequisites
run: |
ruby - e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2 > /dev/null
brew install --build-from-source cmake
- name: Build all
run: |
git fetch --tags --force
git describe --always --long --dirty --abbrev=10 --tags | awk '{print "\""$0"\""}' > git_tag.inc
sed -i'.original' -e 's/git_tag.inc/git_tag.ci.inc/g' TTFviewer.pro
sed -i'.original' -e 's/QT_DIR=\/opt/QT_DIR=$(cd "$(dirname "$0")";pwd)/g' build_dmg.sh
sed -i'.original' -e 's/\/home\/qqm\/Desktop\/ttfviewer\/depend\/freetype/\/usr\/local\/ttfviewer/g' partform_unix.pri
cd depend
sudo ./build.sh
cd -
./build_dmg.sh
- name: Upload build asserts
uses: actions/[email protected]
with:
name: TTFviewer_macos
path: |
./build_release/out/TTFviewer.dmg
- name: Run tests
run: |
sudo hdiutil attach ./build_release/out/TTFviewer.dmg
/Volumes/TTFviewer/TTFviewer.app/Contents/MacOS/TTFviewer --version
3 changes: 3 additions & 0 deletions InnoSetup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# InnoSetup
/build
TTFviewer_setup.exe
1 change: 1 addition & 0 deletions InnoSetup/Info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TTFviewer tools
54 changes: 54 additions & 0 deletions InnoSetup/build_setup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

#define MyAppName "TTFviewer"
#define MyAppVersion "#VERSION#"
#define MyAppVersionInfoVersion "#VERSIONINFOVERSION#"
#define MyAppPublisher "QQxiaoming <[email protected]> zhiliao007 <[email protected]>"
#define MyAppURL "https://github.com/QQxiaoming/TTFviewer"
#define MyAppExeName "TTFviewer.exe"
#define MyAppOutputName "TTFviewer_setup"

[Setup]
AppId={{4368AAE0-A354-4127-94A9-0C38727B1DCC}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename={#MyAppOutputName}
Compression=lzma
SolidCompression=yes

VersionInfoVersion={#MyAppVersionInfoVersion}
UninstallDisplayIcon={app}/{#MyAppExeName}
InfoBeforeFile=..\InnoSetup\Info.txt
OutPutdir=..\InnoSetup
;SetupIconFile=..\img\ico.ico
PrivilegesRequired=admin
AllowNoIcons=no
DisableProgramGroupPage=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode

[Files]
Source: "..\InnoSetup\build\TTFviewer.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\InnoSetup\build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
10 changes: 9 additions & 1 deletion TTFviewer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ win32:{
INCLUDEPATH += $${FREETPE2_DIR}\include\freetype2 \
$${FREETPE2_DIR}\include

LIBS += $${FREETPE2_DIR}\lib\libfreetype.a
LIBS += $${FREETPE2_DIR}\lib\libfreetype.dll.a

VERSION = $${YVYVIEWER_VERSION}.000
QMAKE_TARGET_PRODUCT = "TTFviewer"
Expand All @@ -83,7 +83,9 @@ unix:!macx:{
QMAKE_RPATHDIR=$ORIGIN
QMAKE_LFLAGS += -no-pie

INCLUDEPATH += -I $${FREETPE2_DIR}/include
INCLUDEPATH += -I $${FREETPE2_DIR}/include/freetype2
DEPENDPATH +=$${FREETPE2_DIR}/include
DEPENDPATH +=$${FREETPE2_DIR}/include/freetype2
LIBS += -L $${FREETPE2_DIR}/lib/ -lfreetype

Expand All @@ -93,6 +95,12 @@ unix:!macx:{
macx:{
QMAKE_RPATHDIR=$ORIGIN

INCLUDEPATH += -I $${FREETPE2_DIR}/include
INCLUDEPATH += -I $${FREETPE2_DIR}/include/freetype2
DEPENDPATH +=$${FREETPE2_DIR}/include
DEPENDPATH +=$${FREETPE2_DIR}/include/freetype2
LIBS += -L $${FREETPE2_DIR}/lib/ -lfreetype

git_tag.commands = $$quote("cd $$PWD && git describe --always --long --dirty --abbrev=10 --tags | awk \'{print \"\\\"\"\$$0\"\\\"\"}\' > git_tag.inc")
}

Expand Down
47 changes: 47 additions & 0 deletions build_deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

###############################################################################
# 定义QT目录
QT_DIR=/opt/Qt5.12.8/5.12.8/gcc_64

# 定义版本号
YVYVIEWER_MAJARVERSION="0"
YVYVIEWER_SUBVERSION="0"
YVYVIEWER_REVISION="1"
###############################################################################


###############################################################################
export PATH=$QT_DIR/bin:$PATH
export LD_LIBRARY_PATH=$QT_DIR/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$QT_DIR/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=$QT_DIR/qml:$QML2_IMPORT_PATH
# 合成版本号
YVYVIEWER_VERSION="V"$YVYVIEWER_MAJARVERSION$YVYVIEWER_SUBVERSION$YVYVIEWER_REVISION
# 编译
rm -rf .qmake.stash Makefile
qmake ./TTFviewer.pro -spec linux-g++ CONFIG+=qtquickcompiler
make clean
make -j8
# clean打包目录
rm -rf ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64
rm -f ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64.deb
# 构建打包目录
cp -r ./dpkg/TTFviewer ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64
mkdir -p ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer
cp -r ./test ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/test
cp ./build_release/out/TTFviewer ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/TTFviewer
# 使用linuxdeployqt拷贝依赖so库到打包目录
./tools/linuxdeployqt ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/TTFviewer -appimage
rm -rf ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/doc ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/default.png ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/AppRun ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/default.desktop
#cp ./img/ico.png ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/opt/TTFviewer/TTFviewer.png
# 配置打包信息
sed -i "s/#VERSION#/$YVYVIEWER_MAJARVERSION.$YVYVIEWER_SUBVERSION$YVYVIEWER_REVISION/g" ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/DEBIAN/control
SIZE=$(du -sh -B 1024 ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64 | sed "s/.\///g")
InstalledSize=$SIZE
sed -i "s/#SIZE#/$InstalledSize/g" ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/DEBIAN/control
chmod 755 ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64/* -R
# 打包
dpkg -b ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64 ./dpkg/TTFviewer_Linux_"$YVYVIEWER_VERSION"_x86_64.deb
echo build success!
###############################################################################
32 changes: 32 additions & 0 deletions build_dmg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

###############################################################################
# 定义QT目录
QT_DIR=/opt/Qt5.12.2/5.12.2/gcc_64

# 定义版本号
YVYVIEWER_MAJARVERSION="0"
YVYVIEWER_SUBVERSION="4"
YVYVIEWER_REVISION="9"
###############################################################################


###############################################################################
export PATH=$QT_DIR/bin:$PATH
export LD_LIBRARY_PATH=$QT_DIR/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$QT_DIR/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=$QT_DIR/qml:$QML2_IMPORT_PATH
# 合成版本号
YVYVIEWER_VERSION="V"$YVYVIEWER_MAJARVERSION$YVYVIEWER_SUBVERSION$YVYVIEWER_REVISION
# 编译
rm -rf .qmake.stash Makefile
qmake -makefile
make
cp -R ./test ./build_release/out/TTFviewer.app/contents/resources/test
cd ./build_release/out
# 打包
macdeployqt TTFviewer.app
otool -L ./TTFviewer.app/Contents/MacOS/TTFviewer
macdeployqt TTFviewer.app -dmg -verbose=2
echo build success!
###############################################################################
Loading

0 comments on commit 687405e

Please sign in to comment.