CI/CD #23
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: CI/CD | |
on: | |
push: | |
branches: [ master, develop ] | |
pull_request: | |
branches: [ master ] | |
create: null | |
jobs: | |
main_build: | |
name: ${{ matrix.package_suffix }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
qt: | |
- 6.6.2 | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
build_type: | |
- Release | |
include: | |
- qt_tools: tools_ninja | |
qt_modules: | |
cmake_cli_arg: 'OFF' | |
- os: ubuntu-latest | |
package_extension: 'tar.xz' | |
package_suffix: 'linux64' | |
- os: macos-latest | |
package_extension: 'dmg' | |
package_suffix: 'macos' | |
cmake_extra_args: "-DCMAKE_OSX_ARCHITECTURES=\"arm64;x86_64\"" | |
- os: windows-latest | |
package_extension: 'zip' | |
package_suffix: 'win64' | |
win_arch: "x64" | |
qt_arch: win64_msvc2019_64 | |
cmake_extra_args: '-DZLIB_ROOT=C:/zlib' | |
qt_tools: tools_ninja, tools_cmake | |
env: | |
qt_installation_path: ${{ github.workspace }} | |
zlib_path: ${{ github.workspace }}/../zlib-git | |
zlib_build_path: ${{ github.workspace }}/../build-zlib-git | |
zlib_installation_path: C:/zlib | |
zlib_version: "1.3.1" | |
lz4_path: ${{ github.workspace }}/../lz4-git | |
lz4_build_path: ${{ github.workspace }}/../build-lz4-git | |
lz4_installation_path: ${{ github.workspace }}/../lz4 | |
lz4_version: "dev" | |
deling_build_path: ${{ github.workspace }}/../build-deling | |
deling_installation_path: ${{ github.workspace }}/../installation-deling | |
deling_appbundle_path: ${{ github.workspace }}/../appbundle-deling | |
CMAKE_GENERATOR: Ninja | |
CMAKE_BUILD_TYPE: ${{ matrix.build_type }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Env Script (Windows) | |
uses: ilammy/msvc-dev-cmd@v1 | |
if: runner.os == 'Windows' | |
with: | |
arch: ${{ matrix.win_arch }} | |
- name: Install Qt | |
uses: jurplel/[email protected] | |
with: | |
dir: ${{ env.qt_installation_path }} | |
arch: ${{ matrix.qt_arch }} | |
version: ${{ matrix.qt }} | |
cache: true | |
tools: ${{ matrix.qt_tools }} | |
modules: ${{ matrix.qt_modules }} | |
- name: Configure env | |
shell: bash | |
run: | | |
QT_MAJOR_VERSION=$(echo "${{ matrix.qt }}" | sed -E 's/^([0-9]+)\..*/\1/') | |
QT_DIR=$(eval 'echo $Qt'"$QT_MAJOR_VERSION"'_DIR') | |
echo "$IQTA_TOOLS/Ninja" >> $GITHUB_PATH | |
echo "$IQTA_TOOLS/CMake_64/bin" >> $GITHUB_PATH | |
echo "QT_MAJOR_VERSION=$QT_MAJOR_VERSION" >> $GITHUB_ENV | |
echo "QT_DIR=$QT_DIR" >> $GITHUB_ENV | |
- name: Set prerelease string | |
if: github.event.ref_type != 'tag' | |
shell: bash | |
run: | | |
echo "PRERELEASE_STRING= unstable build" >> $GITHUB_ENV | |
- name: Cache Zlib | |
id: cache-zlib | |
if: runner.os == 'Windows' | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.zlib_installation_path }} | |
key: ${{ runner.os }}${{ matrix.win_arch }}-zlib-${{ env.zlib_version}} | |
- name: Install Zlib | |
if: (runner.os == 'Windows') && (steps.cache-zlib.outputs.cache-hit != 'true') | |
run: | | |
git clone -q --depth 1 --single-branch --branch=v${{ env.zlib_version }} https://github.com/madler/zlib ${{ env.zlib_path }} | |
cmake -S${{ env.zlib_path }} -B${{ env.zlib_build_path }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX=${{ env.zlib_installation_path }} | |
cmake --build ${{ env.zlib_build_path }} --target install -j3 | |
- name: Cache lz4 | |
id: cache-lz4 | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.lz4_installation_path }} | |
key: ${{ runner.os }}${{ matrix.win_arch }}-lz4-${{ env.lz4_version}} | |
- name: Install lz4 | |
if: steps.cache-lz4.outputs.cache-hit != 'true' | |
run: | | |
git clone -q --depth 1 --single-branch --branch=${{ env.lz4_version }} https://github.com/lz4/lz4 ${{ env.lz4_path }} | |
cmake -S${{ env.lz4_path }}/build/cmake -B${{ env.lz4_build_path }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX=${{ env.lz4_installation_path }} -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON -DLZ4_BUILD_LEGACY_LZ4C:BOOL=OFF -DLZ4_POSITION_INDEPENDENT_LIB:BOOL=OFF -DLZ4_BUILD_CLI:BOOL=OFF ${{ matrix.cmake_extra_args }} | |
cmake --build ${{ env.lz4_build_path }} --target install -j3 | |
- name: Download linuxdeployqt | |
if: runner.os == 'Linux' | |
run: | | |
wget -qc "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" | |
wget -qc "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" | |
export VERSION=continuous | |
chmod a+x linuxdeploy*.AppImage | |
mv linuxdeploy-plugin-qt-*.AppImage $QT_DIR/bin/linuxdeploy-plugin-qt | |
mv linuxdeploy-*.AppImage $QT_DIR/bin/linuxdeploy | |
- name: Build Deling | |
id: main_build | |
run: | | |
cmake -B ${{ env.deling_build_path }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX=${{ env.deling_installation_path }} -DPRERELEASE_STRING="$PRERELEASE_STRING" -Dlz4_DIR=${{ env.lz4_installation_path }}/lib/cmake/lz4 ${{ matrix.cmake_extra_args }} | |
cmake --build ${{ env.deling_build_path }} --target package -j3 | |
- name: Build AppImage (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo add-apt-repository -y universe | |
sudo apt install -y libfuse2 libxkbcommon-x11-0 libxcb-cursor0 | |
cmake --build ${{ env.deling_build_path }} --target install -j3 | |
mkdir -p ${{env.deling_appbundle_path}}/usr/share/deling/translations | |
cp ${{env.deling_installation_path}}/share/deling/translations/*.qm ${{env.deling_appbundle_path}}/usr/share/deling/translations/ | |
export VERSION=continuous | |
export PATH=$PATH:${{ env.qt_installation_path }}/Qt/${{ matrix.qt }}/gcc_64/libexec | |
linuxdeploy --appdir="${{ env.deling_appbundle_path }}" --plugin=qt --output appimage \ | |
-e "${{ env.deling_installation_path }}"/bin/Deling \ | |
-d "${{ env.deling_installation_path }}"/share/applications/io.github.myst6re.deling.desktop \ | |
-i "${{ env.deling_installation_path }}"/share/icons/hicolor/256x256/apps/io.github.myst6re.deling.png | |
mv *.AppImage deling-continuous-${{ matrix.package_suffix }}.AppImage | |
- name: Prepare Upload | |
shell: bash | |
run: mv ../build-deling/*.${{ matrix.package_extension }} deling-continuous-${{ matrix.package_suffix }}.${{ matrix.package_extension }} | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-${{ matrix.package_suffix }} | |
path: ${{ github.workspace }}/deling-continuous-*.* | |
pre_release_assets: | |
name: Pre-Release | |
needs: [main_build] | |
if: (github.event.ref_type != 'tag') && (github.ref == 'refs/heads/develop') | |
concurrency: pre-release-${{ github.ref }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Files | |
uses: actions/download-artifact@v4 | |
- name: Deploy Package | |
uses: crowbarmaster/GH-Automatic-Releases@latest | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "continuous" | |
prerelease: true | |
title: "Unstable Build" | |
files: | | |
artifact-*/* | |
release_assets: | |
name: Release | |
needs: [main_build] | |
if: github.event.ref_type == 'tag' | |
concurrency: release-${{ github.ref }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Files | |
uses: actions/download-artifact@v4 | |
- name: Prepare Upload | |
shell: bash | |
run: find . -type f -name 'deling-continuous-*' -exec bash -c 'mv "{}" $(echo {} | sed 's/continuous-//')' ';' | |
- name: Deploy Package | |
uses: crowbarmaster/GH-Automatic-Releases@latest | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
prerelease: false | |
title: ${{ github.event.ref }} | |
files: | | |
artifact-*/* | |