Attach version info to binaries

This commit is contained in:
Ben Sarmiento
2023-11-29 23:36:14 +01:00
parent f61ffe82f3
commit 6e54fa760b
2 changed files with 9 additions and 6 deletions

View File

@@ -40,10 +40,10 @@ jobs:
race: false race: false
ldflags: > ldflags: >
-s -w -s -w
-X 'version.BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)' -X 'github.com/debridmediamanager/zurg/internal.BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)'
-X 'version.GoVersion=$(go version)' -X 'github.com/debridmediamanager/zurg/internal.GoVersion=$(go version | cut -d ' ' -f 3)'
-X 'version.GitCommit=$(git rev-parse HEAD)' -X 'github.com/debridmediamanager/zurg/internal.GitCommit=$(git rev-parse HEAD)'
-X 'version.Version=${{ steps.version.outputs.version }}' -X 'github.com/debridmediamanager/zurg/internal.Version=${{ steps.version.outputs.version }}'
buildmode: default buildmode: default
trimpath: true trimpath: true
@@ -57,7 +57,10 @@ jobs:
platform=$(echo $platform | sed 's/.exe//g') platform=$(echo $platform | sed 's/.exe//g')
extension=".exe" extension=".exe"
fi fi
(cd artifacts && zip -r "../compressed_artifacts/zurg-${{ steps.version.outputs.version }}-$platform.zip" "zurg-$platform$extension") cd artifacts
cp -f "zurg-$platform$extension" zurg
zip -r "../compressed_artifacts/zurg-${{ steps.version.outputs.version }}-$platform.zip" zurg
cd ..
done done
- name: Upload artifacts to workflow - name: Upload artifacts to workflow

View File

@@ -11,7 +11,7 @@ FROM golang:1-alpine AS builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN apk add --no-cache bash git go gcc musl-dev curl fuse RUN apk add --no-cache bash git go gcc musl-dev curl fuse
RUN go build -ldflags="-s -w -X 'main.BuiltAt=${BuiltAt}' -X 'main.GoVersion=${GoVersion}' -X 'main.GitCommit=${GitCommit}' -X 'main.Version=${Version}'" -o zurg cmd/zurg/main.go RUN go build -ldflags="-s -w -X 'github.com/debridmediamanager/zurg/internal.BuiltAt=${BuiltAt}' -X 'github.com/debridmediamanager/zurg/internal.GoVersion=${GoVersion}' -X 'github.com/debridmediamanager/zurg/internal.GitCommit=${GitCommit}' -X 'github.com/debridmediamanager/zurg/internal.Version=${Version}'" -o zurg cmd/zurg
# Obfuscation stage # Obfuscation stage
FROM alpine:3 AS obfuscator FROM alpine:3 AS obfuscator