-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (157 loc) · 5.33 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: CI
on:
push:
paths:
# Build
- 'Makefile'
- '.aqua.yaml'
# Go
- '**.go'
- 'go.mod'
- 'go.sum'
# Protocol Buffers
- '**.proto'
- '**/buf.yaml'
- '**/buf.lock'
- 'buf.gen.yaml'
- 'buf.work.yaml'
# GitHub Actions
- '.github/workflows/ci.yml'
workflow_dispatch:
permissions:
contents: read
issues: write
pull-requests: write
repository-projects: write
jobs:
build:
strategy:
matrix:
os:
- ubuntu
- macos
# TODO: Once Aqua is Windows-compatible, activate it.
# - windows
go:
- '1.18'
- '1.19'
- '1.20'
env:
CC: 'gcc'
CXX: 'g++'
CGO_ENABLED: '1'
RELEASE_GO_VERSION: '1.18'
runs-on: ${{ matrix.os }}-latest
name: Go ${{ matrix.go }} (${{ matrix.os }})
defaults:
run:
shell: bash
steps:
################################################################################
# Packages
################################################################################
- name: Packages
if: ${{ matrix.os == 'ubuntu' }}
run: |
sudo apt-get install -y libpcsclite-dev
################################################################################
# Checkout
################################################################################
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: ${{ startsWith(github.ref, 'refs/tags/') && '0' || '1' }}
################################################################################
# Setup
################################################################################
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Setup Aqua
uses: aquaproj/aqua-installer@v2.3.2
with:
aqua_version: v2.23.1 # renovate: depName=aquaproj/aqua
################################################################################
# Cache
################################################################################
- name: Cache Directory
id: cache-dir
run: |
GOCACHE="$(go env GOCACHE)"
GOMODCACHE="$(go env GOMODCACHE)"
test -z "${GOCACHE}" && GOCACHE="${HOME}/.cache/go-build"
test -z "${GOMODCACHE}" && GOMODCACHE="$(go env GOPATH)/pkg/mod"
test -z "${AQUA_ROOT_DIR}" && AQUA_ROOT_DIR="${HOME}/.local/share/aquaproj-aqua"
test -z "${BUF_CACHE_DIR}" && BUF_CACHE_DIR="${HOME}/.cache/buf"
echo "::set-output name=go-build::${GOCACHE}"
echo "::set-output name=go-mod::${GOMODCACHE}"
echo "::set-output name=aqua::${AQUA_ROOT_DIR}"
echo "::set-output name=buf-mod::${BUF_CACHE_DIR}"
echo "GOCACHE=${GOCACHE}" >> $GITHUB_ENV
echo "GOMODCACHE=${GOMODCACHE}" >> $GITHUB_ENV
echo "AQUA_ROOT_DIR=${AQUA_ROOT_DIR}" >> $GITHUB_ENV
echo "BUF_CACHE_DIR=${BUF_CACHE_DIR}" >> $GITHUB_ENV
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-dir.outputs.go-build }}
key: ${{ matrix.os }}-go-${{ matrix.go }}-build-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.github/actions-cache-version') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-dir.outputs.go-mod }}
key: ${{ matrix.os }}-go-${{ matrix.go }}-mod-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.github/actions-cache-version') }}
- name: Buf Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-dir.outputs.buf-mod }}
key: ${{ matrix.os }}-buf-${{ matrix.go }}-mod-${{ hashFiles('**/buf.lock') }}-${{ hashFiles('.github/actions-cache-version') }}
- name: Aqua Tools Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-dir.outputs.aqua }}
key: ${{ matrix.os }}-aqua-tools-${{ hashFiles('**/aqua.yaml') }}-${{ hashFiles('.github/actions-cache-version') }}
################################################################################
# Go
################################################################################
- name: Go Mod Download
run: go mod download
- name: Go Mod Tidy
run: go mod tidy
- name: Go Tools
run: make tools
- name: Go BufBuild
run: make bufbuild
- name: Go Generate
run: make generate
- name: Go Vet
run: make vet
- name: Go Lint
run: make lint
- name: Go Test
run: make test
- name: Go Build
run: make build
- name: Go Archive
run: make archive
################################################################################
# Artifact
################################################################################
- name: Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}
path: |
dist/*.zip
dist/*.zip.sha256sum
################################################################################
# Release
################################################################################
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.go == env.RELEASE_GO_VERSION }}
with:
files: |
dist/*.zip
dist/*.zip.sha256sum