-
Notifications
You must be signed in to change notification settings - Fork 2
152 lines (126 loc) · 4.82 KB
/
release-manager.yml
File metadata and controls
152 lines (126 loc) · 4.82 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
140
141
142
143
144
145
146
147
148
149
150
151
152
# 推送 tag v*.*.* 时:构建 Manager 二进制与镜像,并创建 GitHub Release
name: Release (Manager)
on:
push:
tags:
- 'v*.*.*'
concurrency:
group: release-manager-${{ github.ref }}
cancel-in-progress: false
env:
GO_VERSION: "1.26.0"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: go.sum
- name: Run tests
run: go test -v ./cmd/runner-manager/... ./internal/...
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#v}
COMMIT=$(git rev-parse --short HEAD)
BUILD_DATE=$(date -u +%FT%T%z)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT
- name: Build Manager binaries
run: |
mkdir -p dist
VERSION=${{ steps.version.outputs.version }}
LDFLAGS="-s -w -X main.Version=v${VERSION}"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o dist/runner-manager-linux-amd64 ./cmd/runner-manager
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o dist/runner-manager-linux-arm64 ./cmd/runner-manager
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o dist/runner-manager-darwin-amd64 ./cmd/runner-manager
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o dist/runner-manager-darwin-arm64 ./cmd/runner-manager
- name: Generate checksums
run: |
cd dist
sha256sum * > checksums.txt
# Dockerfile 内已 COPY config.yaml.example 为 config/config.yaml 并 sed,无需在 workflow 中准备
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute canonical image name (lowercase for GHCR)
id: vars
shell: bash
run: |
set -eu
CANONICAL="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "canonical=${CANONICAL,,}" >> "$GITHUB_OUTPUT"
- name: Extract metadata (Manager image)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.vars.outputs.canonical }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=true
- name: Build and push Manager Docker image
uses: docker/build-push-action@v6
with:
context: ${{ github.workspace }}
file: ${{ github.workspace }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
name: Release ${{ steps.version.outputs.tag }}
body: |
## Changes
详见提交历史与变更说明。
## 使用方式
### Docker 镜像 (GHCR)
- Manager(管理服务):
```bash
docker pull ${{ steps.vars.outputs.canonical }}:${{ steps.version.outputs.tag }}
```
- Runner 容器镜像(容器模式,同镜像名,tag 带 -runner 后缀,由 Release (Runner) 工作流推送):
```bash
docker pull ${{ steps.vars.outputs.canonical }}:${{ steps.version.outputs.tag }}-runner
```
### 二进制
- Linux AMD64: `runner-manager-linux-amd64`
- Linux ARM64: `runner-manager-linux-arm64`
- macOS AMD64: `runner-manager-darwin-amd64`
- macOS ARM64: `runner-manager-darwin-arm64`
### 校验和
见 `checksums.txt` 中的 SHA256。
draft: false
prerelease: false