Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f039bd0c61 | |||
| f4beb90769 | |||
| 6f0b273950 | |||
| b43601b4fd | |||
| 3aa63d6575 |
@@ -1,8 +1,9 @@
|
||||
name: DB Backup
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 18 * * *' # UTC 18:00 = 北京时间 02:00
|
||||
# 定时备份已暂停(保留手动触发)。恢复时取消下面 schedule 的注释即可。
|
||||
# schedule:
|
||||
# - cron: '0 18 * * *' # UTC 18:00 = 北京时间 02:00
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: backend/go.mod
|
||||
cache-dependency-path: backend/go.sum
|
||||
|
||||
- name: Go tests
|
||||
working-directory: backend
|
||||
run: go test ./...
|
||||
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
cache: true
|
||||
|
||||
- name: Flutter tests
|
||||
working-directory: client
|
||||
run: flutter test
|
||||
@@ -16,6 +16,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Provision (idempotent — auto-runs if host not initialized)
|
||||
run: sh scripts/ci/provision-mac.sh
|
||||
|
||||
- name: Compile (Linux backend + Flutter Web)
|
||||
run: sh scripts/ci/compile.sh "${{ gitea.ref_name }}"
|
||||
|
||||
@@ -26,6 +29,9 @@ jobs:
|
||||
path: dist/
|
||||
|
||||
build-macos:
|
||||
# Same physical runner as build-linux-web (label: mac, capacity 1). Run them
|
||||
# serially via needs so the second job doesn't sit queued and time out.
|
||||
needs: build-linux-web
|
||||
runs-on: mac
|
||||
env:
|
||||
PUB_HOSTED_URL: https://pub.flutter-io.cn
|
||||
@@ -34,6 +40,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Provision (idempotent — auto-runs if host not initialized)
|
||||
run: sh scripts/ci/provision-mac.sh
|
||||
|
||||
- name: Compile (Flutter macOS)
|
||||
run: sh scripts/ci/compile-macos.sh "${{ gitea.ref_name }}"
|
||||
|
||||
@@ -53,6 +62,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Provision (idempotent — auto-runs if host not initialized)
|
||||
shell: bash
|
||||
run: sh scripts/ci/provision-windows.sh
|
||||
|
||||
- name: Compile (Flutter Windows)
|
||||
shell: bash
|
||||
run: sh scripts/ci/compile-windows.sh "${{ gitea.ref_name }}"
|
||||
|
||||
@@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.0.9] - 2026-06-04
|
||||
|
||||
### 修复
|
||||
- 适配 nginx 容器化部署:nginx 已迁入 `pangolin-edge` 容器(host 网络),deploy 改为将 jiu.conf 写入 pangolin 挂载目录并 `docker exec pangolin-edge nginx -s reload`,不再操作已废弃的主机 nginx
|
||||
|
||||
## [1.0.8] - 2026-06-03
|
||||
|
||||
### 修复
|
||||
- 修复 EC2 部署最后一步 nginx reload 失败(`invalid PID number`):改用 `systemctl reload-or-restart nginx`(经 systemd MAINPID 发 HUP,不依赖空的 /run/nginx.pid),并 `enable nginx` 确保重启后自启
|
||||
|
||||
## [1.0.7] - 2026-06-03
|
||||
|
||||
### 修复
|
||||
- 修复 Windows 构建 `PathExistsException`(errno 183):复制 client/ 到 C:\jiu-build 后,先清除 cp 复制成真实目录的插件软链(windows/flutter/ephemeral)及 .dart_tool/build,再交给 flutter 干净重建
|
||||
|
||||
## [1.0.6] - 2026-06-03
|
||||
|
||||
### 改进
|
||||
- CI 运行环境自愈预置:mac/windows runner 首次构建自动 `flutter precache` 并预热 pub/go/npm 缓存(stamp 文件按 Flutter 版本短路),后续构建不再运行时下载 engine
|
||||
- 发版流水线同一 mac runner 上的任务改为串行(build-macos 依赖 build-linux-web),避免排队等待超时失败
|
||||
- 暂停定时数据库备份(保留手动触发)
|
||||
|
||||
## [1.0.5] - 2026-06-03
|
||||
|
||||
### 修复
|
||||
- 修复 Windows CI 构建失败:放弃脆弱的 `subst W:` 路径映射,改为将 client/ 复制到 System32 之外的干净短路径(C:\jiu-build)构建,规避 WOW64 文件系统重定向
|
||||
|
||||
## [1.0.4] - 2026-05-30
|
||||
|
||||
### 新功能
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# _env.sh — shared CI mirror env. `source` this from other scripts.
|
||||
# Idempotent: only sets vars if not already provided by the environment.
|
||||
|
||||
export GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
|
||||
export PUB_HOSTED_URL="${PUB_HOSTED_URL:-https://pub.flutter-io.cn}"
|
||||
export FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.flutter-io.cn}"
|
||||
|
||||
# Ensure Homebrew tools are on PATH (macOS runners); harmless elsewhere.
|
||||
case ":${PATH}:" in
|
||||
*":/opt/homebrew/bin:"*) ;;
|
||||
*) export PATH="/opt/homebrew/bin:${PATH}" ;;
|
||||
esac
|
||||
@@ -2,9 +2,8 @@
|
||||
# compile-macos.sh <tag> — build Flutter macOS desktop, package into dist/
|
||||
set -euo pipefail
|
||||
|
||||
export GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
|
||||
export PUB_HOSTED_URL="${PUB_HOSTED_URL:-https://pub.flutter-io.cn}"
|
||||
export FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.flutter-io.cn}"
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
|
||||
@@ -2,52 +2,55 @@
|
||||
# compile-windows.sh <tag> — build Flutter Windows desktop, package into dist/
|
||||
set -euo pipefail
|
||||
|
||||
export GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
|
||||
export PUB_HOSTED_URL="${PUB_HOSTED_URL:-https://pub.flutter-io.cn}"
|
||||
export FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.flutter-io.cn}"
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
|
||||
echo "==> compile-windows: version=${VER}"
|
||||
|
||||
# Sync Flutter pubspec version
|
||||
# Sync Flutter pubspec version (done in the checkout, before copying out)
|
||||
sed -i "s/^version:.*/version: ${VER}+1/" client/pubspec.yaml
|
||||
|
||||
# Build Flutter Windows
|
||||
# Use subst to create a short path (W:) to avoid WOW64 redirection issue
|
||||
# when workspace is under C:\Windows\System32\config\systemprofile
|
||||
WORKSPACE_WIN=$(cygpath -w "$(pwd)")
|
||||
echo "==> workspace: $WORKSPACE_WIN"
|
||||
cmd //c "subst W: \"${WORKSPACE_WIN}\"" || true
|
||||
# The Forgejo Windows runner checks out under
|
||||
# C:\Windows\System32\config\systemprofile\.cache\act\...\hostexecutor
|
||||
# Building there triggers WOW64 filesystem redirection (System32 -> SysWOW64)
|
||||
# which breaks CMake/Flutter native paths. So copy the Flutter project to a
|
||||
# clean short path OUTSIDE System32 and build there. This replaces the previous
|
||||
# `subst W:` trick, which was fragile due to cmd/MSYS quoting.
|
||||
BUILD_ROOT="/c/jiu-build"
|
||||
BUILD_CLIENT="${BUILD_ROOT}/client"
|
||||
|
||||
cd /w/client
|
||||
echo "==> copying client/ to ${BUILD_CLIENT}"
|
||||
rm -rf "$BUILD_ROOT"
|
||||
mkdir -p "$BUILD_ROOT"
|
||||
cp -r client "$BUILD_CLIENT"
|
||||
|
||||
# `cp -r` turns Flutter's plugin symlinks (windows/flutter/ephemeral/.plugin_symlinks/*)
|
||||
# into real directories. flutter's createPluginSymlinks only cleans up *symlinks*, so it
|
||||
# then fails to create a symlink over the copied real dir (errno 183 / PathExists).
|
||||
# Drop all regenerable artifacts so the build below recreates them cleanly.
|
||||
rm -rf "${BUILD_CLIENT}/windows/flutter/ephemeral" \
|
||||
"${BUILD_CLIENT}/.dart_tool" \
|
||||
"${BUILD_CLIENT}/build"
|
||||
|
||||
# Build (run from the clean path; pushd/popd avoids needing $() to save cwd)
|
||||
pushd "$BUILD_CLIENT" > /dev/null
|
||||
flutter create --platforms=windows . --project-name jiu_client
|
||||
flutter build windows --release \
|
||||
"--dart-define=BASE_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=APP_VERSION=${TAG}"
|
||||
cd /w
|
||||
popd > /dev/null
|
||||
|
||||
cmd //c "subst W: /d" || true
|
||||
|
||||
# Package release folder into zip using Python (available on all platforms)
|
||||
# Package the Release folder into dist/ using PowerShell Compress-Archive.
|
||||
# Source is an absolute Windows path; destination is relative to the workspace.
|
||||
mkdir -p dist
|
||||
python3 - <<'PYEOF'
|
||||
import zipfile, os
|
||||
|
||||
src = os.path.join('W:\\', 'client', 'build', 'windows', 'x64', 'runner', 'Release') if os.path.exists('W:\\') else os.path.join('client', 'build', 'windows', 'x64', 'runner', 'Release')
|
||||
dst = os.path.join('dist', 'jiu-windows-x64.zip')
|
||||
|
||||
with zipfile.ZipFile(dst, 'w', zipfile.ZIP_DEFLATED) as zf:
|
||||
for root, dirs, files in os.walk(src):
|
||||
for fname in files:
|
||||
fp = os.path.join(root, fname)
|
||||
zf.write(fp, os.path.relpath(fp, src))
|
||||
|
||||
size = os.path.getsize(dst)
|
||||
print(f'Packaged {dst} ({size // 1024 // 1024} MB)')
|
||||
PYEOF
|
||||
REL_WIN='C:\jiu-build\client\build\windows\x64\runner\Release'
|
||||
echo "==> packaging ${REL_WIN} -> dist/jiu-windows-x64.zip"
|
||||
powershell -NoProfile -Command \
|
||||
"Compress-Archive -Path '${REL_WIN}\*' -DestinationPath 'dist\jiu-windows-x64.zip' -Force"
|
||||
|
||||
echo "==> compile-windows: done — dist/ contents:"
|
||||
ls -lh dist/
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
# compile.sh <tag> — build backend + Flutter web, package into dist/
|
||||
set -euo pipefail
|
||||
|
||||
export PATH="/opt/homebrew/bin:$PATH"
|
||||
export GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
|
||||
export PUB_HOSTED_URL="${PUB_HOSTED_URL:-https://pub.flutter-io.cn}"
|
||||
export FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.flutter-io.cn}"
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
|
||||
@@ -126,9 +126,12 @@ mkdir -p /opt/jiu/marketing
|
||||
rsync -a --delete /tmp/jiu-marketing-new/ /opt/jiu/marketing/
|
||||
rm -rf /tmp/jiu-marketing-new
|
||||
|
||||
# Update nginx config and reload
|
||||
sudo cp /tmp/nginx-jiu.conf /etc/nginx/conf.d/jiu.conf
|
||||
sudo nginx -t && sudo nginx -s reload
|
||||
# Update jiu nginx config in the pangolin-edge reverse proxy.
|
||||
# nginx now runs inside the `pangolin-edge` container (host networking), not on
|
||||
# the host. Its /etc/nginx/conf.d is bind-mounted from the host dir below, so we
|
||||
# write the config there and reload nginx *inside the container*.
|
||||
cp /tmp/nginx-jiu.conf /home/ec2-user/pangolin/edge/conf.d/jiu.conf
|
||||
docker exec pangolin-edge nginx -t && docker exec pangolin-edge nginx -s reload
|
||||
|
||||
echo "Deploy complete!"
|
||||
ENDSSH
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
# provision-mac.sh — idempotent provisioning for the macOS host runner.
|
||||
#
|
||||
# Pre-warms everything the build jobs (compile.sh / compile-macos.sh) would
|
||||
# otherwise download at runtime: Flutter macOS+web engine artifacts, pub
|
||||
# packages, Go modules, npm deps. Safe to run on every pipeline run — it
|
||||
# short-circuits via a stamp file keyed to the installed Flutter version, so
|
||||
# once provisioned it returns in milliseconds and downloads nothing.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "${SCRIPT_DIR}/_env.sh"
|
||||
|
||||
STAMP_DIR="${HOME}/.cache/jiu-ci"
|
||||
STAMP="${STAMP_DIR}/provisioned-mac"
|
||||
CUR="${STAMP_DIR}/.flutter-version-mac.cur"
|
||||
mkdir -p "$STAMP_DIR"
|
||||
|
||||
# --- detection: skip if already provisioned for this Flutter version ---
|
||||
if ! command -v flutter >/dev/null 2>&1; then
|
||||
echo "ERROR: flutter not found on PATH. Install Flutter on this runner first." >&2
|
||||
exit 1
|
||||
fi
|
||||
flutter --version --machine > "$CUR" 2>/dev/null || flutter --version > "$CUR" 2>&1 || true
|
||||
|
||||
if [ -s "$STAMP" ] && cmp -s "$STAMP" "$CUR"; then
|
||||
echo "==> provision-mac: already provisioned (Flutter unchanged), skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "==> provision-mac: not provisioned (or Flutter changed) — running."
|
||||
|
||||
# --- toolchain presence (do not auto-install system-level tools) ---
|
||||
for tool in go node npm; do
|
||||
if ! command -v "$tool" >/dev/null 2>&1; then
|
||||
echo "ERROR: '$tool' not found on PATH. Install it on this runner first." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# --- warm Flutter platform engines (the macOS SDK download seen in CI) ---
|
||||
echo "==> precache Flutter engines (macos, web)"
|
||||
flutter precache --macos --web --universal
|
||||
|
||||
# --- warm dependency caches ---
|
||||
echo "==> flutter pub get (client)"
|
||||
(cd "${SCRIPT_DIR}/../../client" && flutter pub get)
|
||||
|
||||
echo "==> go mod download (backend)"
|
||||
(cd "${SCRIPT_DIR}/../../backend" && go mod download)
|
||||
|
||||
echo "==> npm ci (web)"
|
||||
(cd "${SCRIPT_DIR}/../../web" && npm ci --prefer-offline)
|
||||
|
||||
# --- mark provisioned ---
|
||||
cp "$CUR" "$STAMP"
|
||||
echo "==> provision-mac: done."
|
||||
echo "--- versions ---"
|
||||
flutter --version | head -1
|
||||
go version
|
||||
node --version
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# provision-windows.sh — idempotent provisioning for the Windows host runner.
|
||||
#
|
||||
# Pre-warms what compile-windows.sh would download at runtime: Flutter Windows
|
||||
# engine artifacts and pub packages. Short-circuits via a stamp file keyed to
|
||||
# the installed Flutter version, so repeat runs return immediately.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "${SCRIPT_DIR}/_env.sh"
|
||||
|
||||
STAMP_DIR="${HOME}/.cache/jiu-ci"
|
||||
STAMP="${STAMP_DIR}/provisioned-windows"
|
||||
CUR="${STAMP_DIR}/.flutter-version-win.cur"
|
||||
mkdir -p "$STAMP_DIR"
|
||||
|
||||
# --- detection ---
|
||||
if ! command -v flutter >/dev/null 2>&1; then
|
||||
echo "ERROR: flutter not found on PATH. Install Flutter on this runner first." >&2
|
||||
exit 1
|
||||
fi
|
||||
flutter --version --machine > "$CUR" 2>/dev/null || flutter --version > "$CUR" 2>&1 || true
|
||||
|
||||
if [ -s "$STAMP" ] && cmp -s "$STAMP" "$CUR"; then
|
||||
echo "==> provision-windows: already provisioned (Flutter unchanged), skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "==> provision-windows: not provisioned (or Flutter changed) — running."
|
||||
|
||||
# --- warm Flutter Windows engine + pub deps ---
|
||||
echo "==> precache Flutter engine (windows)"
|
||||
flutter precache --windows
|
||||
|
||||
echo "==> flutter pub get (client)"
|
||||
(cd "${SCRIPT_DIR}/../../client" && flutter pub get)
|
||||
|
||||
# --- mark provisioned ---
|
||||
cp "$CUR" "$STAMP"
|
||||
echo "==> provision-windows: done."
|
||||
flutter --version | head -1
|
||||
Reference in New Issue
Block a user