Skip to content

Commit

Permalink
ci: fix build container image and pass missed build args
Browse files Browse the repository at this point in the history
  • Loading branch information
WoozyMasta committed Jan 16, 2025
1 parent 2ffc1ea commit f4b17bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
ghcr.io/woozymasta/dayz-exporter:latest
docker.io/woozymasta/dayz-exporter:${{ steps.env.outputs.image_tag }}
docker.io/woozymasta/dayz-exporter:latest
build-args: |
VERSION=${{ github.ref_name }}
COMMIT=${{ github.sha }}
- name: Extract changelog
id: changelog
Expand Down
17 changes: 11 additions & 6 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ RUN set -xeu; \
tar -xvf upx.tar.xz --strip-components=1 "upx-$UPX_VERSION-${ARCH}_linux/upx"; \
chmod +x upx; \
mv upx /usr/local/bin/upx; \
rm -f upx.tar.xz
rm -f upx.tar.xz; \
go install github.com/tdewolff/minify/cmd/minify@latest

WORKDIR /src/dayz-exporter
COPY go.mod go.sum ./
COPY ./internal/vars ./internal/vars
RUN go mod download

ENV CGO_ENABLED=0
Expand All @@ -27,13 +29,16 @@ ENV GOARCH=$ARCH

COPY ./cli ./cli
COPY ./pkg ./pkg
COPY ./internal ./internal

RUN set -eux;\
pkg="$(grep -Po 'module \K.*$' go.mod)/pkg/config"; \
version="$pkg.Version=$VERSION"; \
commit="$pkg.Commit=$COMMIT"; \
date="$pkg.BuildTime=$(date -uIs)"; \
go build -ldflags="-s -w -X '$version' -X '$commit' -X '$date'" \
go mod tidy; \
go generate ./...; \
go build -ldflags="-s -w \
-X 'internal/vars.Version=$VERSION' \
-X 'internal/vars.Commit=$COMMIT' \
-X 'internal/vars.BuildTime=$(date -uIs)' \
-X 'internal/vars.URL=https://$(grep -Po 'module \K.*$' go.mod)'" \
-o "./dayz-exporter" "cli/"*.go; \
upx --lzma --best ./dayz-exporter; \
upx -t ./dayz-exporter
Expand Down

0 comments on commit f4b17bf

Please sign in to comment.