Skip to content

Commit

Permalink
piaas-2 Use release-it to publish to github.
Browse files Browse the repository at this point in the history
It should create a new release as well.
  • Loading branch information
sohoffice committed May 23, 2019
1 parent fde8b94 commit a74a892
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
9 changes: 9 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"git": {
"tagName": "v${version}"
},
"github": {
"release": true,
"assets": ["dist/piaas"]
}
}
38 changes: 9 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand All @@ -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
Expand All @@ -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

0 comments on commit a74a892

Please sign in to comment.