Skip to content

Commit

Permalink
Merge pull request #207 from kafkesc/detro/publish-to-docker-directly…
Browse files Browse the repository at this point in the history
…-from-here

Publish to Docker directly from this repository
  • Loading branch information
detro committed Apr 15, 2024
2 parents f1ae1a9 + 28c8e36 commit d419b8b
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 200 deletions.
3 changes: 0 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

[registries.crates-io]
protocol = "sparse"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
push:
branches: [ "main" ]
paths-ignore:
- 'README.md'
- '*.md'
- 'images/*'
pull_request:
branches: [ "main" ]
paths-ignore:
- 'README.md'
- '*.md'
- 'images/*'

env:
Expand Down
46 changes: 39 additions & 7 deletions .github/workflows/crates.io-publish.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Creates.io Publish
name: Publish Crate

on:
# This workflow is designed to be triggered, when a tag is pushed against "main" branch.workflow_call:
# Tags must be of the format "vX.Y.Z" or "vX.Y.Z-SOMETHING".
push:
tags: [ "v[0-9]+.[0-9]+.[0-9]+*" ]

# TODO Remove once we have done a couple of releases and confirmed this is solid
workflow_dispatch:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"

env:
CARGO_TERM_COLOR: always

jobs:
publish:
name: Publish
publish-crates_io:
name: Publish to crates.io (${{ github.ref_name }})

runs-on: ubuntu-latest

Expand All @@ -37,3 +37,35 @@ jobs:
run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_PUBLISH_TOKEN }}

publish-hub_docker_com-linux_amd64:
name: Publish to hub.docker.com (linux/amd64)

needs:
- publish-crates_io

uses: ./.github/workflows/hub.docker.com-publish.yml

with:
release-version: ${{ github.ref_name }}
target-platforms: linux/amd64

secrets:
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}

publish-hub_docker_com-linux_arm64:
name: Publish to hub.docker.com (linux/arm64)

needs:
- publish-crates_io

uses: ./.github/workflows/hub.docker.com-publish.yml

with:
release-version: ${{ github.ref_name }}
target-platforms: linux/arm64

secrets:
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/hub.docker.com-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Publish Docker Image

on:
# This workflow is designed to be invoked by others, not triggered by events.
workflow_call:
inputs:

target-platforms:
type: string
default: linux/amd64,linux/arm64
description: Platforms to target when publishing the docker image

dockerhub-org:
type: string
default: kafkesc
description: Docker Hub organization under which to publish the docker image

dockerhub-imagename:
type: string
default: ksunami
description: Name of the docker image to publish

release-version:
required: true
type: string
description: Version to publish as docker image (eg. 'vX.Y.Z')

secrets:

dockerhub-username:
required: true
description: Docker Hub username to use when publishing the image

dockerhub-password:
required: true
description: Docker Hub password to use when publishing the image (e.g. the API token)

jobs:
publish:
name: Build & Publish ${{ inputs.dockerhub-org }}/${{ inputs.dockerhub-imagename }}:${{ inputs.release-version }} for ${{ inputs.target-platforms }}

runs-on: ubuntu-latest

steps:

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.dockerhub-username }}
password: ${{ secrets.dockerhub-password }}

- name: Set-up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ inputs.target-platforms }}

- name: Build & Push
uses: docker/build-push-action@v5
with:
push: true
platforms: ${{ inputs.target-platforms }}
build-args: |
KSUNAMI_VERSION=${{ inputs.release-version }}
tags: |
${{ inputs.dockerhub-org }}/${{ inputs.dockerhub-imagename }}:latest
${{ inputs.dockerhub-org }}/${{ inputs.dockerhub-imagename }}:${{ inputs.release-version }}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# vNEXT (YYYY-MM-DD)

## Features

Setup GitHub Actions Workflow to publish Docker image kafkesc/ksunami at every release ([i#206](https://github.com/kafkesc/ksunami/issues/206))

## Notes

Multiple dependencies upgrades since previous release

# v0.1.8 (2023-06-18)

## Notes
Expand Down
Loading

0 comments on commit d419b8b

Please sign in to comment.