File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,12 +31,25 @@ jobs:
3131 username : ${{ github.actor }}
3232 password : ${{ secrets.GITHUB_TOKEN }} # packages:write [oai_citation:2‡GitHub](https://github.com/docker/login-action?utm_source=chatgpt.com)
3333
34+ - name : Extract version
35+ id : extract_version
36+ run : |
37+ if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
38+ VERSION="${GITHUB_REF#refs/tags/}"
39+ else
40+ VERSION="dev"
41+ fi
42+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
43+ echo "✓ Version: $VERSION"
44+
3445 - name : Build and push (multi-arch)
3546 uses : docker/build-push-action@v6
3647 with :
3748 context : .
3849 push : true
3950 platforms : linux/amd64,linux/arm64
51+ build-args : |
52+ VERSION=${{ steps.extract_version.outputs.version }}
4053 tags : |
4154 ghcr.io/${{ github.repository }}:latest
4255 ghcr.io/${{ github.repository }}:${{ github.sha }}
Original file line number Diff line number Diff line change @@ -242,6 +242,8 @@ jobs:
242242 context : .
243243 push : true
244244 platforms : linux/amd64,linux/arm64
245+ build-args : |
246+ VERSION=${{ steps.tag_version.outputs.version }}
245247 tags : |
246248 ghcr.io/${{ github.repository }}:latest
247249 ghcr.io/${{ github.repository }}:${{ steps.tag_version.outputs.version }}
Original file line number Diff line number Diff line change @@ -11,8 +11,11 @@ RUN go mod download
1111COPY . .
1212RUN go mod tidy
1313
14- # Build the binary
15- RUN CGO_ENABLED=0 GOOS=linux go build -o awmg .
14+ # Build argument for version (defaults to "dev")
15+ ARG VERSION=dev
16+
17+ # Build the binary with version information
18+ RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X main.Version=${VERSION}" -o awmg .
1619
1720# Runtime stage
1821FROM alpine:latest
You can’t perform that action at this time.
0 commit comments