chocolate是一个类似于基于Debian系统的包管理器apt,
apt install
等价于choco install
,你可以搜索你想要安装的包。
- innosetup 这是一个用于打包的编译器,主要用于发布Windows平台的安装程序,此类程序发布软件据我之前的了解就是一个压缩程序而已。innosetup是基于iss文件进行规则指定的,我们通过命令行的方式进行指定和安装。
- VIP用户可以让多个jobs任务并行执行,但是如果你是fork的VIP仓库,你只能串行执行程序。
- Travis CI的生命周期本身有限,考虑条件执行的同时,尽量采用原生的脚本进行逻辑判断。
- Cache缓存确实可以避免每一次进行安装依赖,但是你的脚本逻辑中一定要考虑到提前终止编译导致某个缓存目录导致的文件不一致问题。
- 添加GITHUB_TOKEN的时候请注意一定要像下面一样配置,此处的token设置路径参考下图,请注意**.travis.yml**中部署的token设置一定是
api_key: $GITHUB_TOKEN
,刚开始接触的时候,很多网站就是设置token: $GTIHUB_TOKEN
,这样子你将在Travis 3.0版本中面临invalid option: "--token="
,网上有很多误导说没有设置Travis仓库中的env variable,但是实际上我尝试在deploy模块设置edge: true
api_key: secure: $GITHUB_TOKEN
依旧是老样子。同时一定要注意github token一定要有write pacakage之类的权限,才能让git push origin v4.2.1这个tag生效并发布。
你可能需要为我们的C++项目实现多个平台编译的脚本以及相应的虚拟环境,Linux amd x86_64|Linux arm64采用Miniconda3进行虚拟环境配置。
branches:
only:
- master
- /^v.*$/
env:
- APP_VERSION=`git describe --abbrev=0 --tags`
jobs:
include:
- os: linux
arch: arm64-graviton2
virt: vm
sudo: false
compiler: gcc
language: cpp
group: edge
dist: focal
cache:
directories:
- $HOME/deps
# 向bash脚本中传递参数
install:
- "bash tools/travis-scripts/minicondaDeps.sh $HOME/deps https://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Linux-aarch64.sh"
script:
- "bash tools/build-linux-arm64.sh"
before_deploy:
- mv build/AppDir LinSAR-linux-arm64-$APP_VERSION
- tar zcvf LinSAR-linux-arm64-$APP_VERSION.tar.gz LinSAR-linux-arm64-$APP_VERSION
deploy:
provider: releases # 操作 repo 的 releases 页面
api_key: $GITHUB_TOKEN # 使用github token验证身份,进行操作
file:
- LinSAR-linux-arm64-$APP_VERSION # 上传的文件
skip_cleanup: true # 要上传文件到 release,所以不能自动清除
on:
tags: true # 只有打 tag 时才运行
判断缓存是否存在的逻辑不能在.travis.yml文件中,推荐的做法是在sh脚本文件中完成相应的判断
if [ -d "$1" && -f "$HOME/deps/miniconda/etc/profile.d/conda.sh" ];then
# Useful for debugging any issues with conda
source "$HOME/deps/miniconda/etc/profile.d/conda.sh"
conda info -a
conda activate openblas
else
rm $HOME/deps -rf
wget "$2" -O miniconda.sh
bash miniconda.sh -b -p $HOME/deps/miniconda
source "$HOME/deps/miniconda/etc/profile.d/conda.sh"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
# Useful for debugging any issues with conda
conda info -a
# Replace dep1 dep2 ... with your dependencies
conda env create -n openblas -f tools/link-linux-arm64.yml
conda activate openblas
fi
rm -rf build
mkdir build
cd build
# download and build linuxdeploy qt
git clone https://github.com/probonopd/linuxdeployqt.git
cd linuxdeployqt
cmake -GNinja .
ninja
mv tools/linuxdeployqt/linuxdeployqt ../linuxdeployqt-build
cd ..
# Build link
cmake -GNinja \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DCMAKE_SYSROOT=$CONDA_PREFIX/$HOST/sysroot \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
../
cmake --build . --target install --config Release
# Deploy
export LD_LIBRARY_PATH=".../AppDir/usr/lib/:$CONDA_PREFIX/lib:./lib"
cp $CONDA_PREFIX/lib/libcblas.so.3 ./AppDir/usr/lib/
# Deploy linux binaries
./linuxdeployqt-build ./AppDir/usr/bin/linsar -unsupported-allow-new-glibc -bundle-non-qt-libs -no-copy-copyright-files -qmake=$CONDA_PREFIX/bin/qmake -verbose=2
# ./linuxdeployqt-build
# Second: Must remove X11 server libs manually
rm AppDir/usr/lib/libX11-xcb*
rm AppDir/usr/lib/libXau*
rm AppDir/usr/lib/libxcb*
rm AppDir/usr/lib/libXdmcp*
rm AppDir/usr/lib/libxkbcommon*
rm AppDir/usr/lib/libXrender*
rm AppDir/usr/lib/libXext*
cd ..
rm -rf build
mkdir build
cd build
# download and build linuxdeploy qt
git clone https://github.com/probonopd/linuxdeployqt.git
cd linuxdeployqt
cmake -GNinja .
ninja
mv tools/linuxdeployqt/linuxdeployqt ../linuxdeployqt-build
cd ..
# Build
cmake -GNinja \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DCMAKE_SYSROOT=$CONDA_PREFIX/$HOST/sysroot \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
../
export DESTDIR=AppDir
cmake --build . --target install --config Release
# Deploy link
export LD_LIBRARY_PATH=".../AppDir/usr/lib/:$CONDA_PREFIX/lib:./lib"
cp $CONDA_PREFIX/lib/libcblas.so.3 ./AppDir/usr/lib/
cp $CONDA_PREFIX/lib/libstdc++.so.6 ./AppDir/usr/lib/
cp $CONDA_PREFIX/lib/libz.so.1 ./AppDir/usr/lib/
cp $CONDA_PREFIX/lib/libcom_err.so.3 ./AppDir/usr/lib/
# Deploy linux binaries
./linuxdeployqt-build ./AppDir/usr/bin/linsar -unsupported-allow-new-glibc -bundle-non-qt-libs -no-copy-copyright-files -qmake=$CONDA_PREFIX/bin/qmake -verbose=2
# ./linuxdeployqt-build
# Second: Must remove X11 server libs manually
rm AppDir/usr/lib/libX11-xcb*
rm AppDir/usr/lib/libXau*
rm AppDir/usr/lib/libxcb*
rm AppDir/usr/lib/libXdmcp*
rm AppDir/usr/lib/libxkbcommon*
rm AppDir/usr/lib/libXrender*
rm AppDir/usr/lib/libXext*
cd ..
rm -rf build
mkdir build
cd build
# define the PREFIX_PATH
# 下面这个一定是该变量,由于Travis虚拟容器中是如此
PREFIX_PATH="C:/tools/msys64/ucrt64"
cmake -GNinja \
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
-DCMAKE_MAKE_PROGRAM=ninja \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
-DH2O_BUILD_SHARED=ON \
-DH2O_BUILD_TEST=ON \
-DH2O_VERSION_NAME=linsar \
../
cmake --build . --target install --config Release
# download CQtDeployer using wget and rename it to CQtDeployer.zip
wget https://github.com/QuasarApp/CQtDeployer/releases/download/v1.6.2285/CQtDeployer_1.6.2285.1507045_Windows_AMD64.zip -O CQtDeployer.zip
# unzip CQtDeployer into ./CQtDeployer using unzip
unzip CQtDeployer.zip -d ./CQtDeployer
./CQtDeployer/CQtDeployer.exe -bin ./install/bin/ -libDir $PREFIX_PATH/bin -qmake $PREFIX_PATH/bin/qmake.exe -targetDir ./install/bin/ -recursiveDepth 30
# download vcredist,
cd ..
language: cpp
branches:
only:
- master
- /^v.*$/
compiler:
- gcc
env:
- APP_VERSION=`git describe --abbrev=0 --tags`
# jobs任务,按照job
jobs:
include:
- os: linux
arch: arm64-graviton2
virt: vm
group: edge
dist: focal
install:
- wget https://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Linux-aarch64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
# Replace dep1 dep2 ... with your dependencies
- conda env create -n openblas -f tools/link-linux-arm64.yml
- conda activate openblas
script:
- "bash tools/build-linux-arm64.sh"
before_deploy:
- mv build/AppDir LinSAR-linux-arm64-$APP_VERSION
- tar zcvf LinSAR-linux-arm64-$APP_VERSION.tar.gz LinSAR-linux-arm64-$APP_VERSION
deploy:
provider: releases # 操作 repo 的 releases 页面
api_key: $GITHUB_TOKEN # 使用github token验证身份,进行操作
file:
- LinSAR-linux-arm64-$APP_VERSION # 上传的文件
skip_cleanup: true # 要上传文件到 release,所以不能自动清除
on:
tags: true # 只有打 tag 时才运行
- os: windows
before_install:
- |-
case $TRAVIS_OS_NAME in
windows)
[[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
choco uninstall -y mingw
choco upgrade --no-progress -y msys2
export msys2='cmd //C RefreshEnv.cmd '
export msys2+='& set MSYS=winsymlinks:nativestrict '
export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
export ucrt64="$msys2 -ucrt64 -full-path -here -c "\"\$@"\" --"
export msys2+=" -msys2 -c "\"\$@"\" --"
## Install more MSYS2 packages from https://packages.msys2.org/base here
export PATH=/C/tools/msys64/mingw64/bin:$PATH
export PATH=/C/tools/msys64/ucrt64/bin:$PATH
export MAKE=mingw32-make # so that Autotools can find it
;;
esac
install:
# - choco install -y visualstudio2019buildtools --package-parameters "--includeRecommended --includeOptional --passive"
# - choco install -y visualstudio2019-workload-vctools --package-parameters "--includeRecommended --includeOptional --passive"
- "bash tools/link-mingw-64.sh"
script:
- "bash tools/build-mingw-64.sh"
before_cache:
- |-
case $TRAVIS_OS_NAME in
windows)
# https://unix.stackexchange.com/a/137322/107554
$ucrt64 pacman --sync --clean --noconfirm
;;
esac
- rm -rf $HOME/AppData/Local/Temp/chocolatey
- rm -rf ${TRAVIS_HOME}/.casher
cache:
directories:
- $HOME/AppData/Local/Temp/chocolatey
- /C/tools/msys64
before_deploy:
- mv build/install LinSAR-Win-$APP_VERSION
- 7z a LinSAR-Win-$APP_VERSION.7z LinSAR-Win-$APP_VERSION/* -r
deploy:
provider: releases # 操作 repo 的 releases 页面
api_key: $GITHUB_TOKEN # 使用github token验证身份,进行操作
file:
- LinSAR-Win-$APP_VERSION.7z # 上传的文件
skip_cleanup: true # 要上传文件到 release,所以不能自动清除
on:
tags: true # 只有打 tag 时才运行
- os: linux
arch: amd64
dist: bionic
install:
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
# Replace dep1 dep2 ... with your dependencies
- conda env create -n openblas -f tools/link-linux-64.yml
- conda activate openblas
script:
- "bash tools/build-linux-64.sh"
before_deploy:
- mv build/AppDir LinSAR-linux-amd64-$APP_VERSION
- tar zcvf LinSAR-linux-amd64-$APP_VERSION.tar.gz LinSAR-linux-amd64-$APP_VERSION
deploy:
provider: releases # 操作 repo 的 releases 页面
api_key: $GITHUB_TOKEN # 使用github token验证身份,进行操作
file:
- LinSAR-linux-amd64-$APP_VERSION.tar.gz # 上传的文件
skip_cleanup: true # 要上传文件到 release,所以不能自动清除
on:
tags: true # 只有打 tag 时才运行
# 打包消息通知
notifications:
recipients:
- 2997534654@qq.com
on_success: change # default: change
on_failure: always # default: always