Skip to content
Merged
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
37 changes: 33 additions & 4 deletions rust/.github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,21 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

publish-docker:
name: Publish Docker Image
runs-on: ubuntu-24.04
publish-docker-image:
name: Publish Docker Image (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
needs: [publish-binary]
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-24.04
target: x86_64-unknown-linux-musl
suffix: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
suffix: arm64
steps:
- name: Checkout code.
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
Expand All @@ -55,6 +66,24 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Docker Image
run: make publish-docker RELEASE="${GITHUB_REF_NAME}"
run: make publish-docker-image RELEASE="${GITHUB_REF_NAME}" PLATFORM="${{ matrix.platform }}" TARGET="${{ matrix.target }}" SUFFIX="${{ matrix.suffix }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-docker-manifest:
name: Publish Docker Manifest
runs-on: ubuntu-24.04
needs: [publish-docker-image]
steps:
- name: Checkout code.
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Docker Manifest
run: make publish-docker-manifest RELEASE="${GITHUB_REF_NAME}"
10 changes: 7 additions & 3 deletions rust/Makefile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ dogfood-docker: release
docker build --build-arg TARGET=$(MUSL_TARGET) --tag {{ project_name }} --file Dockerfile .
docker run --rm --volume $(PWD):/workspace --workdir /workspace --env HOME=/github/home --env GITHUB_ACTIONS=true --env CI=true {{ project_name }}

.PHONY: publish-docker
publish-docker:
./ci/publish-docker.sh ${RELEASE}
.PHONY: publish-docker-image
publish-docker-image:
./ci/publish-docker-image.sh ${RELEASE} ${PLATFORM} ${TARGET} ${SUFFIX}

.PHONY: publish-docker-manifest
publish-docker-manifest:
./ci/publish-docker-manifest.sh ${RELEASE}
25 changes: 25 additions & 0 deletions rust/ci/publish-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env sh

set -o errexit
set -o xtrace

if [ $# -ne 4 ]; then
echo "Usage: $0 <release> <platform> <target> <suffix>"
exit 1
fi

RELEASE="$1"
PLATFORM="$2"
TARGET="$3"
SUFFIX="$4"

REPOSITORY="$(basename "$(git rev-parse --show-toplevel)")"
IMAGE="ghcr.io/developerc286/${REPOSITORY}"

# Download and extract pre-built binary from the GitHub release for this architecture.
gh release download "${RELEASE}" --pattern "${TARGET}.tar.gz"
mkdir -p "target/${TARGET}/release"
tar -xzf "${TARGET}.tar.gz" -C "target/${TARGET}/release"

# Build and push the Docker image for this architecture natively (no QEMU emulation).
docker buildx build --platform "${PLATFORM}" --build-arg TARGET="${TARGET}" --tag "${IMAGE}:${RELEASE}-${SUFFIX}" --file Dockerfile . --push
27 changes: 27 additions & 0 deletions rust/ci/publish-docker-manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env sh

set -o errexit
set -o xtrace

if [ $# -ne 1 ]; then
echo "Usage: $0 <release>"
exit 1
fi

RELEASE="$1"
REPOSITORY="$(basename "$(git rev-parse --show-toplevel)")"
IMAGE="ghcr.io/developerc286/${REPOSITORY}"

# Create and push the multi-architecture manifest.
docker buildx imagetools create --tag "${IMAGE}:${RELEASE}" \
"${IMAGE}:${RELEASE}-amd64" \
"${IMAGE}:${RELEASE}-arm64"

# Create alternate version tag (with/without 'v' prefix).
if [ "${RELEASE#v}" != "${RELEASE}" ]; then
# Release has 'v' prefix (v1.2.3), also create version without 'v' prefix (1.2.3).
docker buildx imagetools create --tag "${IMAGE}:${RELEASE#v}" "${IMAGE}:${RELEASE}"
else
# Release has no 'v' prefix (1.2.3), also create version with 'v' prefix (v1.2.3).
docker buildx imagetools create --tag "${IMAGE}:v${RELEASE}" "${IMAGE}:${RELEASE}"
fi
42 changes: 0 additions & 42 deletions rust/ci/publish-docker.sh

This file was deleted.