-
-
Notifications
You must be signed in to change notification settings - Fork 69
83 lines (79 loc) · 2.19 KB
/
ci.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
name: "CI"
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
# run unittest
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [ '1.20' ]
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@v3
- run: go test -v -coverprofile=profile.cov ./...
- name: go vet
run: |
go vet ./...
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
flag-name: Go-${{ matrix.go }}
parallel: true
# build binary
build:
needs: test
name: Build binary CI
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ linux, windows, darwin ]
goarch: [ "386", amd64, arm, arm64 ]
exclude:
- goos: darwin
goarch: arm
- goos: darwin
goarch: "386"
fail-fast: true
steps:
- uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Set env
run: |
echo BUILD_TIME=$(date --rfc-3339=seconds) >> ${GITHUB_ENV}
- name: Build binary file
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
export BINARY_NAME="DDBOT"
if [ $GOOS = "windows" ]; then export BINARY_NAME="$BINARY_NAME.exe"; fi
go build -o "$BINARY_NAME" -ldflags '-w -s -X "github.com/Sora233/DDBOT/lsp.BuildTime=${{ env.BUILD_TIME }}" -X github.com/Sora233/DDBOT/lsp.CommitId=${{ github.sha }} -X github.com/Sora233/DDBOT/lsp.Tags=${{ env.Tags }}' github.com/Sora233/DDBOT/cmd
- name: Upload artifact
uses: actions/upload-artifact@v2
if: ${{ !github.head_ref }}
with:
name: ${{ matrix.goos }}_${{ matrix.goarch }}
path: |
./DDBOT
./DDBOT.exe
# notifies that all test jobs are finished.
finish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true