From a74a89241c31d63b0b470b36302b37724207b42b Mon Sep 17 00:00:00 2001 From: Douglas Liu Date: Thu, 23 May 2019 14:38:33 +0800 Subject: [PATCH] piaas-2 Use release-it to publish to github. It should create a new release as well. --- .release-it.json | 9 +++++++++ Makefile | 38 +++++++++----------------------------- 2 files changed, 18 insertions(+), 29 deletions(-) create mode 100644 .release-it.json diff --git a/.release-it.json b/.release-it.json new file mode 100644 index 0000000..9a51700 --- /dev/null +++ b/.release-it.json @@ -0,0 +1,9 @@ +{ + "git": { + "tagName": "v${version}" + }, + "github": { + "release": true, + "assets": ["dist/piaas"] + } +} diff --git a/Makefile b/Makefile index 1664e5e..c53bcce 100644 --- a/Makefile +++ b/Makefile @@ -10,11 +10,11 @@ BINARY_NAME=piaas TESTMODE?= LDFLAGS=-ldflags "-X main.version=$(VERSION)" -all: test$(TESTMODE) build-all update-latest +all: test$(TESTMODE) build-all build: - cd main && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/$(VERSION)/darwin_amd64/$(BINARY_NAME) -v && cd .. - chmod a+x dist/$(VERSION)/darwin_amd64/$(BINARY_NAME) + cd main && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/darwin_amd64/$(BINARY_NAME) -v && cd .. + chmod a+x dist/darwin_amd64/$(BINARY_NAME) @echo " Built darwin-amd64" test: $(GOTEST) -v ./... @@ -28,7 +28,7 @@ clean: $(GOCLEAN) rm -rf dist run: build - ./dist/$(VERSION)/darwin_amd64/$(BINARY_NAME) sync cent -debug + ./dist/darwin_amd64/$(BINARY_NAME) sync cent -debug deps: $(GOGET) github.com/markbates/goth $(GOGET) github.com/markbates/pop @@ -39,35 +39,15 @@ build-all: build build-linux build-windows # Cross compilation on linux build-linux: - cd main && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/$(VERSION)/linux_amd64/$(BINARY_NAME) -v && cd .. - chmod a+x dist/$(VERSION)/linux_amd64/$(BINARY_NAME) + cd main && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/linux_amd64/$(BINARY_NAME) -v && cd .. + chmod a+x dist/linux_amd64/$(BINARY_NAME) @echo " Built linux-amd64" build-windows: - cd main && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/$(VERSION)/windows_amd64/$(BINARY_NAME).exe -v && cd .. - chmod a+x dist/$(VERSION)/windows_amd64/$(BINARY_NAME).exe + cd main && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/windows_amd64/$(BINARY_NAME).exe -v && cd .. + chmod a+x dist/windows_amd64/$(BINARY_NAME).exe @echo " Built windows-amd64" -update-latest: - @rm -f dist/latest - @ln -s ./$(VERSION) dist/latest - # Publish new release publish: tests$(TESTMODE) build-all - # Tag the main repo with the release version - git tag -f -a $(VERSION) -m "$(VERSION)" - git push origin :refs/tags/$(VERSION) - git push origin $(VERSION) - git push - - # Copy the released file to gh-pages - @rm -rf tmp/piaas-gh-pages - git clone https://github.com/sohoffice/piaas.git tmp/piaas-gh-pages -b gh-pages --single-branch - rm -rf tmp/piaas-gh-pages/files/$(VERSION) - cp -R dist/$(VERSION) tmp/piaas-gh-pages/files - rm -rf tmp/piaas-gh-pages/files/latest - cp -R dist/$(VERSION) tmp/piaas-gh-pages/files/latest - cd tmp/piaas-gh-pages && git add . && git commit -m "Release version $(VERSION)" - cd tmp/piaas-gh-pages && git push - - @echo "\n$(PROJECT_NAME) version: $(VERSION) was released.\n\n" + release-it