diff --git a/.github/workflows/upload_assets.yml b/.github/workflows/upload_assets.yml new file mode 100644 index 0000000..9efbc02 --- /dev/null +++ b/.github/workflows/upload_assets.yml @@ -0,0 +1,26 @@ +on: + release: + types: [created] + +name: Upload release assets after release is created +jobs: + build: + name: build binaries + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Checkout code + uses: actions/checkout@v2 + - name: build + run: | + echo "GO111MODULE=on" >> $GITHUB_ENV + make zip + - name: Upload release assets + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: './assets/*' diff --git a/.gitignore b/.gitignore index 89becd6..e11b53a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea -clisso* +build/ +assets/ tmp vendor *.zip diff --git a/Makefile b/Makefile index b967027..38e8af7 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,14 @@ GOCMD=go GOBUILD=$(GOCMD) build GOCLEAN=$(GOCMD) clean +BUILDPATH=build +ASSETPATH=assets BINARY_NAME=clisso VERSION=`git describe --tags --always` .PHONY: build build: - $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BINARY_NAME) -v + $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BUILDPATH)/$(BINARY_NAME) -v .PHONY: test test: @@ -14,30 +16,34 @@ test: .PHONY: darwin-amd64 darwin-amd64: - GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BINARY_NAME)-darwin-amd64 -v + GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BUILDPATH)/$(BINARY_NAME)-darwin-amd64 -v .PHONY: linux-386 linux-386: - GOOS=linux GOARCH=386 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BINARY_NAME)-linux-386 -v + GOOS=linux GOARCH=386 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BUILDPATH)/$(BINARY_NAME)-linux-386 -v .PHONY: linux-amd64 linux-amd64: - GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BINARY_NAME)-linux-amd64 -v + GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BUILDPATH)/$(BINARY_NAME)-linux-amd64 -v .PHONY: windows-386 windows-386: - GOOS=windows GOARCH=386 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BINARY_NAME)-windows-386.exe -v + GOOS=windows GOARCH=386 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BUILDPATH)/$(BINARY_NAME)-windows-386.exe -v .PHONY: windows-amd64 windows-amd64: - GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BINARY_NAME)-windows-amd64.exe -v + GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(BUILDPATH)/$(BINARY_NAME)-windows-amd64.exe -v .PHONY: all all: darwin-amd64 linux-386 linux-amd64 windows-386 windows-amd64 .PHONY: zip -zip: - for i in `ls -1 $(BINARY_NAME)* | grep -v '.zip'`; do zip $$i.zip $$i; done +zip: all + mkdir -p $(ASSETPATH) + cd $(BUILDPATH) && \ + for i in `ls -1 $(BINARY_NAME)* | grep -v '.zip'`; do zip ../$(ASSETPATH)/$$i.zip $$i; done + cd $(ASSETPATH) && \ + sha256sum *zip > SHASUMS256.txt .PHONY: brew brew: @@ -53,4 +59,4 @@ install: .PHONY: clean clean: $(GOCLEAN) - rm -f $(BINARY_NAME)* + rm -f $(BUILDPATH)/$(BINARY_NAME)* $(ASSETPATH)/*