File tree Expand file tree Collapse file tree 6 files changed +29
-7
lines changed
Expand file tree Collapse file tree 6 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 1717 steps :
1818 - name : Check out code
1919 uses : actions/checkout@v5
20+ with :
21+ fetch-tags : true
2022 - id : lc_repo
2123 run : python3 -c'print("out=${{github.repository}}".lower())' >> "$GITHUB_OUTPUT"
24+ - id : git_version
25+ run : echo "out=$(git describe --tags --always)" >> "$GITHUB_OUTPUT"
2226 - name : Log in to the Container registry
2327 uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
2428 with :
4347 platforms : linux/amd64,linux/arm64
4448 tags : ${{ steps.meta.outputs.tags }}
4549 labels : ${{ steps.meta.outputs.labels }}
50+ build-args : " HF_VERSION=${{ steps.git_version.outputs.out }}"
4651 - name : Generate artifact attestation
4752 uses : actions/attest-build-provenance@v2
4853 with :
Original file line number Diff line number Diff line change @@ -38,10 +38,12 @@ jobs:
3838
3939 - name : Check out code
4040 uses : actions/checkout@v5
41+ with :
42+ fetch-tags : true
4143
4244 - name : Build
4345 run : |
44- env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -v -o helmfile-nix-${{ matrix.os }}-${{ matrix.arch }}
46+ env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -v -ldflags="-X main.version=$(git describe --tags) -w -s" - o helmfile-nix-${{ matrix.os }}-${{ matrix.arch }}
4547
4648 - name : Upload Release Asset
4749 uses : actions/upload-release-asset@v1
Original file line number Diff line number Diff line change @@ -3,14 +3,11 @@ FROM golang:1.24.6-bullseye AS builder
33ARG BUILDPLATFORM
44ARG TARGETOS
55ARG TARGETARCH
6+ ARG HF_VERSION="docker-dev"
67
78WORKDIR /app/
89ADD . .
9- RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o helmfile-nix .
10-
11-
12- # Build the binary.
13- RUN go build -mod=readonly -v -o helmfile-nix .
10+ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X main.version=${HF_VERSION} -w -s" -o helmfile-nix .
1411
1512
1613FROM ghcr.io/remarkable/helmfile-nix/nix-alpine:main@sha256:67d8ff0355fe85bf9b52adfa4378d2dc253fba8af23cfdd721a970024e4f8ebd
Original file line number Diff line number Diff line change 11{
2+ version ,
23 pkgs ? (
34 let
45 inherit ( builtins ) fetchTree fromJSON readFile ;
2324in
2425buildGoApplication {
2526 pname = "helmfile-nix" ;
26- version = "0.1" ;
27+ version = version ;
28+ ldflags = "-X main.version=${ version } -w -s" ;
2729 pwd = ./. ;
2830 src = ./. ;
2931 nativeBuildInputs = with pkgs ; [
Original file line number Diff line number Diff line change 2525 {
2626 packages . default = pkgs . callPackage ./. {
2727 inherit ( gomod2nix . legacyPackages . ${ system } ) buildGoApplication ;
28+ version = self . shortRev or self . dirtyShortRev ;
2829 } ;
2930 packages . devenv-up = self . devShells . ${ system } . default . config . procfileScript ;
3031 packages . devenv-test = self . devShells . ${ system } . default . config . test ;
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import (
2121//go:embed eval.nix
2222var eval string
2323
24+ var version = "dev"
25+
2426// List of temporary directories that need to be cleaned up after use.
2527var cleanup []string
2628
@@ -30,6 +32,7 @@ type Options struct {
3032 Env string `short:"e" long:"environment" description:"Environment to deploy to" default:"dev"`
3133 ShowTrace []bool `long:"show-trace" description:"Enable stacktraces"`
3234 StateValuesSet []string `long:"state-values-set" description:"Set state values"`
35+ Version bool `short:"v" long:"version" description:"Print version and exit"`
3336}
3437
3538var (
@@ -51,6 +54,18 @@ func main() {
5154 retcode = 1
5255 return
5356 }
57+ if opts .Version {
58+ fmt .Printf ("helmfile-nix version %s\n " , version )
59+ cmd := exec .Command ("helmfile" , "--version" )
60+ cmd .Stderr = os .Stderr
61+ cmd .Stdout = os .Stdout
62+ callErr := cmd .Run ()
63+ if callErr != nil {
64+ log .Println ("Running helmfile failed: " , err )
65+ retcode = 1
66+ }
67+ return
68+ }
5469
5570 seen := false
5671 for _ , v := range args [1 :] {
You can’t perform that action at this time.
0 commit comments