From a8e7a05ded89b7c477bf8933677b6739b857dbe9 Mon Sep 17 00:00:00 2001 From: Leonardo Comelli Date: Sat, 20 Mar 2021 16:29:13 -0300 Subject: [PATCH] add github actions --- .github/workflows/build.yml | 38 +++++++++++++++++++++++++ .github/workflows/release.yml | 52 +++++++++++++++++++++++++++++++++++ Makefile | 3 +- 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0517425 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: Build + +on: + - push + - pull_request + +jobs: + test-build: + name: Test & Build + runs-on: ubuntu-latest + + steps: + - name: Set up Go 1.16 + uses: actions/setup-go@v2 + with: + go-version: '1.16.2' + + - name: Set GOPATH and PATH + run: | + echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV + echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH + shell: bash + + - name: Check out code + uses: actions/checkout@v2 + + - name: Update build dependencies + run: make setup + + - name: Check quality code + run: make verify + + - name: Test + run: make test + + - name: Build + run: make bin + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6dd201e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: Release +on: + push: + tags: + - 'v*' +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + + steps: + - name: Set up Go 1.16 + uses: actions/setup-go@v2 + with: + go-version: '1.16.2' + + - name: Set GOPATH and PATH + run: | + echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV + echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH + shell: bash + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Generate releases + run: make releases + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false + + - name: GitHub Release + uses: softprops/action-gh-release@v1 + if: success() + with: + draft: true + files: | + dist/asl_darwin-amd64 + dist/asl_linux-amd64 + dist/asl_windows-amd64 + name: ${{ github.ref }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + diff --git a/Makefile b/Makefile index 7ec8d13..30a0e92 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ .DEFAULT_GOAL := all PLATFORMS := linux/amd64 darwin/amd64 windows/amd64 -LD_FLAGS := -ldflags "-X main.Version=`git describe` -X main.BuildDate=`date -u +%Y-%m-%d_%H:%M:%S` -X main.GitHash=`git rev-parse HEAD`" +LD_FLAGS := -ldflags "-X main.Version=`git describe --tags` -X main.BuildDate=`date -u +%Y-%m-%d_%H:%M:%S` -X main.GitHash=`git rev-parse HEAD`" temp = $(subst /, ,$@) os = $(word 1, $(temp)) @@ -14,6 +14,7 @@ setup: @go get golang.org/x/lint/golint@v0.0.0-20201208152925-83fdc39ff7b5 @go get golang.org/x/tools/cmd/goimports@v0.0.0-20210104081019-d8d6ddbec6ee @go get github.com/securego/gosec/v2@v2.5.0 + @go mod download GOFILES=$(shell find . -type f -name '*.go' -not -path "./.git/*")