diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f567ac8f..6597b1a0f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,11 @@ name: Test -on: [push,pull_request] +on: + push: + branches: + - '**' + tags-ignore: + - '**' + pull_request: jobs: build: name: Test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..10a6fd2e3 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 \ + . diff --git a/.goreleaser.yml b/.goreleaser.yml index 1c6b75044..92f15d966 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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 @@ -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 }}" diff --git a/Dockerfile.hub b/Dockerfile.hub index 178fead29..2c77a118c 100644 --- a/Dockerfile.hub +++ b/Dockerfile.hub @@ -1,5 +1,7 @@ -FROM alpine +# syntax=docker/dockerfile:1.0-experimental +FROM alpine:3.11 LABEL maintainer="Victor Castell " +ARG TARGETPLATFORM RUN set -x \ && buildDeps='bash ca-certificates openssl tzdata' \ @@ -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"]