Skip to content

Build

Build #105

Workflow file for this run

name: Build
# Complete packaging in the future
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
permissions: write-all
jobs:
build:
env:
QT_VERSION: 6.6.3
name: Build ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
rid: [linux-x64, win-x64, win-arm64, macos]
include:
- rid: linux-x64
rust_target: x86_64-unknown-linux-gnu
qt_arch: 'gcc_64'
os: ubuntu-24.04
- rid: win-x64
msvc_arch: x64
rust_target: x86_64-pc-windows-msvc
qt_arch: 'win64_msvc2019_64'
os: windows-latest
- rid: win-arm64
msvc_arch: arm64
rust_target: aarch64-pc-windows-msvc
qt_host_arch: 'win64_msvc2019_64'
qt_arch: 'win64_msvc2019_arm64'
os: windows-latest
- rid: macos
rust_target: aarch64-apple-darwin
qt_arch: 'clang_64'
os: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up GCC
if: startsWith(matrix.rid, 'linux-')
uses: egor-tensin/[email protected]
with:
version: 14
platform: x64
- name: Setup Rust toolchain
uses: moonrepo/setup-rust@v1
with:
channel: stable
targets: ${{ matrix.rust_target }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Cache corrosion
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/build/_deps
${{ github.workspace }}/build/*/cargo/build
!${{ github.workspace }}/build/*/cargo/build/**/incremental
${{ github.workspace }}/build/corrosion/**/target
!${{ github.workspace }}/build/corrosion/**/target/**/incremental
key: corrosion-${{ matrix.rid }}
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgConfigurationJsonGlob: 'vcpkg-configuration.json'
vcpkgJsonGlob: 'vcpkg.json'
- name: Install Qt (Tools on Host)
if: matrix.qt_host_arch && (matrix.qt_arch != matrix.qt_host_arch)
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
arch: ${{ matrix.qt_host_arch }}
cache: true
set-env: false
add-tools-to-path: false
- name: Save Qt Host Path
if: matrix.qt_host_arch && (matrix.qt_arch != matrix.qt_host_arch)
shell: pwsh
run: |
$qtHostPath = Join-Path $env:RUNNER_WORKSPACE "Qt"
$qtHostPath = Get-ChildItem -Path $qtHostPath | Select-Object -First 1
$qtHostPath = Get-ChildItem -Path $qtHostPath | Select-Object -First 1
Write-Host "Using Qt host path: $qtHostPath"
Write-Output "QT_HOST_PATH=$qtHostPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
arch: ${{ matrix.qt_arch }}
cache: true
- name: Install Windows SDK for arm64
if: matrix.rid == 'win-arm64'
uses: ChristopheLav/windows-sdk-install@v1
with:
version-sdk: 26100
features: OptionId.DesktopCPParm64
- name: Build
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$rid = '${{ matrix.rid }}'
$additionalConfigureArgs = @()
if ($rid.StartsWith('win-')) {
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} "\Microsoft Visual Studio\Installer\vswhere.exe") -property installationpath
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=${{ matrix.msvc_arch }} -host_arch=x64'
$additionalConfigureArgs += '-DPKG_CONFIG_EXECUTABLE:FILEPATH=./build/vcpkg_installed/x64-windows/tools/pkgconf/pkgconf.exe'
}
$qtHostPath = $env:QT_HOST_PATH
if ($qtHostPath.Length -ne 0) {
$additionalConfigureArgs += "-DQT_HOST_PATH:PATH=$qtHostPath"
}
cmake --preset native -DRust_CARGO_TARGET=${{ matrix.rust_target }} @additionalConfigureArgs
cmake --build --preset native-release
if ($rid.StartsWith('win-')) {
echo winSdkDir=$env:WindowsSdkDir >> $env:GITHUB_ENV
echo winSdkVer=$env:WindowsSdkVersion >> $env:GITHUB_ENV
echo vcToolsInstallDir=$env:VCToolsInstallDir >> $env:GITHUB_ENV
echo vcToolsRedistDir=$env:VCToolsRedistDir >> $env:GITHUB_ENV
}
- name: Package for Windows
if: startsWith(matrix.rid, 'win-')
env:
msvcArch: ${{ matrix.msvc_arch }}
shell: pwsh
run: scripts\windows-publish.ps1
- name: Make .desktop file
if: matrix.rid == 'linux-x64'
shell: bash
run: |
touch sast-evento.desktop
cat >> sast-evento.desktop << EOF
[Desktop Entry]
Name=SAST Evento
Version=${{ github.ref_name }}
Categories=Education;
Type=Application
Comment=An event management system developed and used by NJUPT SAST
Exec=sast-evento
Icon=evento
Terminal=false
EOF
- name: Package for deb
if: matrix.rid == 'linux-x64'
shell: bash
run: |
mkdir -p sast-evento/DEBIAN
touch sast-evento/DEBIAN/control
cat >> sast-evento/DEBIAN/control << EOF
Package: sast-evento
Version: ${{ github.ref_name }}
Architecture: x64
Priority: optional
Essential: no
Depends: qt6-base-dev
Maintainer: NJUPT-SAST-C++
Description: An event management system developed and used by NJUPT SAST
EOF
mkdir -p sast-evento/usr/bin
mkdir -p sast-evento/usr/lib
install -Dm755 build/src/Release/sast-evento sast-evento/usr/bin
install -Dm755 build/src/Tray/Release/sast-evento-tray sast-evento/usr/bin
install -Dm644 build/3rdpart/sast-link-cxx-sdk/Release/libsast-link.so.1 sast-evento/usr/lib
install -Dm644 build/3rdpart/sast-link-cxx-sdk/src/details/Release/libsast-link_details.so sast-evento/usr/lib
install -Dm644 build/_deps/slint-build/libslint_cpp.so sast-evento/usr/lib
install -Dm644 ui/assets/image/icon/evento.png sast-evento/usr/share/pixmaps/evento.png
install -Dm644 sast-evento.desktop sast-evento/usr/share/applications/sast-evento.desktop
dpkg-deb --build sast-evento
- name: Prepare PKGBUILD
if: matrix.rid == 'linux-x64'
shell: bash
run: |
mkdir -p build-aux/sast-evento-bin
touch build-aux/sast-evento-bin/PKGBUILD
cat >> build-aux/sast-evento-bin/PKGBUILD << EOF
# Maintainer: NJUPT-SAST <[email protected]>
pkgname=sast-evento-bin
pkgver=${{ github.ref_name }}
pkgrel=1
pkgdesc="An event management system developed and used by NJUPT SAST"
arch=(x86_64)
url="https://github.com/NJUPT-SAST-CPP/sast-evento"
license=(MIT)
depends=(qt6-base)
provides=(sast-evento)
conflicts=(sast-evento)
replaces=(sast-evento-appimage)
package() {
install -Dm755 "\$srcdir/../../../build/src/Release/sast-evento" "\$pkgdir/usr/bin/sast-evento"
install -Dm755 "\$srcdir/../../../build/src/Tray/Release/sast-evento-tray" "\$pkgdir/usr/bin/sast-evento-tray"
install -Dm644 "\$srcdir/../../../build/3rdpart/sast-link-cxx-sdk/Release/libsast-link.so" "\$pkgdir/usr/lib/libsast-link.so"
install -Dm644 "\$srcdir/../../../build/3rdpart/sast-link-cxx-sdk/src/details/Release/libsast-link_details.so" "\$pkgdir/usr/lib/libsast-link_details.so"
install -Dm644 "\$srcdir/../../../build/_deps/slint-build/libslint_cpp.so" "\$pkgdir/usr/lib/libslint_cpp.so"
install -Dm644 "\$srcdir/../../../ui/assets/image/icon/evento.png" "\$pkgdir/usr/share/pixmaps/evento.png"
install -Dm644 "\$srcdir/../../../sast-evento.desktop" "\$pkgdir/usr/share/applications/sast-evento.desktop"
}
EOF
- name: Package for pacman
if: matrix.rid == 'linux-x64'
uses: 2m/[email protected]
with:
target: 'pkgbuild'
pkgname: build-aux/sast-evento-bin/
- name: Prepare .app
if: matrix.rid == 'macos'
shell: bash
run: |
cp build/3rdpart/sast-link-cxx-sdk/Release/libsast-link.dylib build/src/Release/sast-evento.app/Contents/Frameworks/
cp build/3rdpart/sast-link-cxx-sdk/src/details/Release/libsast-link_details.dylib build/src/Release/sast-evento.app/Contents/Frameworks/
cp build/_deps/slint-build/libslint_cpp.dylib build/src/Release/sast-evento.app/Contents/Frameworks/
cp build/src/Tray/Release/sast-evento-tray.app/Contents/MacOS/sast-evento-tray build/src/Release/sast-evento.app/Contents/Frameworks/
- name: Package for macos (dmg)
if: matrix.rid == 'macos'
uses: L-Super/[email protected]
with:
dmg_name: 'sast-evento'
src_dir: 'build/src/Release/sast-evento.app'
- uses: actions/upload-artifact@v4
if: startsWith(matrix.rid, 'win-')
with:
name: sast-evento-${{ github.ref_name }}-${{ matrix.rid }}.exe
path: dist
- uses: actions/upload-artifact@v4
if: matrix.rid == 'linux-x64'
with:
name: sast-evento-${{ github.ref_name }}-${{ matrix.rid }}.deb
path: sast-evento.deb
- uses: actions/upload-artifact@v4
if: matrix.rid == 'linux-x64'
with:
name: sast-evento-bin-${{ github.ref_name }}-x86_64.pkg.tar.zst
path: build-aux/sast-evento-bin/sast-evento*
- uses: actions/upload-artifact@v4
if: matrix.rid == 'macos'
with:
name: sast-evento-${{ github.ref_name }}-aarch64.dmg
path: ./sast-evento.dmg
- name: Inno Setup
if: startsWith(matrix.rid, 'win-')
uses: Minionguyjpro/[email protected]
with:
path: ./action-cli/InstallerScript.iss
options: /O+
- name: Upload Windows Release
if: startsWith(matrix.rid, 'win-')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./action-cli/installer.exe
asset_name: sast-evento-${{ github.ref_name }}-${{ matrix.rid }}.exe
tag: ${{ github.ref }}
overwrite: true
- name: Upload Linux Release (deb)
if: matrix.rid == 'linux-x64'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: sast-evento.deb
asset_name: sast-evento-${{ github.ref_name }}-x86_64.deb
tag: ${{ github.ref }}
overwrite: true
- name: Upload Linux Release (pacman)
if: matrix.rid == 'linux-x64'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./build-aux/sast-evento-bin/sast-evento-bin-${{ github.ref_name }}-1-x86_64.pkg.tar.zst
tag: ${{ github.ref }}
overwrite: true
- name: Upload Linux Release (pacman)
if: matrix.rid == 'linux-x64'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./sast-evento.dmg
asset_name: sast-evento-${{ github.ref_name }}-aarch64.dmg
tag: ${{ github.ref }}
overwrite: true