Skip to content

Commit

Permalink
Add NO_SNAPSHOT mode for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolatkey committed Feb 21, 2025
1 parent d24a115 commit 9748370
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- name: Build and push Docker image
run: docker buildx build --platform=linux/amd64,linux/arm64,linux/arm/v7 . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
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
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
Expand All @@ -73,4 +73,5 @@ jobs:
echo VERSION=$VERSION
docker buildx build --push \
--tag $IMAGE_ID:$VERSION \
--build-arg NO_SNAPSHOT=true \
--platform linux/amd64,linux/arm64,linux/arm/v7 .
12 changes: 2 additions & 10 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ builds:
- darwin
goamd64:
- v3

# - main: ./cmd/server/
# env:
# - CGO_ENABLED=0
# id: rwp-server
# binary: rwp-server
# goos:
# - linux
# - windows
# - darwin
ldflags:
- -s -w

archives:
- formats: tar.gz
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM --platform=$BUILDPLATFORM golang:1-bookworm@sha256:3149bc5043fa58cf127fd8db1fdd4e533b6aed5a40d663d4f4ae43d20386665f AS builder
ARG BUILDARCH TARGETOS TARGETARCH
ARG NO_SNAPSHOT=false

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

RUN git fetch --tags
RUN git describe --tags --always

# RUN git lfs pull && ls -alh publications

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

# Run tests
# FROM builder AS tester
Expand Down

0 comments on commit 9748370

Please sign in to comment.