-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (52 loc) · 1.56 KB
/
go-app-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Go App Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Get Dependencies
working-directory: ./go-code/
run: go mod tidy
- name: Run Linter
uses: golangci/golangci-lint-action@v2
with:
working-directory: ./go-code/
- name: Run Unit Tests
working-directory: ./go-code/
run: GOOS=linux GOARCH=amd64 go test -race -cover -v ./...
- name: Run Build
working-directory: ./go-code/
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o reverse-words-linux-amd64 -v ./...
- name: Save app binary Artifact
uses: actions/upload-artifact@v1
with:
name: reverse-words-linux-amd64
path: ./go-code/reverse-words-linux-amd64
release:
name: Creates a new release with the resulting binary
needs: [build]
runs-on: ubuntu-20.04
steps:
- name: Pull the app binary from Artifacts
uses: actions/download-artifact@v1
with:
name: reverse-words-linux-amd64
path: /tmp/
- name: Upload binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /tmp/reverse-words-linux-amd64
asset_name: reverse-words-linux-amd64
tag: ${{ github.ref }}-release
overwrite: true
body: "Automatic release created by a GitHub Action"