Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Expand mage and add build options #73

Merged
merged 38 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pipeline {
}
unstash 'source'
dir("${BASE_DIR}"){
withMageEnv(version: "${env.GO_VERSION}"){
withMageEnv(version: "${env.GO_VERSION}", pkgs: ['github.com/goreleaser/goreleaser']){
cmd(label: 'Go build', script: 'mage -v build')
}
}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ elastic-agent-shipper


# VSCode
/.vscode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why viscose disappeared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's still there, in #directories

/.vscode
dist/
54 changes: 54 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
- go mod tidy
- go generate ./...
builds:
- ldflags:
- -s -w -X main.Tag={{.Tag}}
- -s -w -X main.CommitHash={{.ShortCommit}}
- -s -w -X main.BuildTime={{.Timestamp}}
- id: darwin
binary: '{{ .ProjectName }}-{{ .Env.VERSION }}-{{ if .IsSnapshot}}SNAPSHOT{{ end }}-{{ .Os }}-{{ if eq .Arch "amd64" }}x86_64{{ end }}{{ if eq .Arch "arm64" }}aarch64{{ end }}/{{ .ProjectName }}'
narph marked this conversation as resolved.
Show resolved Hide resolved
env:
- CGO_ENABLED=0
goos:
- darwin
goarch:
- amd64
- arm64
no_unique_dist_dir: true
- id: linux
binary: '{{ .ProjectName }}-{{ .Env.VERSION }}-{{ if .IsSnapshot}}SNAPSHOT{{ end }}-{{ .Os }}-{{ if eq .Arch "amd64" }}x86_64{{ end }}{{ if eq .Arch "386" }}x86{{ end }}{{ if eq .Arch "arm64" }}{{ .Arch }}{{ end }}/{{ .ProjectName }}'
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
- 386
no_unique_dist_dir: true
- id: windows
binary: '{{ .ProjectName }}-{{ .Env.VERSION }}-{{ if .IsSnapshot}}SNAPSHOT{{ end }}-{{ .Os }}-{{ if eq .Arch "amd64" }}x86_64{{ end }}{{ if eq .Arch "386" }}x86{{ end }}/{{ .ProjectName }}'
env:
- CGO_ENABLED=0
goos:
- windows
goarch:
- amd64
- 386
no_unique_dist_dir: true
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Version }}-SNAPSHOT-{{ .Commit }}"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
dist: build/binaries
env:
- VERSION=8.3.0
3 changes: 2 additions & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ var Aliases = map[string]interface{}{
"lint": mage.Linter.All,
}

// Build will create the project binaries found in /build/binaries
func Build() {
sh.Run("go", "build")
sh.Run("goreleaser", "build", "--rm-dist", "--skip-validate")
narph marked this conversation as resolved.
Show resolved Hide resolved
}

// Check runs all the checks
Expand Down
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ import (
"github.com/elastic/elastic-agent-shipper/cmd"
)

const Version = "8.3.0"

var (
// BuildTime is the build time of the binary (set externally with ldflags).
BuildTime = "unknown"

// CommitHash is the Git hash of the branch, used for version purposes (set externally with ldflags).
CommitHash = "undefined"

// Tag describes the semver version of the application (set externally with ldflags).
Tag string
)

func main() {
command := cmd.NewCommand()
if err := command.Execute(); err != nil {
Expand Down