Skip to content

Commit

Permalink
Update ci/cd and deps (antoniomika#262)
Browse files Browse the repository at this point in the history
* Update ci/cd and deps

* Fix build args
  • Loading branch information
antoniomika authored Dec 12, 2022
1 parent a8236e5 commit 4b5c2db
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 132 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Test and Build

on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main

env:
PLATFORMS: |
linux/arm/v7
linux/arm64
linux/amd64
TAGS: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,prefix=,suffix=,format=long
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Checkout repo
uses: actions/checkout@v3
- name: Lint the codebase
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: -E goimports -E godot
- name: Run tests
run: |
go test -v ./... -cover -race -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
build:
runs-on: ubuntu-22.04
needs: test
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Login to Docker Hub
if: ${{ github.actor == github.repository_owner }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Collect image metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
tags: ${{ env.TAGS }}
- name: Collect build image metadata
id: buildmeta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}-build-image
tags: ${{ env.TAGS }}
- name: Build and push release
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.actor == github.repository_owner }}
load: ${{ github.actor != github.repository_owner }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: release
cache-from: |
${{ github.repository }}-cache
cache-to: |
type=registry,ref=${{ github.repository }}-cache,mode=max
platforms: ${{ env.PLATFORMS }}
build-args: |
DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
COMMIT=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
REPOSITORY=${{ github.repository }}
- name: Build and push build image
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.actor == github.repository_owner }}
load: ${{ github.actor != github.repository_owner }}
tags: ${{ steps.buildmeta.outputs.tags }}
labels: ${{ steps.buildmeta.outputs.labels }}
target: build-image
cache-from: |
${{ github.repository }}-cache
cache-to: |
type=registry,ref=${{ github.repository }}-cache,mode=max
platforms: ${{ env.PLATFORMS }}
build-args: |
DATE=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.version'] }}
COMMIT=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.revision'] }}
REPOSITORY=${{ github.repository }}
- name: Get version info
run: |
docker run --rm ${{ github.repository }}:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} -v
116 changes: 0 additions & 116 deletions .github/workflows/docker.yml

This file was deleted.

32 changes: 16 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ require (
github.com/radovskyb/watcher v1.0.7
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.13.0
github.com/vulcand/oxy v1.4.1
golang.org/x/crypto v0.1.0
github.com/spf13/viper v1.14.0
github.com/vulcand/oxy v1.4.2
golang.org/x/crypto v0.4.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
)

Expand All @@ -29,14 +29,14 @@ require (
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.1.2 // indirect
github.com/klauspost/cpuid/v2 v2.2.2 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/libdns/libdns v0.2.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailgun/timetools v0.0.0-20170619190023-f3a7b8ffff47 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mholt/acmez v1.0.4 // indirect
Expand All @@ -45,10 +45,10 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/phuslu/iploc v1.0.20220930 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/phuslu/iploc v1.0.20221130 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -57,12 +57,12 @@ require (
github.com/ugorji/go/codec v1.2.7 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/tools v0.2.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/tools v0.4.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
Expand Down
Loading

0 comments on commit 4b5c2db

Please sign in to comment.