-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from nalbury/na-build-improvements
Makefile, build CI and build/install README updates
- Loading branch information
Showing
6 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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,27 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
jobs: | ||
release: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.13.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Create release artifacts | ||
run: VERSION=${GITHUB_REF} make release | ||
- name: Create release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
for f in ./build/artifacts/* | ||
do | ||
[ -f "$f" ] && assets+=(-a "$f") | ||
done | ||
hub release create -m "Release ${GITHUB_REF}" \ | ||
"${assets[@]}" "${GITHUB_REF}" |
This file contains 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 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 +1,2 @@ | ||
*.swp | ||
build/* |
This file contains 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,43 @@ | ||
GOOS ?= darwin ## OS we're building for (e.g. linux) | ||
GOARCH ?= amd64 ## Arch we're building for (e.g. amd64) | ||
VERSION ?= master ## Version we're releasing | ||
|
||
BUILD_PATH = ./build/bin/$(GOOS)/$(GOARCH) | ||
ARTIFACT_PATH = ./build/artifacts | ||
|
||
export GO_BUILD=GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(BUILD_PATH)/promql ./ | ||
export TAR=tar -czvf $(ARTIFACT_PATH)/promql-$(VERSION)-$(GOOS)-$(GOARCH).tar.gz -C $(BUILD_PATH) promql | ||
|
||
help: ## Print Makefile help | ||
@echo "Makefile for promql" | ||
@echo "#### Examples ####" | ||
@echo "Build a linux binary:" | ||
@echo " GOOS=linux make build" | ||
@echo "Build both linux and macOS binaries and create release artifacts:" | ||
@echo " VERSION=v0.2.1 make release" | ||
@echo "#### Environment Variables ####" | ||
@awk '$$4 == "##" {gsub(/\?=./, "", $$0); $$2="(default: "$$2")"; printf "-- %s \n", $$0}' Makefile | ||
@echo "#### Targets ####" | ||
@awk '$$1 ~ /^.*:$$/ {gsub(":", "", $$1);printf "-- %s \n", $$0}' Makefile | ||
|
||
setup: ## Setup build/artifact paths. | ||
mkdir -p $(BUILD_PATH) | ||
mkdir -p $(ARTIFACT_PATH) | ||
|
||
clean: ## Cleanup build dir | ||
rm -rf ./build/* | ||
|
||
build: setup ## Build promql binary | ||
$(GO_BUILD) | ||
|
||
build-all: ## Build binaries for linux and macOS | ||
GOOS="darwin" GOARCH="amd64" make build | ||
GOOS="linux" GOARCH="amd64" make build | ||
|
||
build-artifact: setup ## Build binary and create release artifact | ||
$(GO_BUILD) | ||
$(TAR) | ||
|
||
release: ## Build binaries and create release artifactors for both linux and macOS | ||
GOOS="darwin" GOARCH="amd64" make build-artifact | ||
GOOS="linux" GOARCH="amd64" make build-artifact |
This file contains 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 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