chore: 添加 Linux 版本导出脚本和相关配置

- 新增 .env 文件和生成脚本
- 更新 docker-compose.yml 和 Dockerfile 以支持 Linux 版本导出
- 添加 PowerShell 脚本生成 .env 文件
- 实现 Linux 版本导出的完整流程
This commit is contained in:
Luke 2025-08-25 12:32:10 +08:00
parent d3646c86ec
commit a16f0ac059
5 changed files with 71 additions and 4 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
# Auto-generated by build\tools\generate-dotenv.ps1
SNOW_VERSION=0.7.0

View File

@ -1,5 +1,5 @@
# Stage 1: 官方 GraalVM 社区版(已含 native-image
FROM ghcr.io/graalvm/native-image-community:latest AS builder
FROM ghcr.io/graalvm/native-image-community:24.0.2 AS builder
RUN microdnf install -y \
gcc gcc-c++ make git wget tar gzip which findutils maven \

26
build/release-linux.ps1 Normal file
View File

@ -0,0 +1,26 @@
# run-linux-snow-export.ps1
Write-Host "Step 0: Generate .env..."
try {
& "$PSScriptRoot\tools\generate-dotenv.ps1" -ErrorAction Stop
}
catch {
Write-Error "Failed to generate .env: $($_.Exception.Message)"
exit 1
}
Write-Host "Step 1: Build and run linux-snow-export..."
docker compose run --build --rm linux-snow-export
if ($LASTEXITCODE -ne 0) {
Write-Error "Build & Run failed, exiting script."
exit $LASTEXITCODE
}
Write-Host "Step 2: Run linux-snow-export without rebuild..."
docker compose run --rm linux-snow-export
if ($LASTEXITCODE -ne 0) {
Write-Error "Run without rebuild failed, exiting script."
exit $LASTEXITCODE
}
Write-Host "All steps completed successfully!"

View File

@ -0,0 +1,23 @@
# build\tools\generate-dotenv.ps1
# Repository root: go up two levels from build\tools\
$repoRoot = (Get-Item $PSScriptRoot).Parent.Parent.FullName
$envPath = Join-Path $repoRoot ".env"
$pomPath = Join-Path $repoRoot "pom.xml"
if (-not (Test-Path $pomPath -PathType Leaf)) {
throw "pom.xml not found: $pomPath"
}
[xml]$pom = Get-Content $pomPath -Encoding UTF8
$version = $pom.project.version
$lines = @(
"# Auto-generated by build\tools\generate-dotenv.ps1"
"SNOW_VERSION=$version"
)
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllLines($envPath, $lines, $utf8NoBom)
Write-Host "Generated/overwritten $envPath (version: $version)"
return

View File

@ -1,8 +1,24 @@
services:
snow-export:
image: my-snow-export
# Run with: docker compose run --rm linux-snow-export
linux-snow-export:
build:
context: .
command: [ "/bin/sh", "-c", "cp /export/Snow /output/Snow" ]
target: export
command:
- /bin/sh
- -c
- |
set -e
ver="Snow-v${SNOW_VERSION}-linux-x64"
mkdir -p "/output/release/$$ver/bin"
cp /export/Snow "/output/release/$$ver/bin/"
if [ -d /export/lib ]; then
mkdir -p "/output/release/$$ver/lib"
cp -a /export/lib/. "/output/release/$$ver/lib/"
fi
tar -C /output/release -czf "/output/release/$$ver.tgz" "$$ver"
volumes:
- ./target:/output
- ./lib:/export/lib:ro
env_file:
- .env