Skip to content

Commit

Permalink
ci - fix app version forwarding, remove buildtime as time.Time
Browse files Browse the repository at this point in the history
  • Loading branch information
MindHunter86 committed Nov 19, 2023
1 parent c34a58b commit 178c096
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/addie-code-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
- name: Download all required imports
run: go mod download
- name: Build source code for ${{ matrix.goos }} ${{ matrix.goarch }}
run: go build -ldflags="-s -w -X main.version='${{ needs.parse_phase.outputs.BUILD_GOTAG }}' -X 'main.buildtime=${{ needs.parse_phase.outputs.BUILD_GOTAG }}'" -o ./addie-${{ matrix.goos }}.${{ matrix.goarch }}${{ matrix.extention }}
run: go build -mod=vendor -trimpath -ldflags="-s -w -X 'main.version=${{ needs.parse_phase.outputs.BUILD_GOTAG }}' -X 'main.buildtime=${{ needs.parse_phase.outputs.BUILD_GOTIME }}'" -o ./addie-${{ matrix.goos }}.${{ matrix.goarch }}${{ matrix.extention }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=Dockerfile

ARG GOAPP_MAIN_VERSION=""
ARG GOAPP_MAIN_BUILDTIME=""


# container - builder
FROM golang:1.19.1-alpine AS build
LABEL maintainer="mindhunter86 <mindhunter86@vkom.cc>"

ARG GOAPP_MAIN_VERSION="devel"
ARG GOAPP_MAIN_BUILDTIME="never"

ENV MAIN_VERSION=$GOAPP_MAIN_VERSION
ENV MAIN_BUILDTIME=$GOAPP_MAIN_BUILDTIME

# hadolint/hadolint - DL4006
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

Expand All @@ -17,7 +19,7 @@ COPY . .

ENV CGO_ENABLED=0
RUN echo "ready" \
&& go build -mod=vendor -trimpath -ldflags="-s -w -X main.version=$GOAPP_MAIN_VERSION -X main.buildtime=$GOAPP_MAIN_BUILDTIME" -o addie \
&& go build -mod=vendor -trimpath -ldflags="-s -w -X 'main.version=$MAIN_VERSION' -X 'main.buildtime=$MAIN_BUILDTIME'" -o addie \
&& apk add --no-cache upx \
&& upx -9 -k addie

Expand Down
8 changes: 3 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import (
"github.com/MindHunter86/addie/utils"
)

const btformat = "2006-01-02T15:04:05.000"

var version = "devel" // -ldflags="-X main.version=X.X.X"
var buildtime = time.Now().Format(btformat)
var buildtime = "never"

func main() {
// logger
Expand All @@ -34,8 +32,7 @@ func main() {
cli.VersionFlag = &cli.BoolFlag{Name: "version", Aliases: []string{"V"}}

app.Name = "addie"
app.Compiled, _ = time.Parse(time.RFC3339, buildtime)
app.Version = fmt.Sprintf("%s\t%s", version, app.Compiled.Format(btformat))
app.Version = fmt.Sprintf("%s\t%s", version, buildtime)
app.Authors = []*cli.Author{
&cli.Author{
Name: "MindHunter86",
Expand Down Expand Up @@ -263,6 +260,7 @@ func main() {
log.Info().Msgf("new cpu count %d", runtime.GOMAXPROCS(1))
}

log.Debug().Msgf("%s (%s) builded %s now is ready...", app.Name, version, buildtime)
return application.NewApp(c, &log).Bootstrap()
}

Expand Down

0 comments on commit 178c096

Please sign in to comment.