File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 - name : Set up Go
1919 uses : actions/setup-go@v6
2020 with :
21- go-version : ' 1.25 '
21+ go-version-file : ' go.mod '
2222 cache : false # golangci-lint-action handles its own caching
2323
2424 - name : Run golangci-lint
4545 - name : Set up Go
4646 uses : actions/setup-go@v6
4747 with :
48- go-version : ' 1.25 '
48+ go-version-file : ' go.mod '
4949 cache : true
5050
5151 - name : Run go vet
6262 - name : Set up Go
6363 uses : actions/setup-go@v6
6464 with :
65- go-version : ' 1.25 '
65+ go-version-file : ' go.mod '
6666 cache : true
6767
6868 - name : Install staticcheck
@@ -71,11 +71,25 @@ jobs:
7171 - name : Run staticcheck
7272 run : staticcheck ./...
7373
74+ resolve-go-version :
75+ name : Resolve Go version
76+ runs-on : ubuntu-latest
77+ outputs :
78+ go-version : ${{ steps.go-version.outputs.version }}
79+ steps :
80+ - name : Checkout code
81+ uses : actions/checkout@v5
82+
83+ - name : Extract Go version from go.mod
84+ id : go-version
85+ run : echo "version=$(grep '^go ' go.mod | awk '{print $2}')" >> "$GITHUB_OUTPUT"
86+
7487 build :
7588 name : Build (Alpine)
89+ needs : resolve-go-version
7690 runs-on : ubuntu-latest
7791 container :
78- image : golang:1.25 -alpine
92+ image : golang:${{ needs.resolve-go-version.outputs.go-version }} -alpine
7993
8094 steps :
8195 - name : Install build dependencies
@@ -101,7 +115,7 @@ jobs:
101115 - name : Set up Go
102116 uses : actions/setup-go@v6
103117 with :
104- go-version : ' 1.25 '
118+ go-version-file : ' go.mod '
105119 cache : true
106120
107121 - name : Install Java (for JVM tests)
Original file line number Diff line number Diff line change 11# syntax=docker/dockerfile:1.6
22
3- FROM golang:1.25.8-alpine AS builder
3+ ARG GO_VERSION
4+ FROM golang:${GO_VERSION}-alpine AS builder
45
56RUN apk add --no-cache \
67 clang \
Original file line number Diff line number Diff line change 1- FROM golang:1.25.8-alpine AS builder
1+ ARG GO_VERSION
2+ FROM golang:${GO_VERSION}-alpine AS builder
23WORKDIR /app
34RUN apk add --no-cache \
45 clang \
@@ -15,8 +16,8 @@ FROM scratch AS final
1516COPY --from=builder /app/cmd/yc/yc /yc
1617ENTRYPOINT ["/yc"]
1718
18- ### command to build yc file
19+ ### command to build yc file (GO_VERSION is read from go.mod)
1920## If ARM64
20- # docker buildx build -f Dockerfile.linux --target final -o type=local,dest=./bin/linux/arm64 .
21+ # docker buildx build -f Dockerfile.linux --build-arg GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') -- target final -o type=local,dest=./bin/linux/arm64 .
2122## If x86_64
22- # docker buildx build -f Dockerfile.linux --target final -o type=local,dest=./bin/linux/amd64 .
23+ # docker buildx build -f Dockerfile.linux --build-arg GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') -- target final -o type=local,dest=./bin/linux/amd64 .
Original file line number Diff line number Diff line change 11CWD := $(shell pwd)
2+ GO_VERSION := $(shell grep '^go ' go.mod | awk '{print $$2}')
23
34IMAGE_NAME := yc-360-script-base:alpine
45CONTAINER_NAME := yc-360-script-base-alpine
910 echo " default"
1011
1112alpine :
12- docker build -f Dockerfile.base.alpine -t $(IMAGE_NAME ) .
13+ docker build --build-arg GO_VERSION= $( GO_VERSION ) - f Dockerfile.base.alpine -t $(IMAGE_NAME ) .
1314
1415base : alpine
1516 docker rm -f $(CONTAINER_NAME ) || true
@@ -35,6 +36,7 @@ build-all:
3536
3637 # linux/amd64
3738 docker buildx build \
39+ --build-arg GO_VERSION=$(GO_VERSION) \
3840 --platform linux/amd64 \
3941 -f Dockerfile.base.alpine \
4042 --target export \
@@ -43,6 +45,7 @@ build-all:
4345
4446 # linux/arm64
4547 docker buildx build \
48+ --build-arg GO_VERSION=$(GO_VERSION) \
4649 --platform linux/arm64 \
4750 -f Dockerfile.base.alpine \
4851 --target export \
You can’t perform that action at this time.
0 commit comments