Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/actions/setup-tools/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Setup citusdata/tools
description: Clone citusdata/tools outside the checkout and install packaging_automation dependencies

inputs:
tools_ref:
description: Immutable citusdata/tools git tag to clone
required: false
default: "v0.8.42"

runs:
using: composite
steps:
- name: Install system dependencies
shell: bash
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libcurl4-openssl-dev libssl-dev python3-testresources

- name: Clone citusdata/tools and install Python requirements
shell: bash
env:
TOOLS_REF: ${{ inputs.tools_ref }}
run: |
tools_root="${RUNNER_TEMP:?RUNNER_TEMP must be set}/citus-tools"
rm -rf "${tools_root}"
git clone --branch "${TOOLS_REF}" --depth 1 -- https://github.com/citusdata/tools.git "${tools_root}/tools"
python -m pip install -r "${tools_root}/tools/packaging_automation/requirements.txt"
echo "TOOLS_PATH=${tools_root}" >> "${GITHUB_ENV}"
echo "PYTHONPATH=${tools_root}${PYTHONPATH:+:${PYTHONPATH}}" >> "${GITHUB_ENV}"
27 changes: 11 additions & 16 deletions .github/workflows/publish_docker_images_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
push:
branches:
- "**"
env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}

jobs:
build_and_publish_images:
Expand All @@ -32,23 +29,21 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Clone tools branch
run: git clone -b v0.8.38 --depth=1 https://github.com/citusdata/tools.git tools

- name: Install package dependencies
run: sudo apt-get update && sudo apt install libcurl4-openssl-dev libssl-dev python3-testresources

- name: Install python requirements
run: python -m pip install -r tools/packaging_automation/requirements.txt
- name: Setup tools
uses: ./.github/actions/setup-tools

- name: DockerHub Login
run: docker login -u "${DOCKERHUB_USER_NAME}" -p "${DOCKERHUB_PASSWORD}"
env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USER_NAME}" --password-stdin

- name: Build and publish docker images
env:
DOCKER_BUILD_MULTI_ARCH: ${{ github.ref == 'refs/heads/master' && '1' || '0' }}
IMAGE_TYPE: ${{ matrix.image_type }}
run: |
python -m tools.packaging_automation.publish_docker \
--pipeline_trigger_type "${GITHUB_EVENT_NAME}" \
--github_ref "${GITHUB_REF}" \
--image_type "${{ matrix.image_type }}"
python -m tools.packaging_automation.publish_docker \
--pipeline_trigger_type "${GITHUB_EVENT_NAME}" \
--github_ref "${GITHUB_REF}" \
--image_type "${IMAGE_TYPE}"
56 changes: 36 additions & 20 deletions .github/workflows/publish_docker_images_on_manual.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: On Demand (Manual) Docker Image Build

env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}

on:
workflow_dispatch:
inputs:
trigger_type:
description: "Type of build which you want to trigger. Allowed values: main, tags, nightly"
description: "Type of build to trigger"
type: choice
required: true
options:
- main
- tags
- nightly
tag_name:
description: "The tag name on the project repo to be released. It is mandatory if you select the trigger_type as 'tags'"
description: "Tag name to release (required when trigger_type is 'tags')"
type: string
required: false
default: ""

