ci: Changed to multiarch build of amd64, arm64, arm32v6

This commit is contained in:
Geoff Bourne 2020-12-28 12:09:59 -06:00
parent c7aa9504f4
commit 44d4766f60
4 changed files with 82 additions and 59 deletions

View File

@ -1,51 +0,0 @@
version: 2
defaults: &defaults
docker:
# specify the version
- image: circleci/golang:1.14.4
jobs:
build:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- cache-{{ arch }}-{{ .Branch }}-{{ checksum "go.sum" }}
- cache-{{ arch }}-{{ .Branch }}
- cache
- run: make test
- save_cache:
key: cache-{{ arch }}-{{ .Branch }}-{{ checksum "go.sum" }}
paths:
- /go/pkg
release:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin
- run: make release
workflows:
version: 2
incremental:
jobs:
- build:
filters:
tags:
ignore: /^\d+\.\d+\.\d+/
release:
jobs:
- release:
filters:
tags:
only: /^\d+\.\d+\.\d+(-\d+)?/
branches:
ignore: /.*/

37
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-*"
jobs:
release:
runs-on: ubuntu-20.04
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Docker login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -16,8 +16,8 @@ builds:
- windows - windows
goarch: goarch:
- amd64 - amd64
goarm: - arm64
- "6" - arm
main: ./cmd/mc-router main: ./cmd/mc-router
binary: mc-router binary: mc-router
env: env:
@ -28,18 +28,50 @@ archives:
format_overrides: format_overrides:
- goos: windows - goos: windows
format: zip format: zip
name_template: '{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
files: files:
- LICENSE* - LICENSE*
- README* - README*
snapshot: snapshot:
name_template: SNAPSHOT-{{ .Commit }} name_template: SNAPSHOT-{{ .ShortCommit }}
dockers: dockers:
- image_templates: - image_templates:
- "itzg/mc-router:latest" - "itzg/{{ .ProjectName }}:{{ .Version }}-amd64"
- "itzg/mc-router:{{.Tag}}" - "itzg/{{ .ProjectName }}:latest"
goos: linux
goarch: amd64 goarch: amd64
build_flag_templates:
- --platform
- linux/amd64
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
binaries:
- mc-router
- image_templates:
- "itzg/{{ .ProjectName }}:{{ .Version }}-arm64"
goarch: arm64
binaries:
- mc-router
build_flag_templates:
- --platform
- linux/arm64
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- image_templates:
- "itzg/{{ .ProjectName }}:{{ .Version }}-arm32v6"
goarch: arm
goarm: "6"
build_flag_templates:
- --platform
- linux/arm/v6
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
binaries:
- mc-router
docker_manifests:
- name_template: "itzg/{{ .ProjectName }}:{{ .Version }}"
image_templates:
- "itzg/{{ .ProjectName }}:{{ .Version }}-amd64"
- "itzg/{{ .ProjectName }}:{{ .Version }}-arm64"
- "itzg/{{ .ProjectName }}:{{ .Version }}-arm32v6"
changelog: changelog:
filters: filters:
exclude: exclude:

View File

@ -1,3 +1,8 @@
FROM scratch FROM scratch
LABEL org.opencontainers.image.authors="Geoff Bourne <itzgeoff@gmail.com>"
LABEL org.opencontainers.image.title="mc-router"
LABEL org.opencontainers.image.source="https://github.com/itzg/mc-router"
COPY mc-router / COPY mc-router /
ENTRYPOINT ["/mc-router"] ENTRYPOINT ["/mc-router"]