-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (86 loc) · 2.96 KB
/
release-agent.yml
File metadata and controls
100 lines (86 loc) · 2.96 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
# 推送 tag v*.*.* 时:构建并推送 Runner 容器镜像(Agent,tag 带 -runner 后缀)
name: Release (Runner)
on:
push:
tags:
- 'v*.*.*'
concurrency:
group: release-runner-${{ github.ref }}
cancel-in-progress: false
env:
GO_VERSION: "1.26.0"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
name: Build and push Runner image
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
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-agent/... ./internal/...
- 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 (for tag)
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: Prepare Runner tags (same image, tag suffix -runner)
id: runner-tags
run: |
echo "tags<<EOF" >> "$GITHUB_OUTPUT"
# metadata-action 可能输出逗号/换行分隔;每行 image:tag 转为 image:tag-runner
echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | while IFS= read -r line; do
[ -z "$line" ] && continue
if [[ "$line" == *:* ]]; then
echo "$line" | sed 's/\(:.*\)$/\1-runner/'
else
echo "${line}:latest-runner"
fi
done >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Build and push Runner Docker image (container mode)
uses: docker/build-push-action@v6
with:
context: ${{ github.workspace }}
file: ${{ github.workspace }}/Dockerfile.runner
push: true
tags: ${{ steps.runner-tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64