Skip to content

Commit 7724711

Browse files
committed
Add github action to publish runtime images
1 parent 0ba99d1 commit 7724711

File tree

2 files changed

+503
-0
lines changed

2 files changed

+503
-0
lines changed
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
name: Publish Prestissimo Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch_or_tag:
7+
description: 'Branch or tag to checkout (e.g., master, 0.295)'
8+
required: true
9+
default: 'master'
10+
dependency_image:
11+
description: 'Dependency image to use'
12+
required: true
13+
default: 'prestodb/presto-native-dependency:centos-latest'
14+
os:
15+
description: 'Operating system (ubuntu/centos)'
16+
required: true
17+
default: 'centos'
18+
type: choice
19+
options:
20+
- centos
21+
- ubuntu
22+
tag_suffix:
23+
description: 'Tag suffix (can be empty)'
24+
required: false
25+
default: ''
26+
tag_latest:
27+
description: 'Tag the image as latest'
28+
type: boolean
29+
default: true
30+
required: false
31+
32+
concurrency:
33+
group: publish-prestissimo-image
34+
cancel-in-progress: false
35+
36+
env:
37+
JAVA_VERSION: ${{ vars.JAVA_VERSION || '17' }}
38+
JAVA_DISTRIBUTION: ${{ vars.JAVA_DISTRIBUTION || 'temurin' }}
39+
DOCKER_REPO: ${{ github.repository }}
40+
ORG_NAME: ${{ github.repository_owner }}
41+
IMAGE_NAME: prestissimo
42+
GIT_CI_USER: ${{ vars.GIT_CI_USER || 'prestodb-ci' }}
43+
GIT_CI_EMAIL: ${{ vars.GIT_CI_EMAIL || '[email protected]' }}
44+
45+
jobs:
46+
publish-prestissimo-image:
47+
strategy:
48+
matrix:
49+
arch: [amd64, arm64]
50+
fail-fast: false
51+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
52+
environment: release
53+
timeout-minutes: 150
54+
permissions:
55+
packages: write
56+
contents: read
57+
steps:
58+
- name: Set up JDK ${{ env.JAVA_DISTRIBUTION }}/${{ env.JAVA_VERSION }}
59+
uses: actions/setup-java@v4
60+
with:
61+
java-version: ${{ env.JAVA_VERSION }}
62+
distribution: ${{ env.JAVA_DISTRIBUTION }}
63+
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
with:
67+
ref: ${{ inputs.branch_or_tag }}
68+
fetch-depth: 1
69+
70+
- name: Configure git
71+
run: |
72+
git config --global user.email "${{ env.GIT_CI_EMAIL }}"
73+
git config --global user.name "${{ env.GIT_CI_USER }}"
74+
75+
echo "Currently on: $(git rev-parse --abbrev-ref HEAD)"
76+
echo "Commit SHA: $(git rev-parse HEAD)"
77+
echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
78+
79+
- name: Checkout submodules
80+
working-directory: presto-native-execution
81+
run: |
82+
df -h
83+
make submodules
84+
85+
- name: Extract version
86+
run: |
87+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
88+
echo "Raw version: $VERSION"
89+
90+
if [ -z "$VERSION" ]; then
91+
echo "Failed to extract project version with Maven"
92+
exit 1
93+
fi
94+
95+
if [[ "$VERSION" == *"-SNAPSHOT" ]]; then
96+
# Remove -SNAPSHOT and append commit SHA
97+
CLEAN_VERSION=${VERSION%-SNAPSHOT}
98+
TAG_VERSION="${CLEAN_VERSION}-${COMMIT_SHA}"
99+
echo "SNAPSHOT version detected, using: $TAG_VERSION"
100+
else
101+
TAG_VERSION="$VERSION"
102+
echo "Release version detected, using: $TAG_VERSION"
103+
fi
104+
105+
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV
106+
107+
- name: Login to DockerHub
108+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.0.0
109+
with:
110+
username: ${{ secrets.DOCKERHUB_USERNAME }}
111+
password: ${{ secrets.DOCKERHUB_TOKEN }}
112+
113+
- name: Set up QEMU
114+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.0.0
115+
116+
- name: Set up buildx
117+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.0.0
118+
119+
- name: Set up builder
120+
run: |
121+
docker buildx create --name container --use
122+
docker buildx inspect --bootstrap
123+
124+
- name: Set image tag and base image
125+
run: |
126+
TAG_BASE="${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ inputs.os }}-${{ env.VERSION }}-${{ matrix.arch }}"
127+
128+
if [[ -n "${{ inputs.tag_suffix }}" ]]; then
129+
echo "IMAGE_TAG=${TAG_BASE}-${{ inputs.tag_suffix }}" >> $GITHUB_ENV
130+
else
131+
echo "IMAGE_TAG=${TAG_BASE}" >> $GITHUB_ENV
132+
fi
133+
134+
if [[ "${{ inputs.os }}" == "ubuntu" ]]; then
135+
echo "BASE_IMAGE=ubuntu:22.04" >> $GITHUB_ENV
136+
else
137+
echo "BASE_IMAGE=quay.io/centos/centos:stream9" >> $GITHUB_ENV
138+
fi
139+
140+
- name: Build prestissimo image
141+
working-directory: presto-native-execution
142+
run: |
143+
df -h
144+
echo "Using image tag: $IMAGE_TAG"
145+
echo "Using dependency image: ${{ inputs.dependency_image }}"
146+
echo "Using base image: $BASE_IMAGE"
147+
148+
if [[ "${{ matrix.arch }}" == "arm64" ]]; then
149+
BUILD_ARGS="--build-arg ARM_BUILD_TARGET=generic"
150+
else
151+
BUILD_ARGS=""
152+
fi
153+
154+
# Build the prestissimo image using Docker buildx
155+
docker buildx build \
156+
--platform linux/${{ matrix.arch }} \
157+
--build-arg DEPENDENCY_IMAGE=${{ inputs.dependency_image }} \
158+
--build-arg BASE_IMAGE=$BASE_IMAGE \
159+
--build-arg OSNAME=${{ inputs.os }} \
160+
--build-arg BUILD_TYPE=Release \
161+
${BUILD_ARGS} \
162+
-f scripts/dockerfiles/prestissimo-runtime.dockerfile \
163+
-t ${{ env.IMAGE_TAG }} \
164+
--load \
165+
.
166+
167+
- name: Publish image
168+
run: |
169+
set -e
170+
docker push ${{ env.IMAGE_TAG }}
171+
172+
if [[ "${{ inputs.tag_latest }}" == "true" ]]; then
173+
LATEST_TAG="${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ inputs.os }}-${{ matrix.arch }}-latest"
174+
docker tag ${{ env.IMAGE_TAG }} ${LATEST_TAG}
175+
docker push ${LATEST_TAG}
176+
echo "Tagged and pushed as latest: ${LATEST_TAG}"
177+
fi
178+
179+
create-manifest:
180+
needs: publish-prestissimo-image
181+
runs-on: ubuntu-latest
182+
environment: release
183+
permissions:
184+
packages: write
185+
contents: read
186+
steps:
187+
- name: Login to DockerHub
188+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.0.0
189+
with:
190+
username: ${{ secrets.DOCKERHUB_USERNAME }}
191+
password: ${{ secrets.DOCKERHUB_TOKEN }}
192+
193+
- name: Checkout
194+
uses: actions/checkout@v4
195+
with:
196+
ref: ${{ inputs.branch_or_tag }}
197+
fetch-depth: 1
198+
199+
- name: Extract version
200+
run: |
201+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
202+
echo "Raw version: $VERSION"
203+
204+
if [ -z "$VERSION" ]; then
205+
echo "Failed to extract project version with Maven"
206+
exit 1
207+
fi
208+
209+
if [[ "$VERSION" == *"-SNAPSHOT" ]]; then
210+
# Remove -SNAPSHOT and append commit SHA
211+
CLEAN_VERSION=${VERSION%-SNAPSHOT}
212+
COMMIT_SHA=$(git rev-parse --short HEAD)
213+
TAG_VERSION="${CLEAN_VERSION}-${COMMIT_SHA}"
214+
echo "SNAPSHOT version detected, using: $TAG_VERSION"
215+
else
216+
TAG_VERSION="$VERSION"
217+
echo "Release version detected, using: $TAG_VERSION"
218+
fi
219+
220+
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV
221+
222+
- name: Create and push multi-arch manifest
223+
run: |
224+
ORG_NAME="${{ github.repository_owner }}"
225+
IMAGE_NAME="prestissimo"
226+
OS="${{ inputs.os }}"
227+
VERSION="${{ env.VERSION }}"
228+
229+
# Determine tag suffix
230+
if [[ -n "${{ inputs.tag_suffix }}" ]]; then
231+
TAG_SUFFIX="-${{ inputs.tag_suffix }}"
232+
else
233+
TAG_SUFFIX=""
234+
fi
235+
236+
# Create manifest for the versioned tag
237+
MANIFEST_TAG="${ORG_NAME}/${IMAGE_NAME}:${OS}-${VERSION}${TAG_SUFFIX}"
238+
AMD64_TAG="${ORG_NAME}/${IMAGE_NAME}:${OS}-${VERSION}-amd64${TAG_SUFFIX}"
239+
ARM64_TAG="${ORG_NAME}/${IMAGE_NAME}:${OS}-${VERSION}-arm64${TAG_SUFFIX}"
240+
241+
echo "Creating manifest: ${MANIFEST_TAG}"
242+
docker manifest create ${MANIFEST_TAG} ${AMD64_TAG} ${ARM64_TAG}
243+
docker manifest push ${MANIFEST_TAG}
244+
245+
# Create latest manifest if requested
246+
if [[ "${{ inputs.tag_latest }}" == "true" ]]; then
247+
LATEST_MANIFEST="${ORG_NAME}/${IMAGE_NAME}:${OS}-latest"
248+
LATEST_AMD64="${ORG_NAME}/${IMAGE_NAME}:${OS}-amd64-latest"
249+
LATEST_ARM64="${ORG_NAME}/${IMAGE_NAME}:${OS}-arm64-latest"
250+
251+
echo "Creating latest manifest: ${LATEST_MANIFEST}"
252+
docker manifest create ${LATEST_MANIFEST} ${LATEST_AMD64} ${LATEST_ARM64}
253+
docker manifest push ${LATEST_MANIFEST}
254+
fi
255+
256+
# Made with Bob

0 commit comments

Comments
 (0)