11name : Build and Publish Docker image to GHCR
22
33on :
4- push :
5- tags : ["v*.*.*"]
64 workflow_dispatch :
5+ inputs :
6+ version :
7+ description : " Version string to tag Docker image with when manually dispatched (e.g., 0.9.2)"
8+ required : false
9+ default : " 0.0.0-dev"
10+ workflow_call :
11+ inputs :
12+ version :
13+ description : " Version string to tag Docker image with when called from another workflow"
14+ type : string
15+ required : false
16+ default : " 0.0.0-dev"
717
818jobs :
919 build-and-push :
3040 id : repo_owner
3141 run : echo "lowercase=$(echo ${GITHUB_REPOSITORY_OWNER} | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
3242
43+ # Determine release version for tagging
44+ - name : Extract release version
45+ id : vars
46+ run : |
47+ TAG="${GITHUB_REF#refs/tags/v}"
48+ if [[ "$TAG" != "$GITHUB_REF" && "$TAG" != "" ]]; then
49+ echo "version=$TAG" >> "$GITHUB_OUTPUT"
50+ else
51+ echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
52+ fi
53+
3354 # Log in to GitHub Container Registry using the auto-generated token
3455 - name : Log in to GHCR
3556 uses : docker/login-action@v3
@@ -44,16 +65,22 @@ jobs:
4465 uses : docker/metadata-action@v5
4566 with :
4667 images : ghcr.io/${{ steps.repo_owner.outputs.lowercase }}/wireport
68+ tags : |
69+ type=semver,pattern={{version}},value=${{ steps.vars.outputs.version }}
70+ type=semver,pattern={{major}}.{{minor}},value=${{ steps.vars.outputs.version }}
71+ type=semver,pattern={{major}},value=${{ steps.vars.outputs.version }}
4772
4873 # Build and push the image defined in wireport/Dockerfile
49- - name : Build and push Docker image
74+ - name : Build & push (inline cache)
5075 uses : docker/build-push-action@v5
5176 with :
52- context : ./
77+ context : .
5378 file : ./Dockerfile
5479 push : true
5580 platforms : linux/amd64,linux/arm64
5681 tags : ${{ steps.meta.outputs.tags }}
5782 labels : ${{ steps.meta.outputs.labels }}
5883 cache-from : type=registry,ref=ghcr.io/${{ steps.repo_owner.outputs.lowercase }}/wireport:buildcache
59- cache-to : type=registry,ref=ghcr.io/${{ steps.repo_owner.outputs.lowercase }}/wireport:buildcache,mode=max
84+ cache-to : type=registry,ref=ghcr.io/${{ steps.repo_owner.outputs.lowercase }}/wireport:buildcache,mode=max
85+ build-args : |
86+ BUILDKIT_INLINE_CACHE=1
0 commit comments