Skip to content

Merge pull request #179 from silicon-heaven/dependabot/submodules/3rd… #700

Merge pull request #179 from silicon-heaven/dependabot/submodules/3rd…

Merge pull request #179 from silicon-heaven/dependabot/submodules/3rd… #700

Workflow file for this run

name: Build
concurrency:
group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}}
cancel-in-progress: true
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: write
id-token: write
pages: write
env:
HASH_FOR_FILENAMES: ${{github.event.pull_request.head.sha || github.sha}}
jobs:
linux:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
env:
emsdk_cache_dir: emsdk-cache
emscripten_version: 4.0.7
strategy:
fail-fast: false
matrix:
include:
- id: linux-qt6
name: Linux / Qt 6
qt_arch: linux_gcc_64
qt_modules: qtserialport qtwebsockets qtnetworkauth
- id: linux-qt5
name: Linux / Qt 5
use_qt6: OFF
qt_arch: gcc_64
qt_version: 5.15.2
- id: wasm-qt6
name: WebAssembly / Qt 6
qt_arch: wasm_singlethread
qt_modules: qtwebsockets
qt_target: wasm
steps:
- name: Clone the repository
uses: actions/checkout@v6
with:
submodules: true
- name: Setup emsdk cache
if: matrix.id == 'wasm-qt6'
uses: actions/cache@v5
with:
key: emsdk-cache-${{ env.emscripten_version }}
path: ${{ env.emsdk_cache_dir }}
- name: Setup emsdk
if: matrix.id == 'wasm-qt6'
uses: mymindstorm/setup-emsdk@v16
with:
version: ${{ env.emscripten_version }}
actions-cache-folder: ${{ env.emsdk_cache_dir }}
- name: Setup CMake
uses: ./.github/actions/cmake
with:
use_qt6: ${{ matrix.use_qt6 || 'ON' }}
qt_version: ${{ matrix.qt_version || '6.10.1' }}
qt_arch: ${{ matrix.qt_arch }}
qt_target: ${{ matrix.qt_target || 'desktop' }}
qt_modules: ${{ matrix.qt_modules || '' }}
additional_cmake_args: -DCMAKE_INSTALL_PREFIX='${{ github.workspace }}/install/usr'
- name: Build
run: cmake --build '${{ github.workspace }}/build'
shell: bash
- name: Create AppImage
if: matrix.id != 'wasm-qt6'
uses: ./.github/actions/appimage
with:
use_qt6: ${{ matrix.use_qt6 || 'ON' }}
- name: Consolidate WebAssembly artifacts
if: matrix.id == 'wasm-qt6'
id: wasm-artifacts
run: |
SHVSPY_HASH="$(head -c 7 <<< '${{env.HASH_FOR_FILENAMES}}')"
DIR_NAME="shvspy-wasm-$SHVSPY_HASH"
ARTIFACT_NAME="$DIR_NAME.tar.gz"
mkdir "$DIR_NAME"
cp '${{ github.workspace }}/build/shvspy/'*.{js,wasm,html} "$DIR_NAME"
mv "$DIR_NAME/shvspy.html" "$DIR_NAME/index.html"
cp '${{ github.workspace }}'/distro/shvspy.AppDir/shvspy.svg "$DIR_NAME/qtlogo.svg"
tar --create --verbose --auto-compress --file "$ARTIFACT_NAME" "$DIR_NAME"/*
echo "archive-name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
echo "dir-name=$DIR_NAME" >> "$GITHUB_OUTPUT"
shell: bash
- name: Setup Pages
if: matrix.id == 'wasm-qt6'
uses: actions/configure-pages@v6
- name: Upload Pages artifact
if: matrix.id == 'wasm-qt6'
uses: actions/upload-pages-artifact@v5
with:
path: ${{steps.wasm-artifacts.outputs.dir-name}}/
- name: Upload Pages artifact
if: matrix.id == 'wasm-qt6'
uses: actions/upload-artifact@v7
with:
name: ${{steps.wasm-artifacts.outputs.archive-name}}
path: ${{steps.wasm-artifacts.outputs.archive-name}}
build-static:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container || null }}
defaults:
run:
shell: ${{ matrix.shell || 'bash' }}
strategy:
fail-fast: false
matrix:
include:
- id: linux-qt6-static
name: Linux Static / Qt 6
runner: ubuntu-latest
container: archlinux:latest
cmake_cmd: static-compat-cmake
artifact_ext: ""
additional_cmake_args: |-
-DGLIB2_DEPENDENCIES=-lgobject-2.0;-lgmodule-2.0;-lglib-2.0;-lmount;-lblkid;-lffi
- id: windows-qt6-static
name: Windows Static / Qt 6
runner: windows-latest
shell: msys2 {0}
cmake_cmd: cmake.exe
artifact_ext: ".exe"
additional_cmake_args: |-
-DFREETYPE_DEPENDENCIES=-lbz2;-lharfbuzz;-lfreetype
-DHARFBUZZ_DEPENDENCIES=-lglib-2.0;-lintl;-lws2_32;-lole32;-lwinmm;-lshlwapi;-lm;-lintl;-lm;-lfreetype;-lgraphite2;-lrpcrt4
steps:
- name: Install dependencies (Linux)
if: matrix.id == 'linux-qt6-static'
run: |
tee -a /etc/pacman.conf <<EOF
[ownstuff]
Server = https://ftp.f3l.de/~martchus/\$repo/os/\$arch
Server = https://martchus.dyn.f3l.de/repo/arch/\$repo/os/\$arch
EOF
pacman-key --init
pacman-key --keyserver keyserver.ubuntu.com --recv-keys B9E36A7275FC61B464B67907E06FE8F53CDC6A4C
pacman-key --lsign-key B9E36A7275FC61B464B67907E06FE8F53CDC6A4C
PACKAGES=(
base-devel
ccache
git
ninja
pkgconf
static-compat-cmake
static-compat-fontconfig
static-compat-pkgconf
static-compat-qt6-base
static-compat-qt6-networkauth
static-compat-qt6-serialport
static-compat-qt6-svg
static-compat-qt6-tools
static-compat-qt6-websockets
upx
)
pacman -Syu --noconfirm "${PACKAGES[@]}"
- name: Setup MSYS2 (Windows)
if: matrix.id == 'windows-qt6-static'
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
git
mingw-w64-x86_64-ccache
mingw-w64-x86_64-cmake
mingw-w64-x86_64-harfbuzz
mingw-w64-x86_64-libpng
mingw-w64-x86_64-libwebp
mingw-w64-x86_64-ninja
mingw-w64-x86_64-pcre2
mingw-w64-x86_64-qt6-static
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-vulkan-headers
upx
# This plugin doesn't work well with static linking. libtiff.a does not properly bring its static dependencies.
- name: Remove QTiffPlugin (Windows)
if: matrix.id == 'windows-qt6-static'
run: rm /mingw64/qt6-static/lib/cmake/Qt6Gui/Qt6QTiffPlugin*
- name: Clone the repository
uses: actions/checkout@v6
with:
submodules: true
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.23
with:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.id }}
max-size: 50M
- name: Build
id: static-binary
run: |
WORKSPACE="$GITHUB_WORKSPACE"
if [ "${{ matrix.id }}" = "windows-qt6-static" ]; then
WORKSPACE="$(cygpath -u "$WORKSPACE")"
fi
readarray -t EXTRA_FLAGS <<< "${{ matrix.additional_cmake_args }}"
CMAKE_FLAGS=(
-G Ninja
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DSHVSPY_WITH_WERROR=ON
-DCMAKE_DISABLE_FIND_PACKAGE_harfbuzz=ON
"${EXTRA_FLAGS[@]}"
)
'${{ matrix.cmake_cmd }}' -S "$WORKSPACE" -B "$WORKSPACE/build" "${CMAKE_FLAGS[@]}"
SHVSPY_HASH="$(head -c 7 <<< '${{env.HASH_FOR_FILENAMES}}')"
cmake --build "$WORKSPACE/build"
NEW_FILENAME="shvspy-static-$SHVSPY_HASH${{matrix.artifact_ext}}"
mv "$WORKSPACE/build/shvspy/shvspy${{ matrix.artifact_ext }}" "$NEW_FILENAME"
echo "new-filename=$NEW_FILENAME" >> "$GITHUB_OUTPUT"
strip "$NEW_FILENAME"
UPX_ARGS=()
# Only use best for the master releases, as it takes quite a while (especially on Windows).
if [[ '${{github.ref}}' = 'refs/heads/master' ]]; then
UPX_ARGS+=(--best)
echo Enabling UPX --best compression.
fi
upx "${UPX_ARGS[@]}" "$NEW_FILENAME"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{steps.static-binary.outputs.new-filename}}
path: ${{steps.static-binary.outputs.new-filename}}
windows-qt6:
name: Windows / Qt 6
runs-on: windows-latest
steps:
- name: Clone the repository
uses: actions/checkout@v6
with:
submodules: true
- name: Setup MinGW cache
uses: actions/cache@v5
with:
key: x86_64-13.1.0-release-posix-seh-msvcrt-rt_v11-rev1.7z
path: ${{github.workspace}}/x86_64-13.1.0-release-posix-seh-msvcrt-rt_v11-rev1.7z
- name: Install MinGW
# WinMain apps fail to link with the default MinGW compiler on GH actions. I suspect it is because Qt (since
# 6.8) uses msvcrt, but GH Actions uses the ucrt version. Furthermore, GH Actions might have an older MinGW
# version which might make things even less compatible. I don't know the exact reasoning. This works, and that's
# all that matters for me.
run: |
MINGW_FILE_NAME='x86_64-13.1.0-release-posix-seh-msvcrt-rt_v11-rev1.7z'
if ! [[ -f '${{github.workspace}}'/"$MINGW_FILE_NAME" ]]; then
curl -L "https://github.com/niXman/mingw-builds-binaries/releases/download/13.1.0-rt_v11-rev1/$MINGW_FILE_NAME" -o '${{github.workspace}}'/"$MINGW_FILE_NAME"
fi
7z x '${{github.workspace}}'/"$MINGW_FILE_NAME"
echo 'CC=${{github.workspace}}/mingw64/bin/gcc.exe' >> "$GITHUB_ENV"
echo 'CXX=${{github.workspace}}/mingw64/bin/g++.exe' >> "$GITHUB_ENV"
shell: bash
- name: 'Install Inno Setup'
run: |
choco install innosetup -y
- name: Setup CMake
uses: ./.github/actions/cmake
with:
qt_arch: win64_mingw
use_qt6: ON
qt_modules: qtserialport qtwebsockets qtnetworkauth
additional_cmake_args: -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/install'
- name: Build
run: cmake --build '${{github.workspace}}/build'
- name: Install
run: cmake --install '${{github.workspace}}/build'
- name: Run windeployqt
run: windeployqt -networkauth -websockets -serialport '${{github.workspace}}/install/bin/shvspy.exe'
- name: Copy MinGW runtime libraries
# windeployqt is unable to copy those, because it looks for them next to where g++.exe is. On the GitHub runner,
# they are in a different directory.
run: cp "${{github.workspace}}"/mingw64/bin/{libstdc++-6.dll,libgcc_s_seh-1.dll,libwinpthread-1.dll} '${{github.workspace}}/install/bin'
shell: bash
- name: Get app version
run: echo "VERSION=$(grep APP_VERSION shvspy/src/appversion.h | cut -d\" -f2)" >> "$GITHUB_ENV"
shell: bash
- name: Create installer
id: installer
run: |
iscc "-DBUILD_DIR=${{github.workspace}}/install" "-DVERSION=${{env.VERSION}}" shvspy/shvspy.iss
SHVSPY_HASH="$(head -c 7 <<< '${{env.HASH_FOR_FILENAMES}}')"
cmake --build "${{github.workspace}}/build"
NEW_FILENAME="shvspy-$SHVSPY_HASH-setup.exe"
mv '${{github.workspace}}'/install/_inno/shvspy/shvspy-*-setup.exe "$NEW_FILENAME"
echo "new-filename=$NEW_FILENAME" >> "$GITHUB_OUTPUT"
shell: bash
- name: Upload installer
uses: actions/upload-artifact@v7
with:
name: ${{steps.installer.outputs.new-filename}}
path: ${{steps.installer.outputs.new-filename}}
deploy-github-pages:
name: Deploy GitHub Pages
if: github.ref == 'refs/heads/master'
needs: [linux]
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v5
create-nightly-release:
name: Create nightly
if: github.ref == 'refs/heads/master'
needs: [linux, build-static, windows-qt6]
runs-on: ubuntu-latest
steps:
# Needed for action-create-tag
- name: Checkout code
uses: actions/checkout@v6
- uses: rickstaa/action-create-tag@v1
with:
tag: "nightly"
force_push_tag: true
- name: Consolidate artifacts
uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: Delete previous nightly release
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run:
# Deleting the release refreshes the release date.
gh release delete nightly
- name: Release
uses: softprops/action-gh-release@v3
with:
name: Nightly
tag_name: nightly
fail_on_unmatched_files: true
body: |
The latest and greatest ShvSpy.
This is a nightly release. If you find any bugs, please report them to the repository's issue tracker.
files: |
shvspy-*
nix:
name: NixOS / Qt 6
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: true
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build
run: nix --experimental-features 'nix-command flakes' build -L "git+file://$(pwd)?submodules=1&rev=$(git rev-parse HEAD)"
- name: Flake check
run: nix --experimental-features 'nix-command flakes' flake check "git+file://$(pwd)?submodules=1&rev=$(git rev-parse HEAD)"
- name: Format
run: nix --experimental-features 'nix-command flakes' fmt . && git diff --exit-code
check-version-bump:
name: Check version bump
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Check if appversion.h was changed
id: version-check
continue-on-error: ${{startsWith(github.head_ref, 'dependabot/')}}
run: |
PREVIOUS_COMMIT="${{github.event.pull_request.base.sha || github.event.before}}"
git fetch origin "$PREVIOUS_COMMIT"
echo Comparing version bump against "$PREVIOUS_COMMIT"
DEFAULT_BRANCH_VERSION="$(git show "$PREVIOUS_COMMIT:shvspy/src/appversion.h" | grep 'APP_VERSION' | head -n1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
CURRENT_BRANCH_VERSION="$(git show "HEAD:shvspy/src/appversion.h" | grep 'APP_VERSION' | head -n1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
if [[ "$DEFAULT_BRANCH_VERSION" = "$CURRENT_BRANCH_VERSION" ]]; then
echo "Error: No version bump detected ($DEFAULT_BRANCH_VERSION" = "$CURRENT_BRANCH_VERSION)."
exit 1
else
echo Version bump detected: "$DEFAULT_BRANCH_VERSION -> $CURRENT_BRANCH_VERSION"
fi
- name: Checkout code
if: steps.version-check.outcome == 'failure'
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{github.head_ref}}
- name: Bump version
if: steps.version-check.outcome == 'failure'
run: |
[[ "$(grep 'APP_VERSION' shvspy/src/appversion.h | head -n1)" =~ ([0-9]+\.[0-9]+\.)([0-9]+) ]]
NEW_VERSION="${BASH_REMATCH[1]}$((BASH_REMATCH[2] + 1))"
echo Bumping "${BASH_REMATCH[0]} -> $NEW_VERSION"
sed -i "s/${BASH_REMATCH[0]}/$NEW_VERSION/" shvspy/src/appversion.h
git diff
git config --global user.name "Login will be determined by the Github API based on the creator of the token"
git config --global user.email ""
git commit -am '[dependabot-skip] Bump version'
- name: Push changes
if: steps.version-check.outcome == 'failure'
uses: Asana/push-signed-commits@v1
with:
github-token: ${{ secrets.DEPENDABOT_GITHUB_TOKEN }}
local_branch_name: ${{github.head_ref}}
remote_branch_name: ${{github.head_ref}}
tag-release:
name: Tag and release
if: github.ref == 'refs/heads/master'
needs: [linux, windows-qt6, build-static, check-version-bump]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get version
id: get-version
run: |
version="$(git show "HEAD:shvspy/src/appversion.h" | grep 'APP_VERSION' | head -n1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create and push tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.get-version.outputs.version }}
- name: Consolidate artifacts
uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: Rename release artifacts
run: |
set -x
find .
SHVSPY_HASH="$(head -c 7 <<< '${{env.HASH_FOR_FILENAMES}}')"
for f in shvspy-*; do
[[ $f == *"$SHVSPY_HASH"* ]] || continue
mv -- "$f" "${f//"$SHVSPY_HASH"/'${{ steps.get-version.outputs.version }}'}"
done
find .
shell: bash
- name: Release
uses: softprops/action-gh-release@v3
with:
name: shvspy ${{ steps.get-version.outputs.version }}
tag_name: ${{ steps.get-version.outputs.version }}
fail_on_unmatched_files: true
body: |
shvspy ${{ steps.get-version.outputs.version }}
If you find any bugs, please test with the nightly version. If the bug persists, report them to the repository's issue tracker.
files: |
shvspy-*${{ steps.get-version.outputs.version }}*