This commit is contained in:
ivaquero
2026-04-18 06:13:30 +08:00
parent 49b39b74d2
commit ec341ddba2
36 changed files with 1941 additions and 273 deletions
+116
View File
@@ -0,0 +1,116 @@
# GitHub Actions Build System
This project uses GitHub Actions for automated building and releasing across multiple platforms.
## Available Workflows
### 1. CI Build (`ci.yml`)
**Trigger**: Push to main/master branches, pull requests
**Purpose**: Quick validation builds on all platforms
**Artifacts**: Platform-specific executables
### 2. Build Qt (`build.yml`)
**Trigger**: Push to main/master branches, pull requests, manual dispatch
**Purpose**: Comprehensive builds using both qmake and CMake
**Artifacts**:
- qmake builds for each platform
- CMake builds for each platform
### 3. Release (`release.yml`)
**Trigger**: Git tags (v*), manual dispatch
**Purpose**: Create official releases with distributable packages
**Artifacts**:
- macOS: DMG installer
- Windows: ZIP package with dependencies
- Linux: TAR.GZ package
## Usage
### Automatic Builds
Every push to main/master branches triggers CI builds to ensure code quality.
### Creating a Release
1. Create and push a version tag:
```bash
git tag v1.0.0
git push origin v1.0.0
```
2. The release workflow will automatically:
- Build for all platforms
- Create distributable packages
- Create a GitHub release with artifacts
### Manual Release
1. Go to Actions tab in GitHub
2. Select "Build and Release Clouck"
3. Click "Run workflow"
4. Enter version number (e.g., v1.0.0)
5. Click "Run workflow"
## Build Requirements
### macOS
- Qt 6.5.0
- Xcode Command Line Tools
- macdeployqt for app bundling
### Windows
- Qt 6.5.0
- Visual Studio Build Tools or MinGW
- windeployqt for dependency deployment
### Linux
- Qt 6.5.0
- GCC/Clang
- X11 development libraries
- XFixes development libraries
## Artifacts
Each workflow produces platform-specific artifacts:
- **macOS**: `.app` bundle or `.dmg` installer
- **Windows**: Executable with Qt dependencies
- **Linux**: Executable with shared libraries
## Configuration
The workflows use:
- `jurplel/install-qt-action@v4` for Qt installation
- Matrix builds for multi-platform support
- Artifact upload for build retention
- Automatic release creation for tagged builds
## Troubleshooting
### Build Failures
1. Check Qt version compatibility
2. Verify platform-specific dependencies
3. Review build logs in GitHub Actions
### Missing Dependencies
- Ensure all required Qt modules are specified
- Check platform-specific library installations
- Verify CMake/qmake configuration
### Release Issues
- Ensure proper version tagging format (v*)
- Check GitHub token permissions
- Verify artifact upload paths
+143
View File
@@ -0,0 +1,143 @@
name: Build Qt Application
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.5.*"
modules: "qt5compat"
cache: true
tools: "tools_ninja"
install-deps: "true"
- name: Build with qmake
run: |
qmake Clouck.pro CONFIG+=release
make
- name: Create macOS Bundle
run: |
macdeployqt build/Clouck.app -dmg
- name: Upload macOS Build
uses: actions/upload-artifact@v7
with:
name: Clouck-qmake
path: build/Clouck.dmg
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Setup MSVC Environment
uses: ilammy/msvc-dev-cmd@v1
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.5.*"
modules: "qt5compat"
cache: true
tools: "tools_ninja"
install-deps: "true"
- name: Build with qmake
shell: cmd
run: |
qmake Clouck.pro CONFIG+=release
nmake
- name: Deploy Windows Build
run: |
mkdir Clouck-windows-dist
copy build\Clouck.exe Clouck-windows-dist\
windeployqt --release Clouck-windows-dist\Clouck.exe
- name: Upload Windows Build
uses: actions/upload-artifact@v7
with:
name: Clouck-windows-qmake
path: Clouck-windows-dist
# build-linux:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v6
# - name: Install Dependencies
# run: |
# sudo apt-get update
# sudo apt-get install -y build-essential qt6-base-dev qt6-tools-dev libx11-dev libxfixes-dev
# - name: Install Qt
# uses: jurplel/install-qt-action@v4
# with:
# version: "6.5.*"
# modules: "qt5compat"
# cache: true
# - name: Build with qmake
# run: |
# qmake Clouck.pro CONFIG+=release
# make
# - name: Create Linux Distribution
# run: |
# mkdir -p Clouck-linux-dist
# cp Clouck Clouck-linux-dist/
# ldd Clouck | grep -o '/lib[^ ]*' | xargs -I {} cp {} Clouck-linux-dist/ 2>/dev/null || true
# - name: Upload Linux Build
# uses: actions/upload-artifact@v7
# with:
# name: Clouck-linux-qmake
# path: Clouck-linux-dist
build-cmake:
strategy:
matrix:
os: [ windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.5.*"
modules: "qt5compat"
cache: true
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake libx11-dev libxfixes-dev
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build with CMake
run: cmake --build build --config Release
- name: Upload CMake Build
uses: actions/upload-artifact@v7
with:
name: Clouck-${{ runner.os }}-cmake
path: build/Clouck*
+200
View File
@@ -0,0 +1,200 @@
name: CI Build
on:
push:
branches: [ main, master ]
paths:
- "**.cpp"
- "**.h"
- "**.pro"
- "CMakeLists.txt"
- ".github/workflows/ci.yml"
pull_request:
branches: [ main, master ]
paths:
- "**.cpp"
- "**.h"
- "**.pro"
- "CMakeLists.txt"
- ".github/workflows/ci.yml"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Setup MSVC Environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.5.*"
modules: "qt5compat"
cache: true
tools: "tools_ninja"
install-deps: "true"
aqtversion: "==3.1.*"
py7zrversion: ">=0.20.2"
# - name: Install Linux Dependencies
# if: runner.os == 'Linux'
# run: |
# sudo apt-get update
# sudo apt-get install -y build-essential cmake libx11-dev libxfixes-dev
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
echo "Configuring CMake for Windows..."
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
echo "CMake configuration completed."
echo "Checking if build directory was created:"
dir build 2>nul && echo "Build directory exists" || echo "Build directory NOT found"
echo "Contents of current directory:"
dir
- name: Configure CMake (macOS)
if: runner.os == 'macOS'
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
echo "Starting Windows build..."
echo "=== Pre-build diagnostics ==="
echo "Current directory: %CD%"
echo "Checking if CMakeLists.txt exists:"
dir CMakeLists.txt 2>nul && echo "✓ CMakeLists.txt found" || echo "✗ CMakeLists.txt NOT found"
echo "Contents before build:"
dir
echo "=== Building with CMake ==="
cmake --build build --config Release
echo "=== Post-build diagnostics ==="
echo "Build completed with exit code: %ERRORLEVEL%"
echo "Contents after build:"
dir
echo "=== Searching for Clouck executable ==="
echo "Checking build directory structure:"
dir build /s /b 2>nul || echo "Build directory not found or empty"
echo "Looking for Clouck.exe in specific locations:"
dir build\Clouck.exe 2>nul && echo "✓ Found Clouck.exe in build\" || echo "✗ Clouck.exe not in build\"
dir build\Release\Clouck.exe 2>nul && echo "✓ Found Clouck.exe in build\Release\" || echo "✗ Clouck.exe not in build\Release\"
dir build\MinSizeRel\Clouck.exe 2>nul && echo "✓ Found Clouck.exe in build\MinSizeRel\" || echo "✗ Clouck.exe not in build\MinSizeRel\"
echo "Searching entire directory tree for any Clouck.exe:"
dir Clouck.exe /s /b 2>nul || echo "No Clouck.exe found anywhere"
echo "Searching for any .exe files in build directory:"
dir build\*.exe /s /b 2>nul || echo "No .exe files found in build"
- name: Build (macOS)
if: runner.os == 'macOS'
run: cmake --build build --config Release
- name: Quick Binary Validation (macOS)
if: runner.os == 'macOS'
run: find ./build -name "Clouck" -type f
- name: Test Build (macOS)
if: runner.os == 'macOS'
run: timeout 3s ./build/Clouck.app/Contents/MacOS/Clouck || echo "Test
completed"
- name: Quick Binary Validation (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
echo "=== Windows Quick Binary Validation ==="
echo "Current directory: %CD%"
echo "Looking for build directory..."
dir build 2>nul && echo "Build directory exists" || echo "Build directory NOT found"
echo "Looking for Clouck executable in possible locations:"
dir build\Clouck.exe 2>nul && echo "✓ Found Clouck.exe in build\" || echo "✗ Clouck.exe not in build\"
dir build\Release\Clouck.exe 2>nul && echo "✓ Found Clouck.exe in build\Release\" || echo "✗ Clouck.exe not in build\Release\"
dir build\MinSizeRel\Clouck.exe 2>nul && echo "✓ Found Clouck.exe in build\MinSizeRel\" || echo "✗ Clouck.exe not in build\MinSizeRel\"
echo "Searching entire build directory for any .exe files:"
dir build\*.exe /s /b 2>nul || echo "No .exe files found in build directory"
echo "=== End Validation ==="
- name: Test Build (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
echo "=== Windows Test Build Diagnostics ==="
echo "Current directory: %CD%"
echo "Visual Studio environment is configured (see env vars above)"
echo "Checking for build directory..."
if exist build (
echo "Build directory exists"
echo "Contents of build directory:"
dir build
echo "Looking for Clouck.exe in build directory..."
if exist build\Clouck.exe (
echo "Found Clouck.exe in build\"
echo "Testing Windows binary..."
start /min build\Clouck.exe & timeout /t 2 /nobreak >nul 2>&1 & tasklist | findstr Clouck.exe >nul 2>&1
) else (
echo "Clouck.exe not found in build\"
echo "Checking build\Release directory..."
if exist build\Release\Clouck.exe (
echo "Found Clouck.exe in build\Release\"
echo "Testing Windows binary..."
start /min build\Release\Clouck.exe & timeout /t 2 /nobreak >nul 2>&1 & tasklist | findstr Clouck.exe >nul 2>&1
) else (
echo "Clouck.exe not found in build\Release\"
echo "Checking build\MinSizeRel directory..."
if exist build\MinSizeRel\Clouck.exe (
echo "Found Clouck.exe in build\MinSizeRel\"
echo "Testing Windows binary..."
start /min build\MinSizeRel\Clouck.exe & timeout /t 2 /nobreak >nul 2>&1 & tasklist | findstr Clouck.exe >nul 2>&1
) else (
echo "ERROR: Clouck.exe not found in any expected location!"
echo "Searching entire build directory for any .exe files:"
dir build\*.exe /s /b
echo "Searching entire working directory for Clouck.exe:"
dir Clouck.exe /s /b
echo "Build failed - no executable found"
exit 1
)
)
)
) else (
echo "ERROR: Build directory does not exist!"
echo "Contents of current directory:"
dir
exit 1
)
- name: Upload Build Artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v7
with:
name: Clouck-windows
path: build/Clouck*.exe
- name: Upload Build Artifact (macOS)
if: runner.os == 'macOS'
run: |
echo "Checking for macOS app bundle..."
ls -la ./build/Clouck.app/Contents/MacOS/Clouck || echo "Clouck.app not found"
- name: Upload macOS Artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v7
with:
name: Clouck-macos
path: |
build/Clouck.app/**/*
!build/Clouck.app/Contents/Frameworks/*
!build/Clouck.app/Contents/PlugIns/*
+285
View File
@@ -0,0 +1,285 @@
name: Build and Release Clouck
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to build (e.g., v1.0.0)"
required: true
default: "v1.0.0"
jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.5.*"
cache: true
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release
- name: Create macOS App Bundle
run: |
# Debug: Check current directory and build output
echo "Current directory: $(pwd)"
echo "Build directory contents:"
ls -la build/
echo "Checking if Clouck executable exists:"
ls -la build/Clouck || echo "ERROR: Clouck executable not found!"
# Create app bundle structure
mkdir -p Clouck.app/Contents/MacOS
mkdir -p Clouck.app/Contents/Resources
# Copy executable
cp build/Clouck Clouck.app/Contents/MacOS/
# Verify executable was copied
echo "App bundle contents:"
ls -la Clouck.app/Contents/MacOS/
# Create Info.plist
cat > Clouck.app/Contents/Info.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Clouck</string>
<key>CFBundleIdentifier</key>
<string>com.clouck.app</string>
<key>CFBundleName</key>
<string>Clouck</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSUIElement</key>
<true/>
</dict>
</plist>
EOF
# Verify app bundle exists before running macdeployqt
echo "Verifying app bundle structure:"
if [ -d "Clouck.app" ]; then
echo "App bundle directory exists"
ls -la Clouck.app/
ls -la Clouck.app/Contents/
ls -la Clouck.app/Contents/MacOS/
else
echo "ERROR: Clouck.app directory not found!"
exit 1
fi
# Check if macdeployqt is available
echo "Checking macdeployqt availability:"
which macdeployqt || echo "macdeployqt not found in PATH"
# Deploy Qt dependencies (ignore non-critical errors)
echo "Running macdeployqt..."
echo "Current directory before macdeployqt: $(pwd)"
echo "Listing current directory contents:"
ls -la
echo "Calling: macdeployqt Clouck.app -dmg"
macdeployqt build/Clouck.app -dmg || echo "macdeployqt failed, will use fallback"
# Check what was created
echo "Files after macdeployqt:"
ls -la *.dmg 2>/dev/null || echo "No DMG files found"
- name: Check DMG Creation
run: |
echo "Checking for DMG files after macdeployqt:"
ls -la *.dmg 2>/dev/null || echo "No DMG files found"
# Check if DMG was created by macdeployqt
if [ -f "Clouck.dmg" ]; then
echo "Found Clouck.dmg, renaming to Clouck.dmg"
mv Clouck.dmg Clouck.dmg
echo "DMG created successfully"
else
echo "Clouck.dmg not found, checking for other DMG files:"
ls -la *.dmg 2>/dev/null || echo "Still no DMG files found"
echo "Creating DMG manually using hdiutil..."
# Fallback: create DMG manually if macdeployqt failed
hdiutil create -volname "Clouck" -srcfolder Clouck.app -ov -format UDZO Clouck.dmg
fi
- name: Upload macOS Artifact
uses: actions/upload-artifact@v7
with:
name: Clouck
path: Clouck.dmg
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.5.*"
cache: true
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release
- name: Create Windows Installer
run: |
# Copy executable and dependencies
mkdir Clouck-windows
cp build/Release/Clouck.exe Clouck-windows/
cp build/Release/*.dll Clouck-windows/ 2>/dev/null || true
# Deploy Qt dependencies
windeployqt --release Clouck-windows/Clouck.exe
# Create ZIP archive
Compress-Archive -Path Clouck-windows -DestinationPath Clouck-windows.zip
- name: Upload Windows Artifact
uses: actions/upload-artifact@v7
with:
name: Clouck-windows
path: Clouck-windows.zip
# build-linux:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v6
#
# - name: Install Dependencies
# run: |
# sudo apt-get update
# sudo apt-get install -y build-essential cmake qt6-base-dev qt6-tools-dev libx11-dev libxfixes-dev
#
# - name: Install Qt
# uses: jurplel/install-qt-action@v4
# with:
# version: "6.5.*"
# cache: true
#
# - name: Configure CMake
# run: |
# cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
#
# - name: Build
# run: cmake --build build --config Release
#
# - name: Create Linux AppImage
# run: |
# mkdir -p Clouck.AppDir/usr/bin
# mkdir -p Clouck.AppDir/usr/lib
#
# cp build/Clouck Clouck.AppDir/usr/bin/
#
# cat > Clouck.AppDir/clouck.desktop << EOF
# [Desktop Entry]
# Name=Clouck
# Exec=Clouck
# Icon=clouck
# Type=Application
# Categories=Utility;
# EOF
#
# # Copy desktop file
# cp Clouck.AppDir/clouck.desktop Clouck.AppDir/
#
# # Deploy Qt dependencies (simplified)
# ldd build/Clouck | grep -o '/lib[^ ]*' | xargs -I {} cp {} Clouck.AppDir/usr/lib/ 2>/dev/null || true
#
# # Create AppImage (simplified approach)
# cd Clouck.AppDir
# ln -s usr/bin/Clouck AppRun
# cd ..
#
# # Create tar.gz for distribution
# tar -czf Clouck-linux.tar.gz Clouck.AppDir/
#
# - name: Upload Linux Artifact
# uses: actions/upload-artifact@v7
# with:
# name: Clouck-linux
# path: Clouck-linux.tar.gz
create-release:
needs: [ build-macos, build-windows ]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event_name ==
'workflow_dispatch'
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Get Version
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v3
with:
name: Clouck ${{ steps.version.outputs.VERSION }}
body: |
Cross-platform clock widget application
## Features
- Always-on-top functionality across all platforms
- Fullscreen mode compatibility
- Resizable interface
- Context menu with customization options
- Native platform integration
## Downloads
- **macOS**: Clouck.dmg
- **Windows**: Clouck-windows.zip
- **Linux**: Clouck-linux.tar.gz
## Installation
### macOS
1. Download Clouck.dmg
2. Open the DMG file
3. Drag Clouck.app to Applications folder
### Windows
1. Download Clouck-windows.zip
2. Extract the ZIP file
3. Run Clouck.exe
### Linux
1. Download Clouck-linux.tar.gz
2. Extract the tar.gz file
3. Run the Clouck executable
files: |
artifacts/Clouck/Clouck.dmg
artifacts/Clouck-windows/Clouck-windows.zip
artifacts/Clouck-linux/Clouck-linux.tar.gz
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}