-
Notifications
You must be signed in to change notification settings - Fork 275
208 lines (174 loc) · 5.62 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: CI
on:
push:
branches: [main]
tags: "*"
pull_request:
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: linux
image: ubuntu-latest
arch: 386
setup: sudo apt-get update && sudo apt-get install -qq gcc-i686-linux-gnu
env:
CC: i686-linux-gnu-gcc
CXX: i686-linux-gnu-g++
- os: linux
image: ubuntu-latest
arch: amd64
env: {}
- os: linux
image: ubuntu-latest
arch: arm
setup: sudo apt-get update && sudo apt-get install -qq gcc-arm-linux-gnueabihf
env:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-g++
GOARM: 7
- os: linux
image: ubuntu-latest
arch: arm64
setup: sudo apt-get update && sudo apt-get install -qq gcc-aarch64-linux-gnu
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
- os: macos
image: macos-latest
arch: amd64
env: {}
- os: macos
image: macos-latest
arch: arm64
env: {}
- os: windows
image: windows-latest
arch: amd64
env: {}
name: Build (${{ matrix.os }}/${{ matrix.arch }})
runs-on: ${{ matrix.image }}
env: ${{ matrix.env }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Setup environment
run: ${{ matrix.setup }}
- run: go mod download
- run: make build ls
env:
GOARCH: ${{ matrix.arch }}
OUTPUT: dbmate-${{ matrix.os }}-${{ matrix.arch }}
- run: dist/dbmate-${{ matrix.os }}-${{ matrix.arch }} --help
if: ${{ matrix.arch == 'amd64' }}
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dbmate-${{ matrix.os }}-${{ matrix.arch }}
path: dist/dbmate-*
- name: Publish binaries
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
files: dist/dbmate-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
name: Docker Test (linux/amd64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure QEMU
uses: docker/setup-qemu-action@v2
- name: Configure Buildx
uses: docker/setup-buildx-action@v2
- name: Check Docker environment
run: |
set -x
docker version
docker buildx version
docker-compose version
- name: Build Docker image
run: |
set -x
docker-compose build
docker-compose run --rm --no-deps dbmate --version
- name: Run make build
run: docker-compose run --rm --no-deps dev make build ls
- name: Run make lint
run: docker-compose run --rm --no-deps dev make lint
- name: Start test dependencies
run: |
set -x
docker-compose pull --ignore-buildable --quiet
docker-compose up --detach
docker-compose run --rm dev make wait
- name: Run make test
run: docker-compose run --rm dev make test
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker image tags
id: meta
uses: docker/metadata-action@v5
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Publish Docker image
uses: docker/build-push-action@v5
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
context: .
target: release
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
npm:
name: NPM
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
cache: npm
cache-dependency-path: typescript/package-lock.json
- uses: actions/download-artifact@v3
with:
path: dist
- run: find dist
- run: npm ci
working-directory: typescript
- run: npm run lint:ci
working-directory: typescript
- run: npm run generate
working-directory: typescript
- run: npm run publish
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
working-directory: typescript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}