Skip to content

Commit

Permalink
Publish a docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranmcnulty committed Jul 5, 2022
1 parent 5b402d3 commit 043b239
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
release:
name: Create release
runs-on: ubuntu-latest

steps:
Expand All @@ -20,3 +21,57 @@ jobs:
- run: gh release create v${{ steps.versions.outputs.changelog-latest-version }} go/dist/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

outputs:
latest-release: ${{ steps.versions.outputs.changelog-latest-version }}

docker:
name: Publish docker images
runs-on: ubuntu-latest
needs: release

steps:
- name: Download binaries
id: download
run: |
gh release download -D /tmp/binaries -R ${{ github.repository }} v${{ needs.release.outputs.latest-release }}
echo ::set-output name=binary-directory::/tmp/binaries
echo "::group::Downloaded"
ls -al /tmp/binaries
echo "::endgroup::"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/setup-qemu-action@v1

- uses: docker/setup-buildx-action@v1

- uses: docker/metadata-action@v4
id: meta
with:
tags: |
type=semver,value=${{ needs.release.outputs.latest-release }},pattern={{major}}.{{minor}}.{{patch}}
type=semver,value=${{ needs.release.outputs.latest-release }},pattern={{major}}.{{minor}}
type=semver,value=${{ needs.release.outputs.latest-release }},pattern={{major}}
images: ${{ github.repository }}

- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:docker"
push: true
platforms: |
linux/386
linux/arm
linux/amd64
linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-contexts: |
binaries=${{ steps.download.outputs.binary-directory }}
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
default:
default: build

build:
cd testdata && make
cd go && make

clean:
cd testdata && make clean
cd go && make clean

.PHONY: default clean
docker: build
docker buildx build ./docker --load --tag=cucumber/json-formatter:latest --build-context binaries=./go/dist

.PHONY: default build clean docker
9 changes: 9 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM scratch

ARG TARGETOS
ARG TARGETARCH
ARG PREFIX=cucumber-json-formatter

COPY --chmod=755 --from=binaries ${PREFIX}-${TARGETOS}-${TARGETARCH} /cucumber-json-formatter

ENTRYPOINT ["/cucumber-json-formatter"]

0 comments on commit 043b239

Please sign in to comment.