Skip to content

Commit 50d0613

Browse files
author
Dusan Malusev
committed
Adding github actions
Signed-off-by: Dusan Malusev <[email protected]>
1 parent fe25ea0 commit 50d0613

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 'Release'
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
upload_url: ${{ steps.create_release.outputs.upload_url }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Create Release
16+
id: create_release
17+
uses: actions/create-release@v1
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
tag_name: ${{ github.ref }}
22+
release_name: Release ${{ github.ref }}
23+
draft: false
24+
prerelease: false
25+
binary:
26+
strategy:
27+
matrix:
28+
os: [ubuntu-latest, macos-latest, windows-latest]
29+
runs-on: ${{ matrix.os }}
30+
needs: release
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v2
34+
- uses: olegtarasov/[email protected]
35+
id: git_tag
36+
with:
37+
tagRegex: "v(.*)"
38+
tagRegexGroup: 1
39+
- name: Install Go
40+
uses: actions/setup-go@v2
41+
with:
42+
go-version: 1.16.x
43+
- uses: actions/cache@v2
44+
with:
45+
path: ~/go/pkg/mod
46+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
47+
restore-keys: |
48+
${{ runner.os }}-go-
49+
- name: Test
50+
run: make test RACE=1 ENVIRONMENT=production
51+
- name: Build
52+
run: make build VERSION=${{ steps.git_tag.outputs.tag }} RACE=0 ENVIRONMENT=production
53+
env:
54+
CGO_ENABLED: 0
55+
- name: Upload Release Asset
56+
id: upload-release-asset
57+
uses: actions/upload-release-asset@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
with:
61+
upload_url: ${{ needs.release.outputs.upload_url }}
62+
asset_path: ./bin/hosts
63+
asset_name: hosts-${{ matrix.os }}-${{ steps.git_tag.outputs.tag }}
64+
asset_content_type: application/octet-stream

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Testing'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
- dev
11+
jobs:
12+
test:
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
runs-on: ${{ matrix.os }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
- name: Install Go
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: 1.16.x
24+
- uses: actions/cache@v2
25+
with:
26+
path: ~/go/pkg/mod
27+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
28+
restore-keys: |
29+
${{ runner.os }}-go-
30+
- name: Test
31+
run: make test RACE=1 ENVIRONMENT=development

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ else
2424
echo "Target ${ENVIRONMENT} is not supported"
2525
endif
2626

27+
.PHONY: install
28+
install:
29+
mv bin/hosts $GOPATH/bin
30+
2731
.PHONY: git-setup
2832
git-setup:
2933
git config user.name GitHub

0 commit comments

Comments
 (0)