diff --git a/Dockerfile b/Dockerfile index 665aafa..35688a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,9 @@ RUN apk add --no-cache \ # The builder build stage compiles the Go code into a static binary. FROM golang:1.16-alpine as builder -ARG VERSION=development +ARG CREATED +ARG REVISION +ARG VERSION WORKDIR /go/src/github.com/joshdk/drone-skip-pipeline @@ -21,7 +23,11 @@ COPY . . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ -o /bin/drone-skip-pipeline \ - -ldflags "-s -w" \ + -ldflags "-s -w \ + -X 'jdk.sh/meta.date=$CREATED' \ + -X 'jdk.sh/meta.sha=$REVISION' \ + -X 'jdk.sh/meta.version=$VERSION' \ + " \ -trimpath \ main.go diff --git a/go.mod b/go.mod index 06f0f78..a060ec2 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/joshdk/drone-skip-pipeline go 1.17 + +require jdk.sh/meta v0.1.1-0.20211021015548-cff3b930ebd9 diff --git a/go.sum b/go.sum new file mode 100644 index 000000000..11f8c12 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +jdk.sh/meta v0.1.0 h1:BTDH9cL/el15OSZWRcnbdOzynyr7hlRlYrTSJCrcKbo= +jdk.sh/meta v0.1.0/go.mod h1:c2+wWgMZejSQ2nXsbxNVKLLQgTLY4yrX7TH6NIaQle0= +jdk.sh/meta v0.1.1-0.20211021015548-cff3b930ebd9 h1:f9CEE/IWIjsG3jBxNc/rfJ17031Oe7ghTWkPg6JJ6Bo= +jdk.sh/meta v0.1.1-0.20211021015548-cff3b930ebd9/go.mod h1:c2+wWgMZejSQ2nXsbxNVKLLQgTLY4yrX7TH6NIaQle0= diff --git a/main.go b/main.go index 3be30d7..ba3a1ad 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,25 @@ +// Copyright Josh Komoroske. All rights reserved. +// Use of this source code is governed by the MIT license, +// a copy of which can be found in the LICENSE.txt file. +// SPDX-License-Identifier: MIT + package main -import "fmt" +import ( + "log" + "os" + + "jdk.sh/meta" +) func main() { - fmt.Println("drone-skip-pipeline") + if err := mainCmd(); err != nil { + log.Println("joshdk/drone-skip-pipeline:", err) + os.Exit(1) + } +} + +func mainCmd() error { + log.Printf("joshdk/drone-skip-pipeline %s (%s)\n", meta.Version(), meta.ShortSHA()) + return nil }