Skip to content
This repository was archived by the owner on Dec 26, 2025. It is now read-only.

Update release.yml

Update release.yml #16

Workflow file for this run

name: Release Build and Package
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for release'
required: false
default: ''
env:
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
vcpkg_triplet: x64-linux
platform_name: linux-x64
executable_name: YumeCard
- os: windows-latest
vcpkg_triplet: x64-mingw-static
platform_name: windows-x64
executable_name: YumeCard.exe
runs-on: ${{ matrix.os }}
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.vcpkg_triplet }}
VCPKG_FEATURE_FLAGS: manifests,registries,versions
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version info
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag_name }}" ]; then
echo "VERSION=${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT
elif [ "${{ github.ref_type }}" == "tag" ]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "VERSION=dev-$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: ${{ env.VCPKG_ROOT }}
key: release-vcpkg-${{ matrix.vcpkg_triplet }}-${{ hashFiles('vcpkg.json') }}
restore-keys: |
release-vcpkg-${{ matrix.vcpkg_triplet }}-
vcpkg-${{ matrix.vcpkg_triplet }}-
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build curl ca-certificates git tar zip unzip pkg-config build-essential
shell: bash
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install ninja
shell: pwsh
- name: Setup vcpkg (Linux)
if: runner.os == 'Linux'
run: |
if [ ! -d "${{ env.VCPKG_ROOT }}" ]; then
git clone https://github.com/Microsoft/vcpkg.git ${{ env.VCPKG_ROOT }}
fi
${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.sh
shell: bash
- name: Setup vcpkg (Windows)
if: runner.os == 'Windows'
run: |
if (!(Test-Path "${{ env.VCPKG_ROOT }}")) {
git clone https://github.com/Microsoft/vcpkg.git ${{ env.VCPKG_ROOT }}
}
& "${{ env.VCPKG_ROOT }}\bootstrap-vcpkg.bat"
shell: pwsh
- name: Install vcpkg packages (Linux)
if: runner.os == 'Linux'
run: |
cd ${{ github.workspace }}
${{ env.VCPKG_ROOT }}/vcpkg install --triplet ${{ env.VCPKG_DEFAULT_TRIPLET }}
shell: bash
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
- name: Install vcpkg packages (Windows)
if: runner.os == 'Windows'
run: |
cd ${{ github.workspace }}
& "${{ env.VCPKG_ROOT }}\vcpkg.exe" install --triplet ${{ env.VCPKG_DEFAULT_TRIPLET }}
shell: pwsh
- name: Configure CMake
run: |
cmake -B ${{ github.workspace }}/build -S ${{ github.workspace }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -G "Ninja" -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_DEFAULT_TRIPLET }} -DVCPKG_LIBRARY_LINKAGE=static -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
- name: Build
run: cmake --build ${{ github.workspace }}/build --config Release
- name: Verify build
run: |
if [ "${{ runner.os }}" == "Linux" ]; then
if [ -f "${{ github.workspace }}/build/${{ matrix.executable_name }}" ]; then
echo "✅ Build successful: ${{ matrix.executable_name }}"
file "${{ github.workspace }}/build/${{ matrix.executable_name }}"
ldd "${{ github.workspace }}/build/${{ matrix.executable_name }}" || echo "Static executable - no dynamic dependencies"
else
echo "❌ Build failed: ${{ matrix.executable_name }} not found"
find "${{ github.workspace }}/build/" -type f -name "*" | head -10
exit 1
fi
fi
shell: bash
- name: Verify build (Windows)
if: runner.os == 'Windows'
run: |
if (Test-Path "${{ github.workspace }}\build\${{ matrix.executable_name }}") {
Write-Host "✅ Build successful: ${{ matrix.executable_name }}"
Get-Item "${{ github.workspace }}\build\${{ matrix.executable_name }}"
} else {
Write-Host "❌ Build failed: ${{ matrix.executable_name }} not found"
Get-ChildItem "${{ github.workspace }}\build\" | Select-Object -First 10
exit 1
}
shell: pwsh
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.platform_name }}-${{ steps.version.outputs.VERSION }}
path: ${{ github.workspace }}/build/${{ matrix.executable_name }}
retention-days: 1
package:
needs: build
strategy:
matrix:
include:
- os: ubuntu-latest
platform_name: linux-x64
executable_name: YumeCard
archive_type: tar.gz
- os: windows-latest
platform_name: windows-x64
executable_name: YumeCard.exe
archive_type: zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from build job
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag_name }}" ]; then
echo "VERSION=${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT
elif [ "${{ github.ref_type }}" == "tag" ]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "VERSION=dev-$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.platform_name }}-${{ steps.get_version.outputs.VERSION }}
path: build/
- name: Make executable (Linux)
if: runner.os == 'Linux'
run: chmod +x build/${{ matrix.executable_name }}
- name: Create package directory (Linux)
if: runner.os == 'Linux'
run: mkdir -p package/YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}
shell: bash
- name: Create package directory (Windows)
if: runner.os == 'Windows'
run: New-Item -ItemType Directory -Force -Path "package\YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}"
shell: pwsh
- name: Copy files to package (Linux)
if: runner.os == 'Linux'
run: |
PACKAGE_DIR="package/YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}"
# Copy executable
cp build/${{ matrix.executable_name }} "$PACKAGE_DIR/"
# Copy project files
[ -f "README.md" ] && cp README.md "$PACKAGE_DIR/" || echo "README.md not found"
[ -f "LICENSE" ] && cp LICENSE "$PACKAGE_DIR/" || echo "LICENSE not found"
[ -f "package.json" ] && cp package.json "$PACKAGE_DIR/" || echo "package.json not found"
[ -f "package-lock.json" ] && cp package-lock.json "$PACKAGE_DIR/" || echo "package-lock.json not found"
# Copy directories
[ -d "Style" ] && cp -r Style "$PACKAGE_DIR/" || echo "Style directory not found"
[ -d "config" ] && cp -r config "$PACKAGE_DIR/" || echo "config directory not found"
# Create version file
cat > "$PACKAGE_DIR/VERSION.txt" << 'VERSIONEOF'
YumeCard ${{ steps.get_version.outputs.VERSION }} for Linux x64
Build Date: $(date)
Platform: Linux x64
Static Linking: Yes
Commit: ${{ github.sha }}
VERSIONEOF
# Create install guide
cat > "$PACKAGE_DIR/INSTALL.txt" << 'INSTALLEOF'
# YumeCard Installation Guide
## Requirements
- No additional dependencies required (statically linked)
- Node.js (for web-related features, if needed)
## Installation Steps
1. Extract this archive to your desired location
2. Make the executable file executable: chmod +x YumeCard
3. Run: ./YumeCard
## Directory Structure
- YumeCard: Main executable
- Style/: UI styles and themes
- config/: Configuration files
- package.json: Node.js dependencies information
- README.md: Project documentation
- LICENSE: License information
## Troubleshooting
- If you encounter permission issues, make sure the executable has proper permissions
- For configuration, check the config/ directory
INSTALLEOF
shell: bash
- name: Copy files to package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$PACKAGE_DIR = "package\YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}"
# Copy executable
Copy-Item "build\${{ matrix.executable_name }}" "$PACKAGE_DIR\"
# Copy project files
if (Test-Path "README.md") { Copy-Item "README.md" "$PACKAGE_DIR\" }
if (Test-Path "LICENSE") { Copy-Item "LICENSE" "$PACKAGE_DIR\" }
if (Test-Path "package.json") { Copy-Item "package.json" "$PACKAGE_DIR\" }
if (Test-Path "package-lock.json") { Copy-Item "package-lock.json" "$PACKAGE_DIR\" }
# Copy directories
if (Test-Path "Style") { Copy-Item "Style" "$PACKAGE_DIR\" -Recurse }
if (Test-Path "config") { Copy-Item "config" "$PACKAGE_DIR\" -Recurse }
# Create version file
$versionContent = @"
YumeCard ${{ steps.get_version.outputs.VERSION }} for Windows x64

Check failure on line 279 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

You have an error in your yaml syntax on line 279
Build Date: $(Get-Date)
Platform: Windows x64
Static Linking: Yes
Commit: ${{ github.sha }}
"@
$versionContent | Out-File -FilePath "$PACKAGE_DIR\VERSION.txt" -Encoding UTF8
# Create install guide
$installContent = @"
# YumeCard Installation Guide
## Requirements
- No additional dependencies required (statically linked)
- Node.js (for web-related features, if needed)
## Installation Steps
1. Extract this archive to your desired location
2. Run: YumeCard.exe
## Directory Structure
- YumeCard.exe: Main executable
- Style/: UI styles and themes
- config/: Configuration files
- package.json: Node.js dependencies information
- README.md: Project documentation
- LICENSE: License information
## Troubleshooting
- If Windows Defender blocks the executable, add it to exclusions
- For configuration, check the config/ directory
"@
$installContent | Out-File -FilePath "$PACKAGE_DIR\INSTALL.txt" -Encoding UTF8
- name: Create archive (Linux)
if: runner.os == 'Linux'
run: |
cd package
tar -czf YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}.tar.gz YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}/
echo "ASSET_PATH=$(pwd)/YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}.tar.gz" >> $GITHUB_ENV
echo "ASSET_NAME=YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}.tar.gz" >> $GITHUB_ENV
shell: bash
- name: Create archive (Windows)
if: runner.os == 'Windows'
run: |
cd package
Compress-Archive -Path "YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}" -DestinationPath "YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}.zip"
$currentPath = Get-Location
echo "ASSET_PATH=$currentPath\YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}.zip" >> $env:GITHUB_ENV
echo "ASSET_NAME=YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}.zip" >> $env:GITHUB_ENV
shell: pwsh
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: YumeCard-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform_name }}
path: ${{ env.ASSET_PATH }}
retention-days: 30
release:
# 此作业创建 GitHub Release。
# 重要提示:此工作流的 'on' 触发器当前仅为 'workflow_dispatch'。
# 此 'if' 条件确保仅当通过 dispatch 提供 tag_name 时才运行 release 作业。
# 如果您打算在推送标签或 GitHub 发布事件时触发发布,
# 则需要更新文件顶部的 'on' 块和此 'if' 条件。
if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != ''
needs: [package] # 依赖于 package 作业准备好工件。
runs-on: ubuntu-latest
steps:
- name: 准备发布信息
id: release_info
run: |
echo "VERSION=${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT
echo "RELEASE_DATE=$(date --utc --iso-8601=seconds)" >> $GITHUB_OUTPUT
shell: bash
- name: 下载所有已打包的工件
uses: actions/download-artifact@v4
with:
path: artifacts/ # 'package' 作业中的所有工件都将下载到此处。
- name: 显示已下载工件的结构
run: |
echo "Structure of downloaded artifacts in ./artifacts/:"
ls -R artifacts
echo "Archives found:"
find artifacts/ -type f \( -name "*.tar.gz" -o -name "*.zip" \)
shell: bash
- name: 创建 GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_info.outputs.VERSION }}
name: YumeCard ${{ steps.release_info.outputs.VERSION }}
body: |
## YumeCard ${{ steps.release_info.outputs.VERSION }}
发布于: ${{ steps.release_info.outputs.RELEASE_DATE }}
提交: ${{ github.sha }} <!-- 工作流触发提交的 SHA -->
### 📦 下载
- **Linux x64**: `YumeCard-${{ steps.release_info.outputs.VERSION }}-linux-x64.tar.gz`
- **Windows x64**: `YumeCard-${{ steps.release_info.outputs.VERSION }}-windows-x64.zip`
### 🔧 构建信息
- 静态链接: Yes
- C++ 标准: C++26
<!-- 注意: 从 head_commit.timestamp 获取的 'Build Date' 已移除,因为它对于 workflow_dispatch 不可靠。
发布日期现在位于顶部。 -->
### 📁 包内容
- 主可执行文件 (YumeCard/YumeCard.exe)
- Style 目录 (UI 主题和样式)
- config 目录 (配置文件)
- Node.js 文件 (package.json, package-lock.json)
- 文档 (README.md, LICENSE, INSTALL.txt, VERSION.txt)
### 📋 安装
1. 下载适用于您平台的相应包
2. 将存档解压缩到您期望的位置
3. 按照 INSTALL.txt 中的说明进行操作
4. 运行可执行文件
### ⚠️ 要求
- 无需其他依赖项 (静态链接)
- 建议使用 Node.js 以支持与 Web 相关的功能
### 🆕 新增内容
查看与标签 ${{ steps.release_info.outputs.VERSION }} 相关的提交历史以获取详细更改。
draft: false
prerelease: ${{ contains(steps.release_info.outputs.VERSION, 'beta') || contains(steps.release_info.outputs.VERSION, 'alpha') || contains(steps.release_info.outputs.VERSION, 'rc') }}
files: artifacts/**/*