Skip to content

Commit 4fa3f51

Browse files
zerg-suKirill Azovtsev
andauthored
ci - update tag creation logic (#7)
Co-authored-by: Kirill Azovtsev <[email protected]>
1 parent 2f2b59b commit 4fa3f51

File tree

4 files changed

+103
-9
lines changed

4 files changed

+103
-9
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,72 @@ jobs:
1010
build:
1111
runs-on: ${{ matrix.runner }}
1212
strategy:
13+
fail-fast: false
1314
matrix:
1415
include:
1516
- runner: ubuntu-24.04
1617
arch: amd64
1718
- runner: ubuntu-24.04-arm
1819
arch: arm64
1920

21+
outputs:
22+
image-tag: ${{ steps.tag.outputs.tag }}
23+
2024
steps:
2125
- name: "Checkout code"
2226
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: "Generate image tag"
31+
id: tag
32+
run: |
33+
GIT_COMMIT=$(git rev-parse --short=7 HEAD)
34+
echo "tag=${GIT_COMMIT}" >> $GITHUB_OUTPUT
35+
echo "platform-tag=${GIT_COMMIT}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
2336
2437
- name: "Login to Docker Hub"
2538
uses: docker/login-action@v3
2639
with:
2740
username: ${{ secrets.DOCKER_USERNAME }}
2841
password: ${{ secrets.DOCKER_TOKEN }}
29-
30-
- name: "Build and Test Docker Image"
42+
43+
- name: "Build Docker image"
44+
run: make docker_image
3145
env:
3246
PLATFORM: ${{ matrix.arch }}
33-
run: |
34-
make docker_image DOCKER_TAG=${{ github.sha }}
35-
make docker_test
36-
37-
- name: "Push Docker image"
47+
DOCKER_TAG: ${{ steps.tag.outputs.platform-tag }}
48+
49+
- name: "Test Docker image"
50+
run: make docker_test
3851
env:
3952
PLATFORM: ${{ matrix.arch }}
53+
DOCKER_TAG: ${{ steps.tag.outputs.platform-tag }}
54+
55+
- name: "Push Docker image"
4056
run: make docker_push
57+
env:
58+
PLATFORM: ${{ matrix.arch }}
59+
DOCKER_TAG: ${{ steps.tag.outputs.platform-tag }}
60+
61+
manifest:
62+
runs-on: ubuntu-latest
63+
needs: build
64+
if: success()
65+
66+
steps:
67+
- name: "Checkout code"
68+
uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 0
71+
72+
- name: "Login to Docker Hub"
73+
uses: docker/login-action@v3
74+
with:
75+
username: ${{ secrets.DOCKER_USERNAME }}
76+
password: ${{ secrets.DOCKER_TOKEN }}
77+
78+
- name: "Create and push manifest"
79+
run: make docker_manifest
80+
env:
81+
DOCKER_TAG: ${{ needs.build.outputs.image-tag }}

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ DOCKER_BUILDKIT ?= 1
2323
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
2424
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
2525

26-
.PHONY: help docker_image docker_push docker_clean info security_scan
26+
.PHONY: help docker_image docker_push docker_clean info security_scan docker_manifest
2727

2828
help: ## Show this help message
2929
@echo "BeamSim Docker Build"
@@ -134,6 +134,17 @@ docker_size: ## Show image size information
134134
@echo "Layer breakdown:"
135135
docker history $(FULL_IMAGE_NAME)
136136

137+
# Create and push multi-architecture manifest
138+
docker_manifest: ## Create and push multi-architecture manifest
139+
@echo "Creating multi-architecture manifest for $(DOCKER_TAG)..."
140+
docker manifest create --amend \
141+
$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(DOCKER_TAG) \
142+
$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(DOCKER_TAG)-amd64 \
143+
$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(DOCKER_TAG)-arm64
144+
@echo "Pushing manifest..."
145+
docker manifest push $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(DOCKER_TAG)
146+
@echo "Multi-architecture manifest created and pushed successfully!"
147+
137148
# Clean all
138149
clean: docker_clean ## Clean all build artifacts
139150
@echo "Cleaning build artifacts..."

docs/BUILD.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,22 @@ make docker_buildx
211211
make docker_buildx DOCKER_REGISTRY=your-registry.com/beamsim
212212
```
213213

214+
### Manual Multi-Architecture Workflow
215+
216+
For more control over the build process, you can build each architecture separately and create a manifest:
217+
218+
```bash
219+
# Build for each architecture
220+
make docker_image PLATFORM=amd64 DOCKER_TAG=v1.0.0-amd64
221+
make docker_push DOCKER_TAG=v1.0.0-amd64
222+
223+
make docker_image PLATFORM=arm64 DOCKER_TAG=v1.0.0-arm64
224+
make docker_push DOCKER_TAG=v1.0.0-arm64
225+
226+
# Create multi-architecture manifest
227+
make docker_manifest DOCKER_TAG=v1.0.0 DOCKER_REGISTRY=your-registry.com
228+
```
229+
214230
**Note**: Multi-platform builds automatically push to the registry (default: `qdrvm`). Make sure you're logged in:
215231
```bash
216232
docker login # For Docker Hub (default)

docs/MAKEFILE.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ make docker_push DOCKER_REGISTRY=ghcr.io/myorg
7474
- Docker login credentials configured
7575
- Image must be built first
7676

77+
### `docker_manifest`
78+
Creates and pushes multi-architecture manifest from existing platform-specific images.
79+
80+
```bash
81+
make docker_manifest DOCKER_TAG=v1.0.0 DOCKER_REGISTRY=your-registry.com
82+
```
83+
84+
**Requirements:**
85+
- Both `amd64` and `arm64` images must already be pushed to registry
86+
- `DOCKER_REGISTRY` must be set
87+
- Docker login credentials configured
88+
89+
**Process:**
90+
1. Creates manifest referencing remote platform-specific images (`-amd64` and `-arm64` tagged)
91+
2. Pushes manifest to registry under the specified tag
92+
3. Enables `docker pull` to automatically select correct architecture
93+
94+
**Note:** This command works directly with remote registry images without pulling them locally. The `--amend` flag allows overwriting existing manifests if needed.
95+
7796
## Development Targets
7897

7998
### `docker_shell`
@@ -239,8 +258,15 @@ make docker_push
239258
make docker_image PLATFORM=amd64
240259
make docker_image PLATFORM=arm64
241260

242-
# Multi-platform release
261+
# Multi-platform release (automated)
243262
make docker_buildx
263+
264+
# Multi-platform release (manual)
265+
make docker_image PLATFORM=amd64 DOCKER_TAG=v1.0.0-amd64
266+
make docker_push DOCKER_TAG=v1.0.0-amd64
267+
make docker_image PLATFORM=arm64 DOCKER_TAG=v1.0.0-arm64
268+
make docker_push DOCKER_TAG=v1.0.0-arm64
269+
make docker_manifest DOCKER_TAG=v1.0.0
244270
```
245271

246272
### Experimentation

0 commit comments

Comments
 (0)