diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d398711..0e267b2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,6 +6,7 @@ on: jobs: release: + name: Create release runs-on: ubuntu-latest steps: @@ -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 }} diff --git a/Makefile b/Makefile index 3935e71..054dec1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -default: +default: build + +build: cd testdata && make cd go && make @@ -6,4 +8,7 @@ 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 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..96024df --- /dev/null +++ b/docker/Dockerfile @@ -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"]