-
Notifications
You must be signed in to change notification settings - Fork 13
Use GoReleaser for build #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,6 @@ | |
| .idea/ | ||
| .vscode/ | ||
| uaa-cli | ||
| uaa | ||
| build/ | ||
| dist/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # The lines below are called `modelines`. See `:help modeline` | ||
| # Feel free to remove those if you don't want/need to use them. | ||
| # yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
| # vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
|
||
| version: 2 | ||
|
|
||
| before: | ||
| hooks: | ||
| - go mod tidy | ||
|
|
||
| builds: | ||
| - env: | ||
| - CGO_ENABLED=0 | ||
| goos: | ||
| - linux | ||
| - windows | ||
| - darwin | ||
| ldflags: | ||
| - -s -w | ||
| - -X code.cloudfoundry.org/uaa-cli/version.Version={{.Version}} | ||
| - -X code.cloudfoundry.org/uaa-cli/version.Commit={{.ShortCommit}} | ||
| binary: uaa | ||
|
|
||
| archives: | ||
| - formats: [binary] | ||
| # Use same naming convention as before: uaa-{os}-{arch}-{version} | ||
| name_template: >- | ||
| uaa- | ||
| {{- .Os }}- | ||
| {{- if eq .Arch "amd64" }}amd64 | ||
| {{- else if eq .Arch "arm64" }}arm64 | ||
| {{- else if eq .Arch "386" }}386 | ||
| {{- else }}{{ .Arch }}{{ end }}- | ||
| {{- .Version }} | ||
|
|
||
| release: | ||
| # Repository to release to. | ||
| github: | ||
| owner: cloudfoundry | ||
| name: uaa-cli | ||
|
|
||
| # You can change the name of the release. | ||
| name_template: "UAA CLI Release {{.Version}}" | ||
|
|
||
| # If set to auto, will mark the release as not ready for production | ||
| # in case there is an indicator for this in the tag e.g. v1.0.0-rc1 | ||
| prerelease: auto | ||
|
|
||
| # What to do with the release notes in case there the release already exists. | ||
| mode: replace | ||
|
|
||
| checksum: | ||
| name_template: 'checksums.txt' | ||
|
|
||
| snapshot: | ||
| version_template: "{{ .Branch }}-{{ .ShortCommit }}" | ||
|
|
||
| changelog: | ||
| # This automatically uses PRs merged since the last tag | ||
| # Shows clickable PR links (#123) and usernames (@user) | ||
| use: github-native | ||
|
|
||
| # Uncomment if you want to publish to a package manager | ||
| # brews: | ||
| # - name: uaa-cli | ||
| # homepage: https://github.com/cloudfoundry/uaa-cli | ||
| # description: "A command line client for the CloudFoundry UAA API" | ||
| # repository: | ||
| # owner: cloudfoundry | ||
| # name: homebrew-tap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,52 @@ | ||
| .PHONY: all build ci clean format ginkgo test install | ||
|
|
||
| BUILD_DEST = build/uaa | ||
| EXECUTABLE_NAME = uaa | ||
| INSTALL_DEST = $(GOPATH)/bin/uaa | ||
| COMMIT_HASH=$(shell git rev-parse --short HEAD) | ||
| GOFILES=$(shell find . -type f -name '*.go') | ||
|
|
||
| ifndef VERSION | ||
| VERSION = DEV | ||
| endif | ||
| .PHONY: all | ||
| all: format test build ## Runs: Format, Test, and Build | ||
|
|
||
| ${EXECUTABLE_NAME}: **/*.go go.mod go.sum ## Build | ||
| goreleaser build --snapshot --clean --single-target --output . | ||
|
|
||
| **/*.go: | ||
| @# noop | ||
|
|
||
| GOFLAGS := -v -ldflags "-X code.cloudfoundry.org/uaa-cli/version.Version=${VERSION} -X code.cloudfoundry.org/uaa-cli/version.Commit=${COMMIT_HASH}" | ||
| .PHONY: build | ||
| build: ${EXECUTABLE_NAME} ## Build | ||
|
|
||
| all: test clean build | ||
| .PHONY: build_all | ||
| build_all: **/*.go go.mod go.sum ## Build all releases, in dist, using Goreleaser (requires goreleaser to be installed) | ||
| goreleaser build --snapshot --clean | ||
|
|
||
| clean: | ||
| rm -rf build | ||
| .PHONY: clean | ||
| clean: ## Clean up artifacts | ||
| rm -rf build/ dist/ ${EXECUTABLE_NAME} | ||
|
|
||
| format: | ||
| .PHONY: format | ||
| format: ## Format Go Code | ||
| go fmt ./... | ||
|
|
||
| ginkgo: | ||
| .PHONY: test | ||
| test: ## Run Ginkgo tests | ||
| go run github.com/onsi/ginkgo/v2/ginkgo -v -r --randomize-suites --randomize-all -race | ||
|
|
||
| test: format ginkgo | ||
| .PHONY: goreleaser-check | ||
| goreleaser-check: ## Test goreleaser configuration | ||
| goreleaser check | ||
|
|
||
| ci: ginkgo | ||
|
|
||
| build: | ||
| mkdir -p build | ||
| CGO_ENABLED=0 go build $(GOFLAGS) -o $(BUILD_DEST) | ||
| .PHONY: install | ||
| install: ${EXECUTABLE_NAME} ## Install executable | ||
| rm -rf $(INSTALL_DEST) | ||
| cp ${EXECUTABLE_NAME} $(INSTALL_DEST) | ||
|
|
||
| build_all: | ||
| mkdir -p build | ||
| CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(GOFLAGS) -o $(BUILD_DEST)-darwin-arm64 | ||
| CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(GOFLAGS) -o $(BUILD_DEST)-darwin-amd64 | ||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(GOFLAGS) -o $(BUILD_DEST)-linux-amd64 | ||
| CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build $(GOFLAGS) -o $(BUILD_DEST)-windows-amd64 | ||
| .PHONY: cve | ||
| cve: ${EXECUTABLE_NAME} ## Scan for CVEs | ||
| grype file:${EXECUTABLE_NAME} | ||
|
|
||
| install: | ||
| rm -rf $(INSTALL_DEST) | ||
| cp $(BUILD_DEST) $(INSTALL_DEST) | ||
| .PHONY: setup | ||
| setup: ## Setup packages needed for release | ||
| brew install caarlos0/tap/svu | ||
| brew install goreleaser/tap/goreleaser | ||
|
|
||
| cve: build | ||
| grype file:$(BUILD_DEST) | ||
| .PHONY: help | ||
| help: ## Display this help | ||
| @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.