Skip to content

Commit

Permalink
github action for release (binary and docker)
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed May 22, 2020
1 parent 2c05755 commit 498ba2d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 20 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Test
on: [push,pull_request]
on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
jobs:
build:
name: Test
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release

on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
# to be used by fork patch-releases ^^
- 'v*.*.*-*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.14.x

- name: Prepare
id: prepare
run: |
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=tag_name::${TAG}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist --timeout=1h
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.prepare.outputs.tag_name }}

- name: set up buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

- name: login to dockerhub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: build (and publish) main image
env:
# fork friendly ^^
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg VERSION=${{ steps.prepare.outputs.tag_name }} \
--push \
-t ${DOCKER_REPO:-dkron/dkron}:${{ steps.prepare.outputs.tag_name }} \
-t ${DOCKER_REPO:-dkron/dkron}:latest \
-f Dockerfile.hub \
.
19 changes: 3 additions & 16 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ builds:
goarch:
- amd64
- arm64
- arm
goarm:
- 7
ldflags:
- -s -w -X github.com/distribworks/dkron/v3/dkron.Version={{.Version}} -X github.com/distribworks/dkron/v3/dkron.Codename=merichuas

Expand Down Expand Up @@ -155,19 +158,3 @@ changelog:
- '^docs:'
- '^test:'
- '^Merge pull request'

dockers:
-
dockerfile: Dockerfile.hub
binaries:
- dkron
- dkron-executor-http
- dkron-executor-shell
- dkron-processor-syslog
- dkron-processor-log
- dkron-processor-files
- dkron-processor-fluent
image_templates:
- "dkron/dkron:latest"
- "dkron/dkron:{{ .Tag }}"
- "dkron/dkron:v{{ .Major }}"
8 changes: 5 additions & 3 deletions Dockerfile.hub
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM alpine
# syntax=docker/dockerfile:1.0-experimental
FROM alpine:3.11
LABEL maintainer="Victor Castell <[email protected]>"
ARG TARGETPLATFORM

RUN set -x \
&& buildDeps='bash ca-certificates openssl tzdata' \
Expand All @@ -12,8 +14,8 @@ EXPOSE 8080 8946
ENV SHELL /bin/bash
WORKDIR /opt/local/dkron

COPY dkron .
COPY dkron-* ./
RUN --mount=target=/build tar xf /build/dist/dkron_*_$(echo ${TARGETPLATFORM} | tr '/' '_' | sed -e 's/arm_/arm/').tar.gz

ENTRYPOINT ["/opt/local/dkron/dkron"]

CMD ["--help"]

0 comments on commit 498ba2d

Please sign in to comment.