Expand All @@ -21,34 +23,48 @@ jobs:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
image_type: ${{ fromJSON(inputs.trigger_type == 'nightly' && '["nightly"]' || '["latest", "alpine", "postgres_17", "postgres_16", "nightly"]') }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: ${{ inputs.trigger_type == 'tags' && '0' || '1' }}
ref: ${{ inputs.trigger_type == 'tags' && 'master' || '' }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Clone tools branch
run: git clone -b v0.8.38 --depth=1 https://github.com/citusdata/tools.git tools

- name: Install package dependencies
run: sudo apt-get update && sudo apt install libcurl4-openssl-dev libssl-dev python3-testresources

- name: Install python requirements
run: python -m pip install -r tools/packaging_automation/requirements.txt
- name: Setup tools
uses: ./.github/actions/setup-tools

- name: DockerHub Login
run: docker login -u "${DOCKERHUB_USER_NAME}" -p "${DOCKERHUB_PASSWORD}"
env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USER_NAME}" --password-stdin

- name: Build and publish docker images
env:
DOCKER_BUILD_MULTI_ARCH: "1"
TRIGGER_TYPE: ${{ inputs.trigger_type }}
TAG_NAME: ${{ inputs.tag_name }}
IMAGE_TYPE: ${{ matrix.image_type }}
run: |
python -m tools.packaging_automation.publish_docker \
--pipeline_trigger_type "${GITHUB_EVENT_NAME}" \
--tag_name "${{ github.event.inputs.tag_name }}" \
--manual_trigger_type "${{ github.event.inputs.trigger_type }}" \
--github_ref "${GITHUB_REF}"
target_ref="${GITHUB_REF}"
if [ "${TRIGGER_TYPE}" = "tags" ]; then
[[ "${TAG_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Valid tag_name (vX.Y.Z) is required when trigger_type is 'tags'"; exit 1; }
target_ref="refs/tags/${TAG_NAME}"
git checkout --quiet "${target_ref}"
elif [ "${TRIGGER_TYPE}" = "main" ] && [ -n "${TAG_NAME}" ]; then
echo "::error::tag_name must be empty when trigger_type is 'main'"; exit 1
fi
python -m tools.packaging_automation.publish_docker \
--pipeline_trigger_type "${GITHUB_EVENT_NAME}" \
--tag_name "${TAG_NAME}" \
--manual_trigger_type "${TRIGGER_TYPE}" \
--github_ref "${target_ref}" \
--image_type "${IMAGE_TYPE}"
79 changes: 63 additions & 16 deletions .github/workflows/publish_docker_images_on_push.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Build Docker Image On Push (Both Tags and Branches)

env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
permissions:
contents: read

concurrency:
group: publish-docker-on-push-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

on:
push:
branches:
- "**"

jobs:
build_and_publish_images:
runs-on: ubuntu-24.04
Expand All @@ -30,23 +34,66 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Clone tools branch
run: git clone -b v0.8.38 --depth=1 https://github.com/citusdata/tools.git tools

- name: Install package dependencies
run: sudo apt-get update && sudo apt install libcurl4-openssl-dev libssl-dev python3-testresources

- name: Install python requirements
run: python -m pip install -r tools/packaging_automation/requirements.txt
- name: Setup tools
uses: ./.github/actions/setup-tools

- name: DockerHub Login
run: docker login -u "${DOCKERHUB_USER_NAME}" -p "${DOCKERHUB_PASSWORD}"
env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USER_NAME}" --password-stdin

- name: Build and publish docker images
env:
DOCKER_BUILD_MULTI_ARCH: ${{ github.ref == 'refs/heads/master' && '1' || '0' }}
IMAGE_TYPE: ${{ matrix.image_type }}
run: |
python -m tools.packaging_automation.publish_docker \
--github_ref "${GITHUB_REF}" \
--pipeline_trigger_type "${GITHUB_EVENT_NAME}" \
--image_type "${{ matrix.image_type }}"
python -m tools.packaging_automation.publish_docker \
--github_ref "${GITHUB_REF}" \
--pipeline_trigger_type "${GITHUB_EVENT_NAME}" \
--image_type "${IMAGE_TYPE}"

tag_release:
needs: build_and_publish_images
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
should_publish: ${{ steps.tag.outputs.should_publish }}
tag_name: ${{ steps.tag.outputs.tag_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Create release tag if missing
id: tag
run: |
version=$(sed -n 's/^ARG VERSION=\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[[:space:]]*$/\1/p' Dockerfile | head -n 1)
[ -n "${version}" ] || { echo "::error::Could not parse ARG VERSION=X.Y.Z from Dockerfile"; exit 1; }
tag="v${version}"
existing_refs=$(git ls-remote --tags origin "refs/tags/${tag}" "refs/tags/${tag}^{}")
if [ -n "${existing_refs}" ]; then
tag_commit=$(printf '%s\n' "${existing_refs}" | awk '$2 ~ /\^\{\}$/ {c=$1} !c {c=$1} END {print c}')
if [ "${tag_commit}" != "${GITHUB_SHA}" ]; then
echo "Tag ${tag} already exists at ${tag_commit}; skipping."
echo "should_publish=false" >> "${GITHUB_OUTPUT}"
exit 0
fi
echo "Tag ${tag} already points to ${GITHUB_SHA}; proceeding to versioned publish."
else
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${tag}" "${GITHUB_SHA}" -m "Release ${tag}"
git push origin "refs/tags/${tag}"
fi
echo "should_publish=true" >> "${GITHUB_OUTPUT}"
echo "tag_name=${tag}" >> "${GITHUB_OUTPUT}"

publish_tagged_images:
needs: tag_release
if: needs.tag_release.outputs.should_publish == 'true'
uses: ./.github/workflows/publish_docker_images_on_tag.yml
with:
tag_name: ${{ needs.tag_release.outputs.tag_name }}
secrets: inherit
44 changes: 28 additions & 16 deletions .github/workflows/publish_docker_images_on_tag.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
name: Build Docker Image On Tag Push

env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
permissions:
contents: read

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_call:
inputs:
tag_name:
description: "Release tag to build and publish (e.g. v14.3.0)"
required: true
type: string

jobs:
build_and_publish_images:
runs-on: ubuntu-24.04
Expand All @@ -33,23 +39,29 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Clone tools branch
run: git clone -b v0.8.38 --depth=1 https://github.com/citusdata/tools.git tools

- name: Install package dependencies
run: sudo apt-get update && sudo apt install libcurl4-openssl-dev libssl-dev python3-testresources

- name: Install python requirements
run: python -m pip install -r tools/packaging_automation/requirements.txt
- name: Setup tools
uses: ./.github/actions/setup-tools

- name: DockerHub Login
run: docker login -u "${DOCKERHUB_USER_NAME}" -p "${DOCKERHUB_PASSWORD}"
env:
DOCKERHUB_USER_NAME: ${{ secrets.DOCKERHUB_USER_NAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USER_NAME}" --password-stdin

- name: Build and publish docker images
env:
DOCKER_BUILD_MULTI_ARCH: "1"
INPUT_TAG_NAME: ${{ inputs.tag_name }}
IMAGE_TYPE: ${{ matrix.image_type }}
run: |
python -m tools.packaging_automation.publish_docker \
--github_ref "${GITHUB_REF}" \
--pipeline_trigger_type "${GITHUB_EVENT_NAME}" \
--image_type "${{ matrix.image_type }}"
if [ -n "${INPUT_TAG_NAME}" ]; then
[[ "${INPUT_TAG_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Invalid tag_name '${INPUT_TAG_NAME}'"; exit 1; }
target_ref="refs/tags/${INPUT_TAG_NAME}"
else
target_ref="${GITHUB_REF}"
fi
git checkout --quiet "${target_ref}"
python -m tools.packaging_automation.publish_docker \
--github_ref "${target_ref}" \
--pipeline_trigger_type push \
--image_type "${IMAGE_TYPE}"
Loading
Loading