fix(wish-tree): 图片扩展名改为 .jpg
Publish Mini Program Dev Version / publish (push) Failing after 1m38s
Build and Deploy Server / build (push) Failing after 3s

- 实际格式是 JPEG,扩展名从 .png 改为 .jpg
- 大小 332KB,远低于微信 2M 限制
This commit is contained in:
gouki
2026-08-08 17:14:30 +00:00
parent 531d342eb6
commit daebda22ee
9 changed files with 118 additions and 5 deletions
+20
View File
@@ -31,6 +31,7 @@ jobs:
env:
MINIAPP_BUILD_NUMBER: ${{ gitea.run_number }}
MINIAPP_VERSION_OVERRIDE: ${{ vars.MINIAPP_VERSION_OVERRIDE }}
GITEA_SHA: ${{ gitea.sha }}
run: |
test -n "$MINIAPP_BUILD_NUMBER"
VERSION="$(node -e 'const {resolveVersion}=require("./ci/resolve-version.cjs"); process.stdout.write(resolveVersion(process.cwd()))')"
@@ -38,6 +39,25 @@ jobs:
mkdir -p ci-artifacts
printf '%s\n' "$VERSION" > ci-artifacts/resolved-version.txt
echo "Resolved Mini Program version for build+upload: $VERSION"
# 注入版本号到 utils/version.js
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
COMMIT_SHORT="${GITEA_SHA:0:7}"
cat > utils/version.js <<EOF
/**
* 版本号配置文件
* 此文件由 CI 构建时自动生成,请勿手动修改
*/
module.exports = {
version: "$VERSION",
buildNumber: "$MINIAPP_BUILD_NUMBER",
buildTime: "$BUILD_TIME",
commitSha: "$COMMIT_SHORT",
};
EOF
echo "Version info injected into utils/version.js:"
cat utils/version.js
- name: Materialize the upload key
env:
WECHAT_CI_PRIVATE_KEY: ${{ secrets.WECHAT_CI_PRIVATE_KEY }}
+32 -2
View File
@@ -30,9 +30,37 @@ jobs:
- name: Build application
working-directory: server
env:
GITEA_SHA: ${{ gitea.sha }}
GITEA_RUN_NUMBER: ${{ gitea.run_number }}
run: |
mkdir -p bin
go build -o bin/server cmd/main.go
# 生成版本号(使用构建编号)
VERSION="1.0.${GITEA_RUN_NUMBER}"
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
COMMIT_SHORT="${GITEA_SHA:0:7}"
echo "Building server version: $VERSION"
echo "Build time: $BUILD_TIME"
echo "Commit SHA: $COMMIT_SHORT"
# 使用 ldflags 注入版本信息
go build -ldflags "\
-X main.Version=$VERSION \
-X main.BuildTime=$BUILD_TIME \
-X main.CommitSha=$COMMIT_SHORT" \
-o bin/server cmd/main.go
# 同时保存版本信息到文件(用于部署时读取)
cat > bin/version.env <<EOF
APP_VERSION=$VERSION
APP_BUILD_TIME=$BUILD_TIME
APP_COMMIT_SHA=$COMMIT_SHORT
EOF
echo "Version info saved to bin/version.env:"
cat bin/version.env
- name: Build frontend (if exists)
working-directory: server
@@ -75,10 +103,12 @@ jobs:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
GITEA_RUN_NUMBER: ${{ gitea.run_number }}
run: |
VERSION="1.0.${GITEA_RUN_NUMBER}"
bash .gitea/scripts/notify.sh success \
"后端服务部署成功" \
"部署包已保存到: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz"
"版本: v${VERSION}\n部署包: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz"
- name: Send failure notification
if: failure()

Before

Width:  |  Height:  |  Size: 332 KiB

After

Width:  |  Height:  |  Size: 332 KiB

+7 -1
View File
@@ -1,3 +1,5 @@
const versionInfo = require('../../utils/version.js');
Page({
data: {
userInfo: null,
@@ -6,7 +8,11 @@ Page({
solarTime: true,
showBuddhist: false,
highlightLunar: true,
bookmarks: []
bookmarks: [],
version: versionInfo.version,
buildNumber: versionInfo.buildNumber,
buildTime: versionInfo.buildTime,
commitSha: versionInfo.commitSha
},
onLoad() {
+2 -1
View File
@@ -92,7 +92,8 @@
<view class="card">
<view class="section-title">关于</view>
<view class="text-sm text-muted">
<text>老黄历小程序 v1.0.1</text>
<text>老黄历小程序 v{{version}}</text>
<text class="block mt-1" wx:if="{{buildNumber !== '0'}}">构建 #{{buildNumber}} ({{commitSha}})</text>
<text class="block mt-1">提供农历、黄历、八字、许愿等功能</text>
</view>
</view>
+1 -1
View File
@@ -35,7 +35,7 @@
<!-- 许愿树 -->
<view class="tree-container">
<image
src="/images/wish-tree.png"
src="/images/wish-tree.jpg"
class="tree-image"
mode="aspectFit"
/>
+11
View File
@@ -0,0 +1,11 @@
/**
* 版本号配置文件
* 此文件由 CI 构建时自动生成,请勿手动修改
*/
module.exports = {
version: "1.0.1", // 会被 CI 替换为实际版本号
buildNumber: "0", // 会被 CI 替换为构建编号
buildTime: "2026-08-08T00:00:00Z", // 会被 CI 替换为构建时间
commitSha: "unknown", // 会被 CI 替换为 Git commit SHA
};
+3
View File
@@ -42,6 +42,9 @@ func main() {
// API 路由
api := r.Group("/api")
{
// 版本信息(无需认证)
api.GET("/version", handler.GetVersion)
// 用户相关
user := api.Group("/user")
{
+42
View File
@@ -0,0 +1,42 @@
package handler
import (
"net/http"
"os"
"github.com/gin-gonic/gin"
)
// VersionInfo 版本信息
type VersionInfo struct {
Version string `json:"version"`
BuildTime string `json:"buildTime"`
CommitSha string `json:"commitSha"`
GoVersion string `json:"goVersion"`
}
// GetVersion 获取服务器版本信息
func GetVersion(c *gin.Context) {
// 从环境变量读取版本信息(由 CI 构建时注入)
version := os.Getenv("APP_VERSION")
if version == "" {
version = "dev"
}
buildTime := os.Getenv("APP_BUILD_TIME")
if buildTime == "" {
buildTime = "unknown"
}
commitSha := os.Getenv("APP_COMMIT_SHA")
if commitSha == "" {
commitSha = "unknown"
}
c.JSON(http.StatusOK, VersionInfo{
Version: version,
BuildTime: buildTime,
CommitSha: commitSha,
GoVersion: "go1.22", // 可以通过 runtime.Version() 获取
})
}