Repository navigation
72 lines (64 loc) · 2.38 KB
/
Copy pathdocker-build-multi-arch.yml
File metadata and controls
72 lines (64 loc) · 2.38 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: Docker build
on:
workflow_dispatch:
inputs:
tag:
description: "Annotated stable tag to build, for example vX.Y.Z"
required: true
type: string
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v5
with:
ref: ${{ inputs.tag }}
fetch-depth: 0
- name: Read build metadata
id: build_metadata
env:
RELEASE_TAG: ${{ inputs.tag }}
run: |
version=$(PYTHONPATH=src python3 -c 'from cbicall import __version__; print(__version__)')
test "$(git cat-file -t "refs/tags/$RELEASE_TAG")" = "tag" || {
echo "Docker release tag $RELEASE_TAG must be annotated"
exit 1
}
test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)" || {
echo "Checked-out commit does not match Docker release tag $RELEASE_TAG"
exit 1
}
python -c 'import re, sys; version = sys.argv[1]; sys.exit(0 if re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", version) else f"Docker version must be stable X.Y.Z, got {version}")' "$version"
test "$RELEASE_TAG" = "v$version" || {
echo "Docker tag $RELEASE_TAG does not match package version $version"
exit 1
}
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push multi-arch image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: true
build-args: |
CBICALL_VERSION=${{ steps.build_metadata.outputs.version }}
VCS_REF=${{ steps.build_metadata.outputs.revision }}
tags: |
manuelrueda/cbicall:${{ steps.build_metadata.outputs.version }}
manuelrueda/cbicall:latest
platforms: linux/amd64,linux/arm64