Skip to content

Commit 33aa0b4

Browse files
authored
Merge pull request #145 from githubnext/copilot/review-protocol-version
2 parents e81f5cd + 9993216 commit 33aa0b4

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/container.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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 }}

.github/workflows/release.lock.yml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/release.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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 }}

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ RUN go mod download
1111
COPY . .
1212
RUN 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
1821
FROM alpine:latest

0 commit comments

Comments
 (0)