Skip to content

Commit a8e7a05

Browse files
committed
add github actions
1 parent 3a4571f commit a8e7a05

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
test-build:
9+
name: Test & Build
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Set up Go 1.16
14+
uses: actions/setup-go@v2
15+
with:
16+
go-version: '1.16.2'
17+
18+
- name: Set GOPATH and PATH
19+
run: |
20+
echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
21+
echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
22+
shell: bash
23+
24+
- name: Check out code
25+
uses: actions/checkout@v2
26+
27+
- name: Update build dependencies
28+
run: make setup
29+
30+
- name: Check quality code
31+
run: make verify
32+
33+
- name: Test
34+
run: make test
35+
36+
- name: Build
37+
run: make bin
38+

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
jobs:
7+
build:
8+
name: Create Release
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Set up Go 1.16
13+
uses: actions/setup-go@v2
14+
with:
15+
go-version: '1.16.2'
16+
17+
- name: Set GOPATH and PATH
18+
run: |
19+
echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
20+
echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
21+
shell: bash
22+
23+
- name: Check out code into the Go module directory
24+
uses: actions/checkout@v2
25+
26+
- name: Generate releases
27+
run: make releases
28+
29+
- name: Create Release
30+
id: create_release
31+
uses: actions/create-release@v1
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
34+
with:
35+
tag_name: ${{ github.ref }}
36+
release_name: ${{ github.ref }}
37+
draft: false
38+
prerelease: false
39+
40+
- name: GitHub Release
41+
uses: softprops/action-gh-release@v1
42+
if: success()
43+
with:
44+
draft: true
45+
files: |
46+
dist/asl_darwin-amd64
47+
dist/asl_linux-amd64
48+
dist/asl_windows-amd64
49+
name: ${{ github.ref }}
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
52+

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.DEFAULT_GOAL := all
44
PLATFORMS := linux/amd64 darwin/amd64 windows/amd64
55

6-
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`"
6+
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`"
77

88
temp = $(subst /, ,$@)
99
os = $(word 1, $(temp))
@@ -14,6 +14,7 @@ setup:
1414
@go get golang.org/x/lint/[email protected]
1515
@go get golang.org/x/tools/cmd/[email protected]
1616
@go get github.com/securego/gosec/[email protected]
17+
@go mod download
1718

1819
GOFILES=$(shell find . -type f -name '*.go' -not -path "./.git/*")
1920

0 commit comments

Comments
 (0)