CI Build Binaries (#345)
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
export CGO_ENABLED=0
|
||||||
|
go := go
|
||||||
|
go.goos ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f1)
|
||||||
|
go.goarch ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f2)
|
||||||
|
|
||||||
|
out.tools := tomll tomljson jsontoml
|
||||||
|
out.dist := $(out.tools:=_$(go.goos)_$(go.goarch).tar.xz)
|
||||||
|
sources := $(wildcard **/*.go)
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
|
tools: $(out.tools)
|
||||||
|
|
||||||
|
$(out.tools): $(sources)
|
||||||
|
GOOS=$(go.goos) GOARCH=$(go.goarch) $(go) build ./cmd/$@
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
|
dist: $(out.dist)
|
||||||
|
|
||||||
|
$(out.dist):%_$(go.goos)_$(go.goarch).tar.xz: %
|
||||||
|
if [ "$(go.goos)" = "windows" ]; then \
|
||||||
|
tar -cJf $@ $^.exe; \
|
||||||
|
else \
|
||||||
|
tar -cJf $@ $^; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
|
clean:
|
||||||
|
rm -rf $(out.tools) $(out.dist)
|
||||||
+41
-1
@@ -132,7 +132,47 @@ stages:
|
|||||||
inputs:
|
inputs:
|
||||||
command: 'test'
|
command: 'test'
|
||||||
arguments: './...'
|
arguments: './...'
|
||||||
|
- stage: build_binaries
|
||||||
|
displayName: "Build binaries"
|
||||||
|
dependsOn: run_checks
|
||||||
|
jobs:
|
||||||
|
- job: build_binary
|
||||||
|
displayName: "Build binary"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
linux_amd64:
|
||||||
|
GOOS: linux
|
||||||
|
GOARCH: amd64
|
||||||
|
darwin_amd64:
|
||||||
|
GOOS: darwin
|
||||||
|
GOARCH: amd64
|
||||||
|
windows_amd64:
|
||||||
|
GOOS: windows
|
||||||
|
GOARCH: amd64
|
||||||
|
pool:
|
||||||
|
vmImage: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- task: GoTool@0
|
||||||
|
displayName: "Install Go"
|
||||||
|
inputs:
|
||||||
|
version: 1.14
|
||||||
|
- task: Bash@3
|
||||||
|
inputs:
|
||||||
|
targetType: inline
|
||||||
|
script: "make dist"
|
||||||
|
env:
|
||||||
|
go.goos: $(GOOS)
|
||||||
|
go.goarch: $(GOARCH)
|
||||||
|
- task: CopyFiles@2
|
||||||
|
inputs:
|
||||||
|
sourceFolder: '$(Build.SourcesDirectory)'
|
||||||
|
contents: '*.tar.xz'
|
||||||
|
TargetFolder: '$(Build.ArtifactStagingDirectory)'
|
||||||
|
- task: PublishBuildArtifacts@1
|
||||||
|
inputs:
|
||||||
|
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
||||||
|
artifactName: binaries
|
||||||
|
|
||||||
- stage: build_docker_image
|
- stage: build_docker_image
|
||||||
displayName: "Build Docker image"
|
displayName: "Build Docker image"
|
||||||
dependsOn: run_checks
|
dependsOn: run_checks
|
||||||
|
|||||||
Reference in New Issue
Block a user