-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (166 loc) · 6.39 KB
/
build-push-rocq.yml
File metadata and controls
189 lines (166 loc) · 6.39 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Build and Push Rocq Image
on:
push:
branches: [main]
tags: ['v*']
paths:
- 'rocq/**'
- '.github/workflows/build-push-rocq.yml'
pull_request:
branches: [main]
paths:
- 'rocq/**'
workflow_run:
workflows: ["Build and Push Images"]
types: [completed]
branches: [main]
workflow_dispatch:
env:
DOCKER_HUB_ROCQ: ${{ secrets.DOCKERHUB_USERNAME }}/ocaml-devcontainer-rocq
GHCR_ROCQ: ghcr.io/${{ github.repository_owner }}/ocaml-devcontainer-rocq
GHCR_DEV: ghcr.io/${{ github.repository_owner }}/ocaml-devcontainer
jobs:
# ============================================================================
# Build Rocq Images (parallel per architecture)
# ============================================================================
build-rocq-amd64:
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Rocq image (amd64)
uses: docker/build-push-action@v6
with:
context: ./rocq
file: ./rocq/Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.GHCR_ROCQ }}:latest-amd64
${{ env.DOCKER_HUB_ROCQ }}:latest-amd64
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
build-args: |
BASE_IMAGE=${{ env.GHCR_DEV }}:latest-amd64
cache-from: type=gha,scope=rocq-amd64
cache-to: type=gha,mode=max,scope=rocq-amd64
build-rocq-arm64:
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Rocq image (arm64)
uses: docker/build-push-action@v6
with:
context: ./rocq
file: ./rocq/Dockerfile
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.GHCR_ROCQ }}:latest-arm64
${{ env.DOCKER_HUB_ROCQ }}:latest-arm64
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
build-args: |
BASE_IMAGE=${{ env.GHCR_DEV }}:latest-arm64
cache-from: type=gha,scope=rocq-arm64
cache-to: type=gha,mode=max,scope=rocq-arm64
# ============================================================================
# Merge Rocq Image Tags into Multi-Arch Manifest
# ============================================================================
merge-rocq:
needs: [build-rocq-amd64, build-rocq-arm64]
if: |
always() &&
needs.build-rocq-amd64.result == 'success' &&
needs.build-rocq-arm64.result == 'success' &&
github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifest (GHCR)
run: |
docker buildx imagetools create -t ${{ env.GHCR_ROCQ }}:latest \
${{ env.GHCR_ROCQ }}:latest-amd64 \
${{ env.GHCR_ROCQ }}:latest-arm64
# Add version tag if this is a release
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
docker buildx imagetools create -t ${{ env.GHCR_ROCQ }}:${VERSION} \
${{ env.GHCR_ROCQ }}:latest-amd64 \
${{ env.GHCR_ROCQ }}:latest-arm64
fi
- name: Create and push multi-arch manifest (Docker Hub)
run: |
docker buildx imagetools create -t ${{ env.DOCKER_HUB_ROCQ }}:latest \
${{ env.DOCKER_HUB_ROCQ }}:latest-amd64 \
${{ env.DOCKER_HUB_ROCQ }}:latest-arm64
# Add version tag if this is a release
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
docker buildx imagetools create -t ${{ env.DOCKER_HUB_ROCQ }}:${VERSION} \
${{ env.DOCKER_HUB_ROCQ }}:latest-amd64 \
${{ env.DOCKER_HUB_ROCQ }}:latest-arm64
fi
- name: Verify multi-arch manifest
run: |
echo "=== GHCR Rocq Image ==="
docker buildx imagetools inspect ${{ env.GHCR_ROCQ }}:latest
echo ""
echo "=== Docker Hub Rocq Image ==="
docker buildx imagetools inspect ${{ env.DOCKER_HUB_ROCQ }}:latest