-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 2.4 KB
/
docker-build.yml
File metadata and controls
72 lines (61 loc) · 2.4 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
name: Build and Push Docker Image
on:
workflow_dispatch:
inputs:
release_tag:
description: "The tag of the latest release"
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# Step 1: 检出代码
- name: Checkout code
uses: actions/checkout@v3
# Step 2: 验证 Release Tag
- name: Validate Release Tag
run: |
if [ -z "${{ github.event.inputs.release_tag }}" ]; then
echo "Error: release_tag is not set!"
exit 1
fi
# Step 3: 设置 QEMU 支持多平台构建
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
# Step 4: 设置 Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Step 5: 登录 DockerHub
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Step 6: 构建并推送 Docker 镜像
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
latelan/cryptomator-cli:${{ github.event.inputs.release_tag }}
latelan/cryptomator-cli:latest
build-args: |
RELEASE_TAG=${{ github.event.inputs.release_tag }}
# 新增 Step 7: 验证镜像基础功能
- name: Verify Image Functionality
run: |
# 测试 amd64 架构镜像(GitHub Runner 原生支持)
docker pull latelan/cryptomator-cli:${{ github.event.inputs.release_tag }} --platform linux/amd64
docker run --rm --platform linux/amd64 latelan/cryptomator-cli:${{ github.event.inputs.release_tag }} --version
# 测试 arm64 架构镜像(通过 QEMU 模拟)
docker pull latelan/cryptomator-cli:${{ github.event.inputs.release_tag }} --platform linux/arm64
docker run --rm --platform linux/arm64 latelan/cryptomator-cli:${{ github.event.inputs.release_tag }} --help
# 验证版本号匹配
if ! docker run --rm latelan/cryptomator-cli:${{ github.event.inputs.release_tag }} --version | grep -q "${{ github.event.inputs.release_tag }}"; then
echo "Version check failed!"
exit 1
fi