修改 action; #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CMake Build | |
on: | |
# push代码时触发workflow | |
push: | |
paths-ignore: # 下列文件的变更不触发部署,可以自行添加 | |
- '.github/workflows/clean_cache.yml' | |
- '.github/workflows/delete_workflow.yml' | |
- '.github/workflows/qmake.yml' | |
- '.github/workflows/readme.yml' | |
- '.github/workflows/toolchain.yml' | |
- 'doc/**' | |
- '.clang-*' | |
- '.gitignore' | |
- 'LICENSE' | |
- 'README*' | |
pull_request: | |
paths-ignore: # 下列文件的变更不触发部署,可以自行添加 | |
- '.github/workflows/clean_cache.yml' | |
- '.github/workflows/delete_workflow.yml' | |
- '.github/workflows/qmake.yml' | |
- '.github/workflows/readme.yml' | |
- '.github/workflows/toolchain.yml' | |
- 'doc/**' | |
- '.clang-*' | |
- '.gitignore' | |
- 'LICENSE' | |
- 'README*' | |
jobs: | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- windows-latest | |
- macos-latest | |
- ubuntu-latest | |
qt_ver: | |
- 6.6.1 | |
build_type: | |
- "RelWithDebInfo" | |
generators: | |
- "Ninja" | |
steps: | |
- name: Restore windows vcpkg | |
if: startsWith(matrix.os, 'windows') | |
uses: actions/cache/restore@v3 | |
with: | |
path: C:\vcpkg\installed | |
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }} | |
- name: Restore macos or ubuntu vcpkg | |
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') | |
uses: actions/cache/restore@v3 | |
with: | |
path: /usr/local/share/vcpkg/installed | |
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }} | |
- name: Install dependencies on windows | |
if: startsWith(matrix.os, 'windows') | |
shell: bash | |
run: | | |
choco install ninja | |
ninja --version | |
cmake --version | |
vcpkg install breakpad --triplet x64-windows | |
- name: Install dependencies on macos | |
if: startsWith(matrix.os, 'macos') | |
shell: bash | |
run: | | |
brew install ninja pkg-config | |
ninja --version | |
cmake --version | |
clang --version | |
vcpkg install breakpad --triplet x64-osx | |
- name: Install dependencies on ubuntu | |
if: startsWith(matrix.os, 'ubuntu') | |
shell: bash | |
run: | | |
sudo apt-get update | |
sudo apt-get install ninja-build build-essential libgl1-mesa-dev | |
ninja --version | |
cmake --version | |
gcc --version | |
vcpkg install breakpad --triplet x64-linux | |
- name: Install Qt | |
uses: jurplel/install-qt-action@v3 | |
with: | |
version: ${{ matrix.qt_ver }} | |
install-deps: 'true' | |
modules: 'qt5compat qtserialport qtnetworkauth qtmultimedia qtimageformats' | |
cache: 'true' | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Enable Developer Command Prompt | |
if: startsWith(matrix.os, 'windows') | |
uses: ilammy/[email protected] | |
with: | |
arch: amd64 | |
- name: Configure windows | |
if: startsWith(matrix.os, 'windows') | |
shell: bash | |
run: | | |
cmake \ | |
-S . \ | |
-B ./build \ | |
-DCMAKE_C_COMPILER=cl \ | |
-DCMAKE_CXX_COMPILER=cl \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-G "${{ matrix.generators }}" \ | |
-DCMAKE_INSTALL_PREFIX:PATH=instdir | |
- name: Configure macos or ubuntu | |
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') | |
shell: bash | |
run: | | |
cmake \ | |
-S . \ | |
-B ./build \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-G "${{ matrix.generators }}" \ | |
-DCMAKE_INSTALL_PREFIX:PATH=instdir | |
- name: Build | |
shell: bash | |
run: | | |
cmake --build ./build --config ${{ matrix.build_type }} | |
- name: Deploy Windows | |
if: startsWith(matrix.os, 'windows') | |
shell: bash | |
run: | | |
cd ./bin-64/${{ matrix.build_type }} | |
# deploy contains plugins | |
cp -rf ./plugins/* . | |
files=$(find . -maxdepth 1 -type f -printf '%P\n') | |
for file in $files; | |
do | |
if [[ $file == *.exe || $file == *.dll ]]; then | |
windeployqt --force --no-translations --compiler-runtime $file | |
fi | |
done | |
rm -rf *plugin.dll | |
ls -l | |
- name: Deploy macos | |
if: startsWith(matrix.os, 'macos') | |
shell: bash | |
run: | | |
macdeployqt ./bin-64/${{ matrix.build_type }}/Qt-App.app -always-overwrite | |
ls -l ./bin-64/${{ matrix.build_type }}/Qt-App.app/Contents/Frameworks | |
rm -rf ./bin-64/${{ matrix.build_type }}/plugins | |
rm -f ./bin-64/${{ matrix.build_type }}/CrashReport | |
rm -f ./bin-64/${{ matrix.build_type }}/*.dylib | |
# make dmg | |
pip3 install dmgbuild | |
dmgbuild -s ./packaging/macos/Qt-App.dmgbuild.py "Qt-App" ./bin-64/${{ matrix.build_type }}/Qt-App.dmg | |
- name: Deploy ubuntu | |
if: startsWith(matrix.os, 'ubuntu') | |
shell: bash | |
run: | | |
sudo add-apt-repository universe | |
sudo apt update | |
sudo apt install libfuse2 libxcb-cursor0 | |
wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" | |
chmod a+x linuxdeployqt-continuous-x86_64.AppImage | |
cp -f ./packaging/ubuntu/Qt-App.desktop ./bin-64/${{ matrix.build_type }}/Qt-App.desktop | |
cp -f ./resource/icon/app.png ./bin-64/${{ matrix.build_type }}/app.png | |
cp -f ./bin-64/${{ matrix.build_type }}/plugins/* ./bin-64/${{ matrix.build_type }} | |
so_files=$(find ./bin-64/${{ matrix.build_type }} -maxdepth 1 -name "*.so" -printf '%P\n') | |
for so_file in $so_files; | |
do | |
./linuxdeployqt-continuous-x86_64.AppImage \ | |
./bin-64/${{ matrix.build_type }}/$so_file \ | |
-qmake=${{ env.Qt6_DIR }}/bin/qmake \ | |
-always-overwrite -no-translations \ | |
-unsupported-allow-new-glibc | |
done | |
rm -f ./bin-64/${{ matrix.build_type }}/AppRun | |
./linuxdeployqt-continuous-x86_64.AppImage \ | |
./bin-64/${{ matrix.build_type }}/Qt-App \ | |
-executable=./bin-64/${{ matrix.build_type }}/CrashReport \ | |
-qmake=${{ env.Qt6_DIR }}/bin/qmake \ | |
-always-overwrite -no-translations \ | |
-unsupported-allow-new-glibc \ | |
-appimage | |
rm linuxdeployqt-continuous-x86_64.AppImage | |
rm -f ./bin-64/${{ matrix.build_type }}/*.so | |
mv *.AppImage ./bin-64/${{ matrix.build_type }} | |
- name: 7z package | |
shell: bash | |
run: | | |
ls -al ./bin-64/${{ matrix.build_type }} | |
7z a -t7z -r -mx=9 -mmt Qt-App-${{ matrix.os }}-${{ matrix.build_type }}.7z ./bin-64/${{ matrix.build_type }} | |
- name: Upload packages | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }}-${{ matrix.build_type }} | |
path: Qt-App-${{ matrix.os }}-${{ matrix.build_type }}.7z | |
release: | |
name: Release | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download packages | |
uses: actions/download-artifact@v3 | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: false | |
prerelease: false | |
generate_release_notes: true | |
files: | | |
*.7z |