Skip to content

Commit

Permalink
chore(*): output binaries (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrynhard authored Oct 5, 2018
1 parent 4194aa5 commit 088e0a7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
26 changes: 19 additions & 7 deletions .conform.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
metadata:
repository: autonomy/conform
variables:
binaryPath: /conform
linuxBinaryPath: /conform-linux-amd64
darwinBinaryPath: /conform-darwin-amd64
gitRepository: github.com/autonomy/conform
maintainer: Andrew Rynhard <andrew.rynhard@autonomy.io>
policies:
Expand Down Expand Up @@ -72,10 +73,18 @@ pipeline:
- src
- test
- build
- image
stages:
build:
artifacts:
- source: /conform-linux-amd64
destination: ./build/conform-linux-amd64
- source: /conform-darwin-amd64
destination: ./build/conform-darwin-amd64
tasks:
- build
image:
tasks:
- binary
- image
src:
tasks:
Expand All @@ -87,22 +96,25 @@ stages:
tasks:
- test
tasks:
binary:
build:
template: |
FROM autonomy/conform:src AS {{ .Docker.CurrentStage }}
{{ if and .Git.IsClean .Git.IsTag }}
RUN go build -o {{ index .Variables "binaryPath" }} -ldflags "-s -w -X \"{{ index .Variables "gitRepository" }}/cmd.Tag={{ trimAll "v" .Git.Tag }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.SHA={{ .Git.SHA }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.Built={{ .Built }}\""
RUN go build -o {{ index .Variables "linuxBinaryPath" }} -ldflags "-s -w -X \"{{ index .Variables "gitRepository" }}/cmd.Tag={{ trimAll "v" .Git.Tag }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.SHA={{ .Git.SHA }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.Built={{ .Built }}\""
RUN GOOS=darwin go build -o {{ index .Variables "darwinBinaryPath" }} -ldflags "-s -w -X \"{{ index .Variables "gitRepository" }}/cmd.Tag={{ trimAll "v" .Git.Tag }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.SHA={{ .Git.SHA }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.Built={{ .Built }}\""
{{ else if .Git.IsClean }}
RUN go build -o {{ index .Variables "binaryPath" }} -ldflags "-s -w -X \"{{ index .Variables "gitRepository" }}/cmd.SHA={{ .Git.SHA }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.Built={{ .Built }}\""
RUN go build -o {{ index .Variables "linuxBinaryPath" }} -ldflags "-s -w -X \"{{ index .Variables "gitRepository" }}/cmd.SHA={{ .Git.SHA }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.Built={{ .Built }}\""
RUN GOOS=darwin go build -o {{ index .Variables "darwinBinaryPath" }} -ldflags "-s -w -X \"{{ index .Variables "gitRepository" }}/cmd.SHA={{ .Git.SHA }}\" -X \"{{ index .Variables "gitRepository" }}/cmd.Built={{ .Built }}\""
{{ else }}
RUN go build -o {{ index .Variables "binaryPath" }}
RUN go build -o {{ index .Variables "linuxBinaryPath" }}
RUN GOOS=darwin go build -o {{ index .Variables "darwinBinaryPath" }}
{{ end }}
image:
template: |
FROM alpine:3.8 AS {{ .Docker.CurrentStage }}
LABEL maintainer="{{ index .Variables "maintainer" }}"
RUN apk --no-cache add bash
COPY --from=binary {{ index .Variables "binaryPath" }} /bin
COPY --from={{ .Repository}}:build {{ index .Variables "linuxBinaryPath" }} /bin/conform
ENTRYPOINT ["conform"]
src:
template: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
conform-*
coverage.txt
vendor
Empty file added build/.keep
Empty file.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Execute() {
func init() {
cobra.OnInitialize(initConfig)

RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.conform.yaml)")
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is .conform.yaml)")
RootCmd.Flags().BoolVar(&debug, "debug", false, "Debug rendering")
}

Expand Down

0 comments on commit 088e0a7

Please sign in to comment.