penguin/flatgit

flatgit showcase

commit bdd09021663dcb4b6d0267105cd47964ff810c51

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-06-18T21:18:56Z
subjectupdate github build
commit bdd09021663dcb4b6d0267105cd47964ff810c51
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-06-18T21:18:56Z

    update github build
---
 .github/workflows/ci.yml      | 34 +++++-----------------------------
 dockerfiles/github.Dockerfile |  4 +---
 2 files changed, 6 insertions(+), 32 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d1519cd..44c3610 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -54,41 +54,19 @@ jobs:
     steps:
       - *checkout
 
-      - &set_build_version
-        name: Set build version
-        id: set_build_version
+      - name: Set image name
         shell: bash
         run: |
           set -eu
-
-          if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
-            BUILD_VER="${GITHUB_REF_NAME}"
-          else
-            BUILD_VER="dev-${GITHUB_SHA::12}"
-          fi
-
-          echo "BUILD_VER=${BUILD_VER}" >> "$GITHUB_ENV"
-          echo "build_ver=${BUILD_VER}" >> "$GITHUB_OUTPUT"
-          echo "Build version: ${BUILD_VER}"
-
-      - &set_image_name
-        name: Set image name
-        shell: bash
-        run: |
-          set -eu
-
           image="ghcr.io/${GITHUB_REPOSITORY}"
           image="${image,,}"
-
           echo "IMAGE_NAME=${image}" >> "$GITHUB_ENV"
           echo "Image name: ${image}"
 
-      - &setup_buildx
-        name: Set up Docker Buildx
+      - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v4
 
-      - &login_ghcr
-        name: Login to GHCR
+      - name: Login to GHCR
         uses: docker/login-action@v4
         with:
           registry: ghcr.io
@@ -101,8 +79,8 @@ jobs:
         with:
           images: ${{ env.IMAGE_NAME }}
           tags: |
-            type=raw,value=${{ env.BUILD_VER }}-debian-slim
-            type=raw,value=latest-debian-slim,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
+            type=raw,value=${{ github.ref_name }}-debian-slim
+            type=raw,value=latest-debian-slim
 
       - name: Build and push image
         uses: docker/build-push-action@v7
@@ -111,7 +89,5 @@ jobs:
           file: ./dockerfiles/github.Dockerfile
           platforms: linux/amd64,linux/arm64
           push: true
-          build-args: |
-            BUILD_VER=${{ env.BUILD_VER }}
           tags: ${{ steps.meta.outputs.tags }}
           labels: ${{ steps.meta.outputs.labels }}
diff --git a/dockerfiles/github.Dockerfile b/dockerfiles/github.Dockerfile
index 10995a7..f70fd19 100644
--- a/dockerfiles/github.Dockerfile
+++ b/dockerfiles/github.Dockerfile
@@ -4,7 +4,6 @@ FROM golang:1.26-trixie AS build
 
 ARG TARGETOS
 ARG TARGETARCH
-ARG BUILD_VER=dev
 
 WORKDIR /src
 
@@ -24,7 +23,6 @@ RUN --mount=type=cache,target=/go/pkg/mod \
     GOARCH=${TARGETARCH:-amd64} \
     go build \
       -trimpath \
-      -ldflags="-s -w -X main.version=${BUILD_VER}" \
       -o /out/bin/flatgit \
       ./cmd/flatgit
 
@@ -51,4 +49,4 @@ VOLUME ["/var/lib/flatgit"]
 
 EXPOSE 8080
 
-ENTRYPOINT ["/usr/local/bin/flatgit"]
+ENTRYPOINT ["/usr/local/bin/flatgit"]
\ No newline at end of file