-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup GH actions, Docker builds, and release zips
- Loading branch information
1 parent
0e7a00f
commit 81cede9
Showing
6 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" # Don't change this despite the path being .github/workflows | ||
schedule: | ||
# Check for updates to GitHub Actions on the first day of the month | ||
interval: "monthly" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
# Check for updates to Go modules on the first day of the month | ||
interval: "monthly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
on: | ||
push: | ||
branches: [main] | ||
tags: ["v*.*.*"] | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
jobs: | ||
format-build-test: | ||
strategy: | ||
matrix: | ||
go-version: ['1.19.x'] | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | ||
|
||
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- if: matrix.platform == 'ubuntu-latest' | ||
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi | ||
|
||
- run: go build -v ./... | ||
|
||
- run: make test | ||
docker-build-push: | ||
if: github.event_name != 'pull_request' | ||
needs: format-build-test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | ||
|
||
- uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1 # v2.9.1 | ||
|
||
- uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0 | ||
id: meta | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=ref,event=branch | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
- uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4.1.1 | ||
with: | ||
context: . | ||
push: true | ||
file: Dockerfile.buildx | ||
platforms: linux/amd64,linux/arm64,linux/arm | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
release-zips: | ||
if: github.event_name != 'pull_request' | ||
needs: format-build-test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | ||
|
||
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | ||
with: | ||
go-version: '1.19' | ||
|
||
- run: CGO_ENABLED=0 make release | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: release-zips | ||
path: "*.zip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
release-zips: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | ||
|
||
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | ||
with: | ||
go-version: '1.19' | ||
|
||
- run: CGO_ENABLED=0 make release | ||
|
||
- run: gh release upload ${{ github.event.release.tag_name }} *.zip | ||
env: | ||
GH_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
FROM gcr.io/distroless/static | ||
|
||
COPY mysqlscepserver-linux-amd64 /mysqlscepserver | ||
ARG TARGETOS TARGETARCH | ||
|
||
COPY mysqlscepserver-$TARGETOS-$TARGETARCH /app/mysqlscepserver | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/mysqlscepserver"] | ||
WORKDIR /app | ||
|
||
ENTRYPOINT ["/app/mysqlscepserver"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM --platform=$BUILDPLATFORM golang:1.19 AS builder | ||
|
||
WORKDIR /go/app | ||
|
||
COPY . . | ||
|
||
ARG TARGETOS TARGETARCH | ||
|
||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg \ | ||
CGO_ENABLED=0 make mysqlscepserver-$TARGETOS-$TARGETARCH | ||
|
||
FROM gcr.io/distroless/static | ||
|
||
ARG TARGETOS TARGETARCH | ||
|
||
COPY --from=builder /go/app/mysqlscepserver-$TARGETOS-$TARGETARCH /app/mysqlscepserver | ||
|
||
EXPOSE 8080 | ||
|
||
WORKDIR /app | ||
|
||
ENTRYPOINT ["/app/mysqlscepserver"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters