Skip to content

Commit 9748370

Browse files
committedFeb 21, 2025
Add NO_SNAPSHOT mode for releases
1 parent d24a115 commit 9748370

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed
 

‎.github/workflows/release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Set up Docker Buildx
5656
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
5757
- name: Build and push Docker image
58-
run: docker buildx build --platform=linux/amd64,linux/arm64,linux/arm/v7 . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
58+
run: docker buildx build --platform=linux/amd64,linux/arm64,linux/arm/v7 . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" --build-arg NO_SNAPSHOT=true
5959
- name: Log in to registry
6060
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
6161
- name: Push image
@@ -73,4 +73,5 @@ jobs:
7373
echo VERSION=$VERSION
7474
docker buildx build --push \
7575
--tag $IMAGE_ID:$VERSION \
76+
--build-arg NO_SNAPSHOT=true \
7677
--platform linux/amd64,linux/arm64,linux/arm/v7 .

‎.goreleaser.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,8 @@ builds:
1818
- darwin
1919
goamd64:
2020
- v3
21-
22-
# - main: ./cmd/server/
23-
# env:
24-
# - CGO_ENABLED=0
25-
# id: rwp-server
26-
# binary: rwp-server
27-
# goos:
28-
# - linux
29-
# - windows
30-
# - darwin
21+
ldflags:
22+
- -s -w
3123

3224
archives:
3325
- formats: tar.gz

‎Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM --platform=$BUILDPLATFORM golang:1-bookworm@sha256:3149bc5043fa58cf127fd8db1fdd4e533b6aed5a40d663d4f4ae43d20386665f AS builder
22
ARG BUILDARCH TARGETOS TARGETARCH
3+
ARG NO_SNAPSHOT=false
34

45
# Install GoReleaser
56
RUN wget --no-verbose "https://github.com/goreleaser/goreleaser/releases/download/v2.7.0/goreleaser_2.7.0_$BUILDARCH.deb"
@@ -17,15 +18,15 @@ RUN go mod download
1718
# Copy local code to the container image.
1819
COPY . ./
1920

20-
RUN git fetch --tags
2121
RUN git describe --tags --always
2222

2323
# RUN git lfs pull && ls -alh publications
2424

2525
# Run goreleaser
2626
RUN --mount=type=cache,target=/root/.cache/go-build \
2727
--mount=type=cache,target=/go/pkg \
28-
GOOS=$TARGETOS GOARCH=$TARGETARCH GOAMD64=v3 goreleaser build --single-target --id rwp --skip=validate --snapshot --output ./rwp
28+
GOOS=$TARGETOS GOARCH=$TARGETARCH GOAMD64=v3 \
29+
goreleaser build --single-target --id rwp --skip=validate $(case "$NO_SNAPSHOT" in yes|true|1) ;; *) echo "--snapshot";; esac) --output ./rwp
2930

3031
# Run tests
3132
# FROM builder AS tester

0 commit comments

Comments
 (0)
Please sign in to comment.