Skip to content

Commit 97e0d00

Browse files
committed
enable multiarch, amd64 and arm64
also applies semantic versions based on tags
1 parent 87d5987 commit 97e0d00

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

.github/workflows/docker-publish.yml

+41-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
# Step 1: Check out the repository
1414
- name: Checkout code
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616

1717
# Step 2: Log in to Docker Hub
1818
- name: Log in to Docker Hub
@@ -21,12 +21,44 @@ jobs:
2121
username: ${{ secrets.DOCKER_USERNAME }}
2222
password: ${{ secrets.DOCKER_PASSWORD }}
2323

24-
# Step 3: Build the Docker image
25-
- name: Build Docker Image
26-
run: |
27-
docker build -t dumbwareio/dumbdrop:latest .
24+
# Step 3: Setup QEMU to enable multiarch builds
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v3
2827

29-
# Step 4: Push the Docker image to Docker Hub
30-
- name: Push Docker Image
31-
run: |
32-
docker push dumbwareio/dumbdrop:latest
28+
# Step 4: Set up docker buildx
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
# Step 5: Extract metadata and set versions
33+
- name: Extract metadata (tags, labels) for Docker
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
# image name is dumbdrop, in the docker user's repo
38+
# this allows the push to work in forks
39+
images: |
40+
name=${{ secrets.DOCKER_USERNAME }}/dumbdrop
41+
tags: |
42+
# the semantic versioning tags add "latest" when a version tag is present
43+
# but since version tags aren't being used (yet?) let's add "latest" anyway
44+
type=raw,value=latest
45+
# output x.y.z, based on a tag vx.y.z (e.g. 1.1.2 for a tag v1.1.2)
46+
type=semver,pattern={{version}}
47+
# output x.y, based on a tag vx.y.z
48+
type=semver,pattern={{major}}.{{minor}}
49+
# output x, based on a tag vx.y.z, disabled if x is zero
50+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
51+
# full length sha
52+
type=sha,format=long
53+
54+
# Step 6: build and push the image for multiple archs
55+
- name: Build and push Docker image
56+
id: push
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: .
60+
push: true
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
# build and push for amd64 and arm64 platforms
64+
platforms: linux/amd64,linux/arm64

0 commit comments

Comments
 (0)