mirror of
https://github.com/komari-monitor/komari.git
synced 2025-10-23 03:31:56 +00:00
ci/cd: 版本信息构建
This commit is contained in:
7
.github/workflows/development.yml
vendored
7
.github/workflows/development.yml
vendored
@@ -12,8 +12,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
#- name: Create dummy index.html
|
#- name: Create dummy index.html
|
||||||
# run: |
|
# run: |
|
||||||
# mkdir -p public/dist
|
# mkdir -p public/dist
|
||||||
@@ -39,7 +39,8 @@ jobs:
|
|||||||
GOOS: linux
|
GOOS: linux
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
run: |
|
run: |
|
||||||
go build -o komari .
|
VERSION_SHA="${{ github.sha }}"
|
||||||
|
go build -ldflags "-X github.com/komari-monitor/komari/utils.CurrentVersion=dev -X github.com/komari-monitor/komari/utils.VersionHash=${VERSION_SHA}" -o komari .
|
||||||
|
|
||||||
- name: Upload binary as artifact
|
- name: Upload binary as artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
3
.github/workflows/docker-publish.yml
vendored
3
.github/workflows/docker-publish.yml
vendored
@@ -44,3 +44,6 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ github.ref_name }}
|
||||||
|
VERSION_HASH=${{ github.sha }}
|
||||||
|
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
@@ -55,7 +55,9 @@ jobs:
|
|||||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||||
BINARY_NAME=${BINARY_NAME}.exe
|
BINARY_NAME=${BINARY_NAME}.exe
|
||||||
fi
|
fi
|
||||||
go build -trimpath -ldflags="-s -w" -o $BINARY_NAME
|
VERSION="${{ github.event.release.tag_name }}"
|
||||||
|
VERSION_HASH="${{ github.sha }}"
|
||||||
|
go build -trimpath -ldflags="-s -w -X github.com/komari-monitor/komari/utils.CurrentVersion=${VERSION} -X github.com/komari-monitor/komari/utils.VersionHash=${VERSION_HASH}" -o $BINARY_NAME
|
||||||
|
|
||||||
- name: Upload binary to release
|
- name: Upload binary to release
|
||||||
env:
|
env:
|
||||||
@@ -97,4 +99,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ github.event.release.tag_name }}
|
||||||
|
VERSION_HASH=${{ github.sha }}
|
@@ -16,8 +16,10 @@ COPY . .
|
|||||||
COPY --from=frontend /web/dist ./public/dist
|
COPY --from=frontend /web/dist ./public/dist
|
||||||
|
|
||||||
ENV CGO_ENABLED=1
|
ENV CGO_ENABLED=1
|
||||||
|
ARG VERSION=unknown
|
||||||
|
ARG VERSION_HASH=unknown
|
||||||
# RUN CC=musl-gcc go build -trimpath -ldflags="-s -w -linkmode external -extldflags -static" -o komari .
|
# RUN CC=musl-gcc go build -trimpath -ldflags="-s -w -linkmode external -extldflags -static" -o komari .
|
||||||
RUN go build -trimpath -ldflags="-s -w -linkmode external -extldflags -static" -o komari .
|
RUN go build -trimpath -ldflags="-s -w -linkmode external -extldflags -static -X github.com/komari-monitor/komari/utils.CurrentVersion=${VERSION} -X github.com/komari-monitor/komari/utils.VersionHash=${VERSION_HASH}" -o komari .
|
||||||
|
|
||||||
# FROM scratch
|
# FROM scratch
|
||||||
FROM alpine:3.21
|
FROM alpine:3.21
|
||||||
|
6
utils/version.go
Normal file
6
utils/version.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
var (
|
||||||
|
CurrentVersion = "0.0.1"
|
||||||
|
VersionHash = "unknown"
|
||||||
|
)
|
Reference in New Issue
Block a user