From 29730d17cec28623749942350300cc623eaeddc1 Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Fri, 13 Oct 2023 15:57:49 -0500 Subject: [PATCH] Add Build Files To Generate Releases --- .circleci/config.yml | 35 ++++++++++++++++++++++++++++++++ Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++++ go.mod | 2 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .circleci/config.yml create mode 100644 Makefile diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..e6fedd7 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,35 @@ +version: 2 +jobs: + build: + docker: + - image: cimg/go:1.21 + steps: + - checkout + - run: go install github.com/tcnksm/ghr@v0.16.0 + - run: sudo apt-get update && sudo apt-get install p7zip-full + - restore_cache: # restores saved cache if no changes are detected since last run + keys: + - go-mod-v4-{{ checksum "go.sum" }} + - run: make dist + - save_cache: + key: go-mod-v4-{{ checksum "go.sum" }} + paths: + - "/go/pkg/mod" + - run: + name: create release + command: | + if [ "$CIRCLE_TAG" ]; then + mkdir -p dist + mv osactivate*.zip dist + ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace $CIRCLE_TAG dist/ + else + echo "No tag" + fi +workflows: + version: 2 + build-workflow: # the name of our workflow + jobs: # the jobs that we are sequencing. + - build: + filters: + tags: + only: /^v.*/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..40ff65f --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +EXECUTABLE=osactivate +WINDOWS=$(EXECUTABLE)_windows_amd64.exe +LINUX=$(EXECUTABLE)_linux_amd64 +OSX_AMD64=$(EXECUTABLE)_osx_amd64 +OSX_ARM64=$(EXECUTABLE)_osx_arm64 +ALL=$(WINDOWS) $(LINUX) $(OSX_AMD64) $(OSX_ARM64) + +default: + go build ${LDFLAGS} + +install: + go install ${LDFLAGS} + +$(WINDOWS): + env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -v -o $(WINDOWS) ${LDFLAGS} + +$(LINUX): + env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o $(LINUX) ${LDFLAGS} + +$(OSX_AMD64): + env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -o $(OSX_AMD64) ${LDFLAGS} + +$(OSX_ARM64): + env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -v -o $(OSX_ARM64) ${LDFLAGS} + +$(basename $(WINDOWS)).zip: $(WINDOWS) + zip $@ $< + 7za rn $@ $< $(EXECUTABLE)$(suffix $<) + +%.zip: % + zip $@ $< + 7za rn $@ $< $(EXECUTABLE) + +dist: test $(addsuffix .zip,$(basename $(ALL))) + +fmt: + go fmt ./... + +test: + test -z "$(go fmt)" + go vet + go test ./... + go test -race ./... + +clean: + -rm -f $(EXECUTABLE) $(EXECUTABLE)_* + +.PHONY: default dist clean docs diff --git a/go.mod b/go.mod index 2a01009..d1fe69a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/octoberswimmer/omnistudio-activation -go 1.21.3 +go 1.21 require ( github.com/ForceCLI/force v1.0.4