|
12 | 12 |
|
13 | 13 | permissions: |
14 | 14 | contents: write |
| 15 | + packages: write |
15 | 16 |
|
16 | 17 | env: |
17 | 18 | CARGO_TERM_COLOR: always |
@@ -254,10 +255,76 @@ jobs: |
254 | 255 | env: |
255 | 256 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
256 | 257 |
|
| 258 | + # Build and push multi-arch Docker image to GHCR (only on tag push, not dry-run) |
| 259 | + docker: |
| 260 | + name: Docker Image |
| 261 | + if: github.ref_type == 'tag' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run) |
| 262 | + runs-on: ubuntu-latest |
| 263 | + steps: |
| 264 | + - uses: actions/checkout@v4 |
| 265 | + |
| 266 | + - name: Set up QEMU |
| 267 | + uses: docker/setup-qemu-action@v3 |
| 268 | + |
| 269 | + - name: Set up Docker Buildx |
| 270 | + uses: docker/setup-buildx-action@v3 |
| 271 | + |
| 272 | + - name: Log in to GHCR |
| 273 | + uses: docker/login-action@v3 |
| 274 | + with: |
| 275 | + registry: ghcr.io |
| 276 | + username: ${{ github.actor }} |
| 277 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 278 | + |
| 279 | + - name: Extract metadata |
| 280 | + id: meta |
| 281 | + uses: docker/metadata-action@v5 |
| 282 | + with: |
| 283 | + images: ghcr.io/${{ github.repository }} |
| 284 | + tags: | |
| 285 | + type=semver,pattern={{version}} |
| 286 | + type=semver,pattern={{major}}.{{minor}} |
| 287 | + type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} |
| 288 | + type=raw,value=latest |
| 289 | +
|
| 290 | + - name: Build and push |
| 291 | + uses: docker/build-push-action@v6 |
| 292 | + with: |
| 293 | + context: . |
| 294 | + platforms: linux/amd64,linux/arm64 |
| 295 | + push: true |
| 296 | + tags: ${{ steps.meta.outputs.tags }} |
| 297 | + labels: ${{ steps.meta.outputs.labels }} |
| 298 | + cache-from: type=gha |
| 299 | + cache-to: type=gha,mode=max |
| 300 | + |
| 301 | + # Build multi-arch Docker image without pushing (dry-run validation) |
| 302 | + docker-dry-run: |
| 303 | + name: Docker Image (Dry Run) |
| 304 | + if: github.event_name == 'workflow_dispatch' && inputs.dry_run |
| 305 | + runs-on: ubuntu-latest |
| 306 | + steps: |
| 307 | + - uses: actions/checkout@v4 |
| 308 | + |
| 309 | + - name: Set up QEMU |
| 310 | + uses: docker/setup-qemu-action@v3 |
| 311 | + |
| 312 | + - name: Set up Docker Buildx |
| 313 | + uses: docker/setup-buildx-action@v3 |
| 314 | + |
| 315 | + - name: Build (no push) |
| 316 | + uses: docker/build-push-action@v6 |
| 317 | + with: |
| 318 | + context: . |
| 319 | + platforms: linux/amd64,linux/arm64 |
| 320 | + push: false |
| 321 | + cache-from: type=gha |
| 322 | + cache-to: type=gha,mode=max |
| 323 | + |
257 | 324 | # Dry-run summary (manual dispatch with dry_run=true) |
258 | 325 | dry-run-summary: |
259 | 326 | name: Dry Run Summary |
260 | | - needs: build |
| 327 | + needs: [build, docker-dry-run] |
261 | 328 | if: github.event_name == 'workflow_dispatch' && inputs.dry_run |
262 | 329 | runs-on: ubuntu-latest |
263 | 330 | steps: |
|
0 commit comments