diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a643ae1..9d5df82 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,8 +27,6 @@ jobs: - name: Setup environment id: environment run: | - GOVERSION=$(make go-version) - echo "GOVERSION=${GOVERSION}" >> $GITHUB_ENV echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV echo "DOCKER_CLI_EXPERIMENTAL=enabled" >> $GITHUB_ENV @@ -36,7 +34,7 @@ jobs: uses: actions/setup-go@v5 id: go with: - go-version: ${{ env.GOVERSION }} + go-version-file: .go-version - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -73,17 +71,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup environment - id: environment - run: | - GOVERSION=$(make go-version) - echo "GOVERSION=${GOVERSION}" >> $GITHUB_ENV - - name: Set up Golang uses: actions/setup-go@v5 id: go with: - go-version: ${{ env.GOVERSION }} + go-version-file: .go-version - name: Install Tools and Dependencies run: make deps @@ -113,15 +105,13 @@ jobs: - name: Setup environment id: environment run: | - GOVERSION=$(make go-version) - echo "GOVERSION=${GOVERSION}" >> $GITHUB_ENV echo "PROMGITHUB_REDIS_ADDR=127.0.0.1:6379" >> $GITHUB_ENV - name: Set up Golang uses: actions/setup-go@v5 id: go with: - go-version: ${{ env.GOVERSION }} + go-version-file: .go-version - name: Install Tools and Dependencies run: make deps diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 788f022..75e57df 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,8 +29,6 @@ jobs: - name: Setup environment id: environment run: | - GOVERSION=$(make go-version) - echo "GOVERSION=${GOVERSION}" >> $GITHUB_ENV echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV echo "DOCKER_CLI_EXPERIMENTAL=enabled" >> $GITHUB_ENV @@ -38,7 +36,7 @@ jobs: uses: actions/setup-go@v5 id: go with: - go-version: ${{ env.GOVERSION }} + go-version-file: .go-version - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.go-version b/.go-version new file mode 100644 index 0000000..ba7b129 --- /dev/null +++ b/.go-version @@ -0,0 +1 @@ +1.25.10 diff --git a/Dockerfile b/Dockerfile index 7c27fd6..e0e5456 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ # Build stage -FROM golang:1.25.9 AS builder +ARG GO_VERSION=1.25.10 +FROM golang:${GO_VERSION} AS builder # Set non-root user for build RUN useradd -u 10001 -m builder diff --git a/Makefile b/Makefile index f53c35f..fa3648e 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ COLOR_RED := \033[31m USERNAME := darthfork TARGET := promgithub SRC := ./... +GO_VERSION := $(shell cat .go-version) LDFLAGS := -X main.Version=$(VERSION) -s -w LDFLAGS_DBG := -X main.enableDebug=true -X main.Version=$(VERSION) BUILDDIR := build @@ -70,7 +71,7 @@ install_tools: deps ## Install development tooling @./utils/install_tools.sh container: ## Build promgithub service container - @docker build --progress=plain -t $(CONTAINER_REGISTRY):$(VERSION) . + @docker build --progress=plain --build-arg GO_VERSION=$(GO_VERSION) -t $(CONTAINER_REGISTRY):$(VERSION) . package-helm-chart: mkdir ## Package promgithub helm chart @helm package $(CHART_SOURCE) -d $(BUILDDIR) @@ -84,6 +85,7 @@ build-cross-platform-binaries: mkdir build-cross-platform-container: ci-check @docker buildx build \ --platform $(PLATFORMS)\ + --build-arg GO_VERSION=$(GO_VERSION) \ -t $(CONTAINER_REGISTRY):$(VERSION) \ --cache-from type=gha,scope=$(TARGET) \ --cache-to type=gha,mode=max,scope=$(TARGET) \ @@ -126,7 +128,7 @@ setup-commit-hooks: @cp .github/hooks/* .git/hooks/ go-version: - @grep '^go ' go.mod | awk '{print $$2}' + @cat .go-version help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile\