-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (122 loc) · 4.62 KB
/
release.yml
File metadata and controls
139 lines (122 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Release
on:
push:
tags:
- "v*" # 触发条件:推送 v 开头的 tag,如 v1.0.0
permissions:
contents: write # 创建 GitHub Release、上传 assets
packages: write # 推送镜像到 GHCR
jobs:
# ----------------------------------------------------------------------------
# binaries: 交叉编译全平台二进制,生成 SHA256 校验文件,发布 GitHub Release
# ----------------------------------------------------------------------------
binaries:
name: Build & Release Binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 完整 tag 历史,make release 中 git describe 依赖它
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Install zip
run: sudo apt-get install -y zip
- name: Build release artifacts
run: make release
# 输出:dist/pairproxy-<version>-<os>-<arch>.tar.gz / .zip
- name: Build reportgen binaries
run: |
VERSION=${{ github.ref_name }}
mkdir -p dist
cd tools/reportgen
for GOOS in linux darwin windows; do
for GOARCH in amd64 arm64; do
EXT=""
[ "$GOOS" = "windows" ] && EXT=".exe"
OUTPUT="../../dist/reportgen-${VERSION}-${GOOS}-${GOARCH}${EXT}"
echo "Building $OUTPUT"
GOOS=$GOOS GOARCH=$GOARCH go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "$OUTPUT" .
done
done
cd ../..
# 打包:linux/darwin 用 tar.gz,windows 用 zip
for GOOS in linux darwin; do
for GOARCH in amd64 arm64; do
NAME="reportgen-${VERSION}-${GOOS}-${GOARCH}"
tar -czf "dist/${NAME}.tar.gz" -C dist "${NAME}"
rm "dist/${NAME}"
done
done
for GOARCH in amd64 arm64; do
NAME="reportgen-${VERSION}-windows-${GOARCH}.exe"
(cd dist && zip "${NAME%.exe}.zip" "${NAME}" && rm "${NAME}")
done
- name: Generate SHA256 checksums
run: |
cd dist
sha256sum *.tar.gz *.zip > SHA256SUMS.txt
echo "=== Checksums ==="
cat SHA256SUMS.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/SHA256SUMS.txt
generate_release_notes: true # 自动从 commit 生成 release notes
fail_on_unmatched_files: true
# ----------------------------------------------------------------------------
# docker: 多架构镜像构建并推送到 GHCR
# ----------------------------------------------------------------------------
docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# QEMU 支持 arm64 模拟构建
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Buildx 支持多平台构建
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 登录 GitHub Container Registry(使用自动提供的 GITHUB_TOKEN,无需额外配置 secret)
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 自动生成镜像标签:
# v1.2.3 → 1.2.3, 1.2, 1, latest
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
labels: |
org.opencontainers.image.title=PairProxy sproxy
org.opencontainers.image.description=Enterprise LLM API gateway for Claude Code
org.opencontainers.image.vendor=PairProxy
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
COMMIT=${{ github.sha }}
BUILT=${{ github.event.head_commit.timestamp }}
# GitHub Actions 缓存,加速后续构建
cache-from: type=gha
cache-to: type=gha,mode=max