Paulchen-Panther 5b6b2dc516 update workflow
2025-02-22 09:29:07 +01:00

263 lines
10 KiB
YAML

name: GitHub Qt5/6 Builds
on:
# Reusable from push_pull.yml
workflow_call:
inputs:
qt_version:
type: string
description: Build with this Qt version
default: '5'
required: false
event_name:
type: string
description: The event name
default: ''
required: false
pull_request_number:
type: string
description: The corresponding PR number
default: ''
required: false
publish:
type: boolean
description: Package publishing
default: false
required: false
jobs:
######################
###### Linux #########
######################
Linux:
name: 🐧 ${{ matrix.os.description }}
runs-on: ${{ matrix.os.architecture[0] == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
strategy:
fail-fast: false
matrix:
os: [
{ distribution: debian, codename: buster, description: Debian Buster (x86_64), architecture: [ amd64, linux/amd64 ], platform: x11 },
{ distribution: debian, codename: buster, description: Debian Buster (Raspberry Pi 1 & Zero 1), architecture: [ armv6, linux/arm/v6 ], platform: rpi },
{ distribution: debian, codename: buster, description: Debian Buster (Raspberry Pi 2), architecture: [ armv7, linux/arm/v7 ], platform: rpi },
{ distribution: debian, codename: buster, description: Debian Buster (Raspberry Pi 3/4/5 & Zero 2), architecture: [ arm64, linux/arm64 ], platform: rpi },
{ distribution: debian, codename: bullseye, description: Debian Bullseye (x86_64), architecture: [ amd64, linux/amd64 ], platform: x11 },
{ distribution: debian, codename: bullseye, description: Debian Bullseye (Raspberry Pi 2), architecture: [ armv7, linux/arm/v7 ], platform: rpi },
{ distribution: debian, codename: bullseye, description: Debian Bullseye (Raspberry Pi 3/4/5 & Zero 2), architecture: [ arm64, linux/arm64 ], platform: rpi }
]
target_lookup: [{ 'arm64': 'arm64', 'armv6': 'armv6l', 'armv7': 'armv7l' }]
isQt5:
- ${{ inputs.qt_version == '5' }}
exclude:
- isQt5: true
os: { distribution: debian, codename: bullseye }
- isQt5: false
os: { distribution: debian, codename: buster }
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 🔧 Append PR number to version (PR only)
if: ${{ inputs.event_name == 'pull_request' }}
shell: bash
run: tr -d '\n' < .version > temp && mv temp .version && echo -n "+PR${{ inputs.pull_request_number }}" >> .version
- name: 👷 Build
shell: bash
run: |
mkdir deploy
docker run --rm --platform=${{ matrix.os.architecture[1] }} ${{ env.ENTRYPOINT }} \
-v "${{ github.workspace }}/deploy:/deploy" \
-v "${{ github.workspace }}:/source:rw" \
-w "/source" \
ghcr.io/hyperion-project/${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} \
/bin/bash -c "cmake --preset linux-${{ env.BUILD_TYPE }} -DPLATFORM=${{ matrix.os.platform }} ${{ env.CPACK_SYSTEM_PROCESSOR }} &&
cmake --build --preset linux-${{ env.BUILD_TYPE }} --target package --parallel $(nproc) &&
cp /source/build/Hyperion-* /deploy/ 2>/dev/null"
env:
DOCKER_IMAGE: ${{ matrix.os.distribution }}
DOCKER_TAG: ${{ matrix.os.codename }}${{ inputs.qt_version == '6' && '-qt6' || '' }}
BUILD_TYPE: ${{ inputs.event_name == 'pull_request' && 'debug' || 'release' }}
ENTRYPOINT: ${{ matrix.os.architecture[0] != 'amd64' && '--entrypoint /usr/bin/env' || '' }}
CPACK_SYSTEM_PROCESSOR: ${{ matrix.os.architecture[0] != 'amd64' && format('-DCPACK_SYSTEM_PROCESSOR={0}', matrix.target_lookup[format('{0}', matrix.os.architecture[0])]) || '' }}
- name: 📦 Upload
if: ${{ inputs.publish || inputs.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.event_name == 'pull_request' && env.NAME || format('artifact-{0}', env.NAME) }}
path: ${{ inputs.event_name == 'pull_request' && 'deploy/*.tar.gz' || 'deploy/Hyperion-*' }}
env:
NAME: ${{ format('{0}_{1}_{2}{3}', matrix.os.distribution, matrix.os.codename, matrix.os.architecture[0], inputs.qt_version == '6' && '_qt6' || '') }}
######################
###### macOS #########
######################
macOS:
name: 🍏 macOS ${{ matrix.architecture }}
runs-on: ${{ matrix.architecture == 'arm64' && 'macos-14' || 'macos-13' }}
strategy:
fail-fast: false
matrix:
architecture: [ arm64, x64 ]
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 🔧 Append Pull Request number to version (PR only)
if: ${{ inputs.event_name == 'pull_request' }}
shell: bash
run: tr -d '\n' < .version > temp && mv temp .version && echo -n "+PR${{ inputs.pull_request_number }}" >> .version
- name: 💾 Restore Homebrew Cache
id: cache-homebrew
uses: actions/cache@v4
with:
path: ~/Library/Caches/Homebrew/downloads
key: ${{ runner.os }}-${{ matrix.architecture }}-homebrew-packages-${{ inputs.qt_version }}
- name: 📥 Install dependencies
shell: bash
run: brew update -q && brew install -q qt@${{ inputs.qt_version }} vulkan-headers ninja libftdi || true
- name: 👷 Build
shell: bash
run: |
cmake --preset macos-${{ env.BUILD_TYPE }}
cmake --build --preset macos-${{ env.BUILD_TYPE }} --parallel $(sysctl -n hw.ncpu)
cd build; cpack
env:
BUILD_TYPE: ${{ inputs.event_name == 'pull_request' && 'debug' || 'release' }}
- name: 📦 Upload
if: ${{ inputs.publish || inputs.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.event_name == 'pull_request' && env.NAME || format('artifact-{0}', env.NAME) }}
path: 'build/Hyperion-*'
env:
NAME: ${{ inputs.qt_version == '6' && format('macOS_{0}_qt6', matrix.architecture) || format('macOS_{0}', matrix.architecture) }}
######################
###### Windows #######
######################
windows:
name: 🪟 Windows x64
runs-on: windows-2022
env:
VCINSTALLDIR: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
LIBJPEG_TURBO_VERSION: 3.0.1
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 🔧 Append Pull Request number to version (PR only)
if: ${{ inputs.event_name == 'pull_request' }}
shell: bash
run: tr -d '\n' < .version > temp && mv temp .version && echo -n "+PR${{ inputs.pull_request_number }}" >> .version
- name: 💾 Restore DirectX SDK & libjpeg-turbo
id: cache-windows
uses: actions/cache@v4
with:
path: ./installer
key: ${{ runner.os }}-libjpeg-${{ env.LIBJPEG_TURBO_VERSION }}-dxsdk-jun10
- name: 📥 Download DirectX SDK & libjpeg-turbo
if: steps.cache-windows.outputs.cache-hit != 'true'
shell: powershell
run: |
mkdir .\installer
Invoke-WebRequest -Uri https://sourceforge.net/projects/libjpeg-turbo/files/${{ env.LIBJPEG_TURBO_VERSION }}/libjpeg-turbo-${{ env.LIBJPEG_TURBO_VERSION }}-vc64.exe -OutFile ".\installer\libjpeg-turbo.exe" -UserAgent "NativeHost"
Invoke-WebRequest -Uri https://download.microsoft.com/download/A/E/7/AE743F1F-632B-4809-87A9-AA1BB3458E31/DXSDK_Jun10.exe -OutFile ".\installer\dxsdk-jun10.exe" -UserAgent "NativeHost"
- name: 📥 Install DirectX SDK, libjpeg-turbo
run: |
cmd.exe /c start /wait .\installer\libjpeg-turbo.exe /S
cmd.exe /c start /wait .\installer\dxsdk-jun10.exe /U /F
- name: Install Vulkan SDK
if: ${{ inputs.qt_version == '6' }}
uses: jakoch/install-vulkan-sdk-action@v1.0.6
with:
install_runtime: false
cache: true
stripdown: true
- name: 📥 Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ inputs.qt_version == '6' && '6.8' || '5.15.*' }}
target: 'desktop'
modules: ${{ inputs.qt_version == '6' && 'qtserialport qtwebsockets' || '' }}
cache: 'true'
cache-key-prefix: 'cache-qt-windows'
- name: 🛠️ Setup MSVC
shell: cmd
run: call "${{env.VCINSTALLDIR}}\Auxiliary\Build\vcvars64.bat"
- name: 👷 Build
shell: bash
run: |
cmake --preset windows-${{ env.BUILD_TYPE }}
cmake --build --preset windows-${{ env.BUILD_TYPE }} --target package -- -nologo -v:m -maxcpucount
env:
BUILD_TYPE: ${{ inputs.event_name == 'pull_request' && 'debug' || 'release' }}
- name: 📦 Upload
if: ${{ inputs.publish || inputs.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.event_name == 'pull_request' && env.NAME || format('artifact-{0}', env.NAME) }}
path: ${{ inputs.event_name == 'pull_request' && 'build/*.exe' || 'build/Hyperion-*' }}
env:
NAME: ${{ inputs.qt_version == '6' && 'windows_x64_qt6' || 'windows_x64' }}
#####################################
###### Publish GitHub Releases ######
#####################################
github_publish:
name: 🚀 Publish GitHub Releases
if: ${{ inputs.qt_version == '5' && inputs.publish }}
needs: [Linux, macOS, windows]
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
- name: 🔧 Prepare
run: |
echo '::group::Generate environment variables from .version and tag'
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "VERSION=$(tr -d '\n' < .version)" >> $GITHUB_ENV
echo '::endgroup::'
- name: 💾 Artifact download
uses: actions/download-artifact@v4.1.8
with:
pattern: artifact-*
path: all-artifacts
- name: 📦 Upload
uses: softprops/action-gh-release@v2
with:
name: Hyperion ${{ env.VERSION }}
tag_name: ${{ env.TAG }}
files: "all-artifacts/**"
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}