-
Notifications
You must be signed in to change notification settings - Fork 5
97 lines (78 loc) · 2.36 KB
/
golang.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Go CI
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
name: Continuous Integration
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/[email protected]
with:
go-version-file: go.mod
check-latest: true
- name: Lint
run: |
go install golang.org/x/tools/cmd/goimports
result=$($(go env GOPATH)/bin/goimports -d -e -local github.com/philips-labs/tabia $(go list -f {{.Dir}} ./...))
echo $result
[ -n "$result" ] && exit 1 || exit 0
- name: Get dependencies
run: go mod download
- name: Install tools
run: make install-tools
- name: Build
run: |
make build
- name: Test and Cover
run: go test -v -race -count=1 -covermode=atomic -coverprofile=coverage.out ./...
env:
TABIA_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Code Coverage
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
release:
name: release
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/[email protected]
with:
go-version-file: go.mod
check-latest: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Logout from DockerHub Registry
if: ${{ always() }}
run: docker logout