Skip to content

Commit

Permalink
update golang
Browse files Browse the repository at this point in the history
  • Loading branch information
childe committed Aug 6, 2024
1 parent 22f96b8 commit 310b012
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Push Docker Image
on:
push:
tags:
- 'v*'
- "v*"

jobs:
docker-build-push:
Expand All @@ -20,7 +20,7 @@ jobs:
go-version: 1.22

- name: Test
run: go test -v ./...
run: make test

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18-alpine3.15 as build
FROM golang:1.22 as build

RUN apk update && apk add make

Expand All @@ -7,7 +7,7 @@ COPY . .

RUN make

FROM alpine:3.15
FROM alpine:3.20

ARG TZ="Asia/Shanghai"
ENV TZ ${TZ}
Expand All @@ -16,4 +16,4 @@ RUN apk upgrade --update
RUN apk --update add tzdata
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime

COPY --from=build /gohangout/build/gohangout /usr/local/bin/
COPY --from=build /gohangout/gohangout /usr/local/bin/
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ tag?=$(hash)
.PHONY: gohangout all clean check test docker linux-binary

gohangout:
mkdir -p build/
CGO_ENABLED=0 go build -ldflags "-X main.version=$(hash)" -o build/gohangout
CGO_ENABLED=0 go build -ldflags "-X main.version=$(hash)" -o gohangout

linux-binary:
mkdir -p build
@echo "Building gohangout binary in docker container"
@if [ -n "$(GOPATH)" ]; then\
docker run -e CGO_ENABLED=0 -v $(GOPATH):/go -v $(PWD):/gohangout -w /gohangout golang:1.18 go build -ldflags "-X main.version=$(hash)" -o build/gohangout;\
docker run -e CGO_ENABLED=0 -v $(GOPATH):/go -v $(PWD):/gohangout -w /gohangout golang:1.22 go build -ldflags "-X main.version=$(hash)" -o build/gohangout;\
else\
docker run -e CGO_ENABLED=0 -v $(PWD):/gohangout -w /gohangout golang:1.18 go build -ldflags "-X main.version=$(hash)" -o build/gohangout;\
docker run -e CGO_ENABLED=0 -v $(PWD):/gohangout -w /gohangout golang:1.22 go build -ldflags "-X main.version=$(hash)" -o build/gohangout;\
fi

docker: linux-binary
Expand All @@ -31,10 +30,10 @@ all: check
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.version=$(hash)" -o build/gohangout-darwin-x64-$(tag)

clean:
rm -rf build/*
rm -rf gohangout

check:
git diff-index --quiet HEAD --

test:
go test -v ./... -covermode=atomic -coverprofile=coverage.out
go test -v -gcflags="all=-N -l" ./...

0 comments on commit 310b012

Please sign in to comment.