1
1
mirror of https://github.com/joshdk/drone-skip-pipeline synced 2024-11-22 13:41:57 +01:00

feat: build version information into docker image (#5)

This commit is contained in:
Josh Komoroske 2021-11-14 10:57:55 -08:00 committed by GitHub
parent d14f040b9d
commit ae754e6ce8
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 4 deletions

@ -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

2
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

4
go.sum Normal file

@ -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=

22
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
}