Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
leocomelli committed Mar 20, 2021
1 parent 3a4571f commit a8e7a05
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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

52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -14,6 +14,7 @@ setup:
@go get golang.org/x/lint/[email protected]
@go get golang.org/x/tools/cmd/[email protected]
@go get github.com/securego/gosec/[email protected]
@go mod download

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

Expand Down

0 comments on commit a8e7a05

Please sign in to comment.