Skip to content

Update docker release pipeline (#162) #7

Update docker release pipeline (#162)

Update docker release pipeline (#162) #7

Workflow file for this run

name: build
on:
push:
tags:
- '*'
permissions:
contents: write # to publish artifacts
packages: write # to publish ghcr.io images
jobs:
deploy_to_github:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: coursier/cache-action@v3
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build artifacts
run: |
sbt 'project kafka' assembly
sbt 'project kinesis' assembly
sbt 'project nsq' assembly
sbt 'project pubsub' assembly
sbt 'project sqs' assembly
sbt 'project stdout' assembly
sbt 'project rabbitmq' assembly
- name: Get current version
id: ver
run: echo "project_version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Create GitHub release and attach artifacts
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
name: ${{ steps.ver.outputs.project_version }}
tag_name: ${{ steps.ver.outputs.project_version }}
files: |
kafka/target/scala-2.12/opensnowcat-collector-kafka-${{ steps.ver.outputs.project_version }}.jar
kinesis/target/scala-2.12/opensnowcat-collector-kinesis-${{ steps.ver.outputs.project_version }}.jar
nsq/target/scala-2.12/opensnowcat-collector-nsq-${{ steps.ver.outputs.project_version }}.jar
pubsub/target/scala-2.12/opensnowcat-collector-google-pubsub-${{ steps.ver.outputs.project_version }}.jar
sqs/target/scala-2.12/opensnowcat-collector-sqs-${{ steps.ver.outputs.project_version }}.jar
stdout/target/scala-2.12/opensnowcat-collector-stdout-${{ steps.ver.outputs.project_version }}.jar
rabbitmq/target/scala-2.12/opensnowcat-collector-stdout-${{ steps.ver.outputs.project_version }}.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy_docker:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- kinesis
- sqs
- pubsub
- kafka
- nsq
- stdout
- rabbitmq
include:
- suffix: ""
- suffix: -experimental
platform: rabbitmq
steps:
- uses: actions/checkout@v4
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'corretto'
- name: Get current version
id: ver
run: echo "project_version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Stage the Docker build
run: sbt "project ${{ matrix.platform }}" docker:stage
- name: Stage the Docker distroless build
run: sbt "project ${{ matrix.platform }}Distroless" docker:stage
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: opensnowcat/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}
tags: |
type=raw,value=latest,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }}
type=raw,value=latest-focal,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }}
type=raw,value=${{ steps.ver.outputs.project_version }}
type=raw,value=${{ steps.ver.outputs.project_version }}-focal
flavor: |
latest=false
- name: Docker metadata distroless
id: distroless-meta
uses: docker/metadata-action@v5
with:
images: opensnowcat/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}
tags: |
type=raw,value=latest-distroless,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }}
type=raw,value=${{ steps.ver.outputs.project_version }}-distroless
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# TODO: login to push images to GitHub Container Registry
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.platform }}/target/docker/stage
file: ${{ matrix.platform }}/target/docker/stage/Dockerfile
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ steps.meta.outputs.tags }}
# TODO: tags to push images to GitHub Container Registry
# tags: |
# ghcr.io/${{ github.repository }}/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}:latest
# ghcr.io/${{ github.repository }}/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}:latest-focal
# ghcr.io/${{ github.repository }}/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}:${{ steps.ver.outputs.project_version }}
# ghcr.io/${{ github.repository }}/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}:${{ steps.ver.outputs.project_version }}-focal
- name: Push distroless image
uses: docker/build-push-action@v6
with:
context: distroless/${{ matrix.platform }}/target/docker/stage
file: distroless/${{ matrix.platform }}/target/docker/stage/Dockerfile
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ steps.distroless-meta.outputs.tags }}
# TODO: tags to push images to GitHub Container Registry
# tags: |
# ghcr.io/${{ github.repository }}/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}:latest-distroless
# ghcr.io/${{ github.repository }}/opensnowcat-collector-${{ matrix.platform }}${{ matrix.suffix }}:${{ steps.ver.outputs.project_version }}-distroless