Skip to content

Commit

Permalink
Merge pull request #108 from allcloud-io/feature/auto-update-release-…
Browse files Browse the repository at this point in the history
…files

Feature/auto update release files
  • Loading branch information
Jonathan committed Feb 11, 2021
2 parents bda3619 + af82ca3 commit 6760a9b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/upload_assets.yml
Original file line number Diff line number Diff line change
@@ -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/*'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
clisso*
build/
assets/
tmp
vendor
*.zip
Expand Down
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
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:
$(GOCMD) test -v ./...

.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:
Expand All @@ -53,4 +59,4 @@ install:
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)*
rm -f $(BUILDPATH)/$(BINARY_NAME)* $(ASSETPATH)/*

0 comments on commit 6760a9b

Please sign in to comment.