-
Notifications
You must be signed in to change notification settings - Fork 73
127 lines (111 loc) · 3.4 KB
/
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
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
name: Build
on: [push, pull_request]
jobs:
test:
name: test (postgres ${{ matrix.pgVersion }})
runs-on: ubuntu-latest
strategy:
matrix:
pgVersion: ['14.8', '15.3', '16.0', 'latest']
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run tests
run: go test ./...
env:
POSTGRES_VERSION: ${{ matrix.pgVersion }}
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54.2
# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
args: --timeout=30m --out-format=colored-line-number --config=.golangci.yml
- name: Ensure JSON examples are formatted
run: |
for file in ./examples/*.json; do
if ! diff <(cat $file | jq) <(cat $file); then
echo "$file is not formatted: run 'cat $file | jq' to fix";
exit 1;
fi
done
license-check:
name: License check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Ensure .go files have a license reference
run: |
curl -s https://raw.githubusercontent.com/lluissm/license-header-checker/master/install.sh | bash
./bin/license-header-checker -a -r .github/license-header.txt . go && [[ -z `git status -s` ]]
examples:
name: examples (postgres ${{ matrix.pgVersion }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pgVersion: ['14.8', '15.3', '16.0', 'latest']
services:
postgres:
image: postgres:${{ matrix.pgVersion }}
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run example migrations
run: |
go run . init
for file in ./examples/*.json; do
if [ -f "$file" ]; then
go run . start --complete $file;
fi
done
release:
runs-on: ubuntu-latest
needs: [test, lint, examples, license-check]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}