Skip to content

Commit a9cdead

Browse files
authored
Merge branch 'amacneil:main' into main
2 parents 52e73a8 + 1613f72 commit a9cdead

26 files changed

Lines changed: 434 additions & 251 deletions

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/ci.yml

Lines changed: 116 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,149 @@ name: CI
33
on:
44
push:
55
branches: [main]
6-
tags: "v*"
6+
tags: "*"
77
pull_request:
8-
branches: [main]
98

109
jobs:
1110
build:
12-
name: Build
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
include:
15+
- os: linux
16+
image: ubuntu-latest
17+
arch: amd64
18+
env: {}
19+
- os: linux
20+
image: ubuntu-latest
21+
arch: arm64
22+
setup: sudo apt-get update && sudo apt-get install -qq gcc-aarch64-linux-gnu
23+
env:
24+
CC: aarch64-linux-gnu-gcc
25+
CXX: aarch64-linux-gnu-g++
26+
- os: macos
27+
image: macos-latest
28+
arch: amd64
29+
env: {}
30+
- os: macos
31+
image: macos-latest
32+
arch: arm64
33+
env: {}
34+
- os: windows
35+
image: windows-latest
36+
arch: amd64
37+
env: {}
38+
39+
name: Build (${{ matrix.os }}/${{ matrix.arch }})
40+
runs-on: ${{ matrix.image }}
41+
env: ${{ matrix.env }}
42+
43+
steps:
44+
- uses: actions/checkout@v3
45+
46+
- uses: actions/setup-go@v3
47+
with:
48+
go-version: "1.17"
49+
50+
- name: Setup environment
51+
run: ${{ matrix.setup }}
52+
53+
- run: go mod download
54+
55+
- run: make build ls
56+
env:
57+
GOARCH: ${{ matrix.arch }}
58+
OUTPUT: dbmate-${{ matrix.os }}-${{ matrix.arch }}
59+
60+
- run: dist/dbmate-${{ matrix.os }}-${{ matrix.arch }} --help
61+
if: ${{ matrix.arch == 'amd64' }}
62+
63+
- name: Publish binaries
64+
uses: softprops/action-gh-release@v1
65+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
66+
with:
67+
files: dist/dbmate-*
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
71+
docker:
72+
name: Docker Test (linux/amd64)
1373
runs-on: ubuntu-latest
1474

1575
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v2
76+
- uses: actions/checkout@v3
77+
78+
- name: Configure QEMU
79+
uses: docker/setup-qemu-action@v1
1880

19-
- name: Environment
81+
- name: Configure Buildx
82+
uses: docker/setup-buildx-action@v1
83+
84+
- name: Check Docker environment
2085
run: |
2186
set -x
2287
docker version
88+
docker buildx version
2389
docker-compose version
2490
25-
- name: Cache
26-
uses: actions/cache@v2
27-
with:
28-
key: cache
29-
path: .cache
30-
31-
- name: Build docker image
91+
- name: Build Docker image
3292
run: |
3393
set -x
3494
docker-compose build
3595
docker-compose run --rm --no-deps dbmate --version
3696
37-
- name: Build binaries
38-
run: |
39-
set -x
40-
docker-compose run --rm --no-deps dev make build-all
41-
dist/dbmate-linux-amd64 --version
97+
- name: Run make build
98+
run: docker-compose run --rm --no-deps dev make build ls
4299

43-
- name: Lint
100+
- name: Run make lint
44101
run: docker-compose run --rm --no-deps dev make lint
45102

46103
- name: Start test dependencies
47104
run: |
48105
set -x
49106
docker-compose pull --quiet
50107
docker-compose up --detach
51-
52-
- name: Run tests
53-
run: |
54-
set -x
55108
docker-compose run --rm dev make wait
56-
docker-compose run --rm dev make test
57109
58-
- name: Publish docker image
110+
- name: Run make test
111+
run: docker-compose run --rm dev make test
112+
113+
- name: Login to Docker Hub
114+
uses: docker/login-action@v1
59115
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
60-
env:
61-
SRC_IMAGE: dbmate_release
62-
DOCKERHUB_IMAGE: ${{ github.repository }}
63-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
64-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
65-
GHCR_IMAGE: ghcr.io/${{ github.repository }}
66-
GHCR_USERNAME: ${{ github.actor }}
67-
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68-
run: .github/workflows/publish-docker.sh
69-
70-
- name: Publish release binaries
71-
uses: softprops/action-gh-release@v1
72-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
73116
with:
74-
files: dist/*
75-
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
username: ${{ secrets.DOCKERHUB_USERNAME }}
118+
password: ${{ secrets.DOCKERHUB_TOKEN }}
119+
120+
- name: Login to GitHub Container Registry
121+
uses: docker/login-action@v1
122+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
123+
with:
124+
registry: ghcr.io
125+
username: ${{ github.actor }}
126+
password: ${{ secrets.GITHUB_TOKEN }}
127+
128+
- name: Generate Docker image tags
129+
id: meta
130+
uses: docker/metadata-action@v3
131+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
132+
with:
133+
images: |
134+
${{ github.repository }}
135+
ghcr.io/${{ github.repository }}
136+
tags: |
137+
type=ref,event=branch
138+
type=semver,pattern={{version}}
139+
type=semver,pattern={{major}}.{{minor}}
140+
type=semver,pattern={{major}}
141+
142+
- name: Publish Docker image
143+
uses: docker/build-push-action@v2
144+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
145+
with:
146+
context: .
147+
target: release
148+
platforms: linux/amd64,linux/arm64
149+
push: true
150+
tags: ${{ steps.meta.outputs.tags }}
151+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/publish-docker.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ linters:
55
- depguard
66
- errcheck
77
- goimports
8-
- golint
98
- gosimple
109
- govet
1110
- ineffassign
1211
- misspell
1312
- nakedret
13+
- revive
1414
- rowserrcheck
1515
- staticcheck
1616
- structcheck

Dockerfile

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
11
# development image
2-
FROM techknowlogick/xgo:go-1.16.x as dev
2+
FROM golang:1.18 as dev
33
WORKDIR /src
4-
ENV GOCACHE /src/.cache/go-build
5-
6-
# enable cgo to build sqlite
7-
ENV CGO_ENABLED 1
84

95
# install database clients
106
RUN apt-get update \
117
&& apt-get install -qq --no-install-recommends \
128
curl \
13-
mysql-client \
9+
file \
10+
mariadb-client \
1411
postgresql-client \
1512
sqlite3 \
1613
&& rm -rf /var/lib/apt/lists/*
1714

1815
# golangci-lint
1916
RUN curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
20-
| sh -s -- -b /usr/local/bin v1.39.0
17+
| sh -s -- -b /usr/local/bin v1.45.2
2118

2219
# download modules
23-
COPY go.* ./
20+
COPY go.* /src/
2421
RUN go mod download
25-
26-
ENTRYPOINT []
27-
CMD ["/bin/bash"]
28-
29-
# build stage
30-
FROM dev as build
31-
COPY . ./
22+
COPY . /src/
3223
RUN make build
3324

3425
# release stage
@@ -38,5 +29,5 @@ RUN apk add --no-cache \
3829
postgresql-client \
3930
sqlite \
4031
tzdata
41-
COPY --from=build /src/dist/dbmate-linux-amd64 /usr/local/bin/dbmate
42-
ENTRYPOINT ["dbmate"]
32+
COPY --from=dev /src/dist/dbmate /usr/local/bin/dbmate
33+
ENTRYPOINT ["/usr/local/bin/dbmate"]

0 commit comments

Comments
 (0)