Skip to content

Commit ab7cbe9

Browse files
committed
Publish a docker image
1 parent 5b402d3 commit ab7cbe9

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed

Diff for: .github/workflows/release.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
jobs:
88
release:
9+
name: Create release
910
runs-on: ubuntu-latest
1011

1112
steps:
@@ -20,3 +21,57 @@ jobs:
2021
- run: gh release create v${{ steps.versions.outputs.changelog-latest-version }} go/dist/*
2122
env:
2223
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
25+
outputs:
26+
latest-release: ${{ steps.versions.outputs.changelog-latest-version }}
27+
28+
docker:
29+
name: Publish docker images
30+
runs-on: ubuntu-latest
31+
needs: release
32+
33+
steps:
34+
- name: Download binaries
35+
id: download
36+
run: |
37+
gh release download -D /tmp/binaries -R ${{ github.repository }} v${{ needs.release.outputs.latest-release }}
38+
39+
echo ::set-output name=binary-directory::/tmp/binaries
40+
41+
echo "::group::Downloaded"
42+
ls -al /tmp/binaries
43+
echo "::endgroup::"
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- uses: docker/setup-qemu-action@v1
48+
49+
- uses: docker/setup-buildx-action@v1
50+
51+
- uses: docker/metadata-action@v4
52+
id: meta
53+
with:
54+
tags: |
55+
type=semver,value=${{ needs.release.outputs.latest-release }},pattern={{major}}.{{minor}}.{{patch}}
56+
type=semver,value=${{ needs.release.outputs.latest-release }},pattern={{major}}.{{minor}}
57+
type=semver,value=${{ needs.release.outputs.latest-release }},pattern={{major}}
58+
images: ${{ github.repository }}
59+
60+
- uses: docker/login-action@v2
61+
with:
62+
username: ${{ secrets.DOCKERHUB_USERNAME }}
63+
password: ${{ secrets.DOCKERHUB_TOKEN }}
64+
65+
- uses: docker/build-push-action@v3
66+
with:
67+
context: "{{defaultContext}}:docker"
68+
push: true
69+
platforms: |
70+
linux/386
71+
linux/arm
72+
linux/amd64
73+
linux/arm64
74+
tags: ${{ steps.meta.outputs.tags }}
75+
labels: ${{ steps.meta.outputs.labels }}
76+
build-contexts: |
77+
binaries=${{ steps.download.outputs.binary-directory }}

Diff for: Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
default:
1+
default: build
2+
3+
build:
24
cd testdata && make
35
cd go && make
46

57
clean:
68
cd testdata && make clean
79
cd go && make clean
810

9-
.PHONY: default clean
11+
docker: build
12+
docker buildx build ./docker --load --tag=cucumber/json-formatter:latest --build-context binaries=./go/dist
13+
14+
.PHONY: default build clean docker

Diff for: docker/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM scratch
2+
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
ARG PREFIX=cucumber-json-formatter
6+
7+
COPY --chmod=755 --from=binaries ${PREFIX}-${TARGETOS}-${TARGETARCH} /cucumber-json-formatter
8+
9+
ENTRYPOINT ["/cucumber-json-formatter"]

0 commit comments

Comments
 (0)