Skip to content

Commit f82bdf0

Browse files
committed
Add github action to publish dependency image
1 parent 21c5810 commit f82bdf0

File tree

2 files changed

+175
-2
lines changed

2 files changed

+175
-2
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Publish Dependency 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+
os:
11+
description: 'Operating system (ubuntu/centos)'
12+
required: true
13+
default: 'centos'
14+
type: choice
15+
options:
16+
- centos
17+
- ubuntu
18+
tag_suffix:
19+
description: 'Tag suffix (can be empty)'
20+
required: false
21+
default: ''
22+
tag_latest:
23+
description: 'Tag the image as latest'
24+
type: boolean
25+
default: true
26+
required: false
27+
28+
concurrency:
29+
group: publish-dependency-image
30+
cancel-in-progress: false
31+
32+
env:
33+
JAVA_VERSION: ${{ vars.JAVA_VERSION || '17' }}
34+
JAVA_DISTRIBUTION: ${{ vars.JAVA_DISTRIBUTION || 'temurin' }}
35+
DOCKER_REPO: ${{ github.repository }}
36+
ORG_NAME: ${{ github.repository_owner }}
37+
IMAGE_NAME: presto-native-dependency
38+
GIT_CI_USER: ${{ vars.GIT_CI_USER || 'prestodb-ci' }}
39+
GIT_CI_EMAIL: ${{ vars.GIT_CI_EMAIL || '[email protected]' }}
40+
41+
jobs:
42+
publish-dependency-image:
43+
strategy:
44+
matrix:
45+
arch: [amd64, arm64]
46+
fail-fast: false
47+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
48+
environment: release
49+
timeout-minutes: 150
50+
permissions:
51+
packages: write
52+
contents: read
53+
steps:
54+
- name: Set up JDK ${{ env.JAVA_DISTRIBUTION }}/${{ env.JAVA_VERSION }}
55+
uses: actions/setup-java@v4
56+
with:
57+
java-version: ${{ env.JAVA_VERSION }}
58+
distribution: ${{ env.JAVA_DISTRIBUTION }}
59+
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
with:
63+
ref: ${{ inputs.branch_or_tag }}
64+
fetch-depth: 1
65+
66+
- name: Configure git
67+
run: |
68+
git config --global user.email "${{ env.GIT_CI_EMAIL }}"
69+
git config --global user.name "${{ env.GIT_CI_USER }}"
70+
71+
echo "Currently on: $(git rev-parse --abbrev-ref HEAD)"
72+
echo "Commit SHA: $(git rev-parse HEAD)"
73+
echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
74+
75+
- name: Checkout submodules
76+
working-directory: presto-native-execution
77+
run: |
78+
df -h
79+
make submodules
80+
81+
- name: Extract version
82+
run: |
83+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
84+
echo "Raw version: $VERSION"
85+
86+
if [ -z "$VERSION" ]; then
87+
echo "Failed to extract project version with Maven"
88+
exit 1
89+
fi
90+
91+
if [[ "$VERSION" == *"-SNAPSHOT" ]]; then
92+
# Remove -SNAPSHOT and append commit SHA
93+
CLEAN_VERSION=${VERSION%-SNAPSHOT}
94+
TAG_VERSION="${CLEAN_VERSION}-${COMMIT_SHA}"
95+
echo "SNAPSHOT version detected, using: $TAG_VERSION"
96+
else
97+
TAG_VERSION="$VERSION"
98+
echo "Release version detected, using: $TAG_VERSION"
99+
fi
100+
101+
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV
102+
103+
- name: Login to DockerHub
104+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.0.0
105+
with:
106+
username: ${{ secrets.DOCKERHUB_USERNAME }}
107+
password: ${{ secrets.DOCKERHUB_TOKEN }}
108+
109+
- name: Set up QEMU
110+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.0.0
111+
112+
- name: Set up buildx
113+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.0.0
114+
115+
- name: Set up builder
116+
run: |
117+
docker buildx create --name container --use
118+
docker buildx inspect --bootstrap
119+
120+
- name: Set image tag
121+
run: |
122+
TAG_BASE="${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ inputs.os }}-${{ env.VERSION }}-${{ matrix.arch }}"
123+
124+
if [[ -n "${{ inputs.tag_suffix }}" ]]; then
125+
echo "IMAGE_TAG=${TAG_BASE}-${{ inputs.tag_suffix }}" >> $GITHUB_ENV
126+
else
127+
echo "IMAGE_TAG=${TAG_BASE}" >> $GITHUB_ENV
128+
fi
129+
130+
if [[ "${{ inputs.os }}" == "ubuntu" ]]; then
131+
echo "DEPENDENCY_TARGET=ubuntu-native-dependency" >> $GITHUB_ENV
132+
echo "LOCAL_IMAGE_TAG=presto/prestissimo-dependency:ubuntu-22.04" >> $GITHUB_ENV
133+
else
134+
echo "DEPENDENCY_TARGET=centos-native-dependency" >> $GITHUB_ENV
135+
echo "LOCAL_IMAGE_TAG=presto/prestissimo-dependency:centos9" >> $GITHUB_ENV
136+
fi
137+
138+
- name: Build image
139+
working-directory: presto-native-execution
140+
run: |
141+
df -h
142+
echo "Using image tag: $IMAGE_TAG"
143+
144+
if [[ "${{ matrix.arch }}" == "arm64" ]]; then
145+
BUILD_ARGS="--build-arg ARM_BUILD_TARGET=generic"
146+
else
147+
BUILD_ARGS=""
148+
fi
149+
150+
echo "BUILD_ARGS=${BUILD_ARGS}"
151+
docker compose build ${BUILD_ARGS} ${{ env.DEPENDENCY_TARGET }}
152+
153+
- name: Publish image
154+
run: |
155+
set -e
156+
docker tag ${{ env.LOCAL_IMAGE_TAG }} ${{ env.IMAGE_TAG }}
157+
docker push ${{ env.IMAGE_TAG }}
158+
159+
if [[ "${{ inputs.tag_latest }}" == "true" ]]; then
160+
LATEST_TAG="${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ inputs.os }}-${{ matrix.arch }}-latest"
161+
docker tag ${{ env.LOCAL_IMAGE_TAG }} ${LATEST_TAG}
162+
docker push ${LATEST_TAG}
163+
echo "Tagged and pushed as latest: ${LATEST_TAG}"
164+
fi

presto-native-execution/scripts/dockerfiles/ubuntu-22.04-dependency.dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,19 @@ COPY velox/scripts /velox/scripts
3636
# from https://github.com/facebookincubator/velox/pull/14016
3737
COPY velox/CMake/resolve_dependency_modules/arrow/cmake-compatibility.patch /velox
3838
ENV VELOX_ARROW_CMAKE_PATCH=/velox/cmake-compatibility.patch
39+
40+
RUN if [ "$(dpkg --print-architecture)" = "arm64" ]; then \
41+
apt update && \
42+
apt install -y software-properties-common && \
43+
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
44+
apt update && \
45+
apt install -y gcc-12 g++-12; \
46+
fi
47+
3948
# install rpm needed for minio install.
4049
RUN mkdir build && \
41-
(cd build && ../scripts/setup-ubuntu.sh && \
42-
apt install -y rpm && \
50+
(cd build && apt update && apt install -y rpm sudo && \
51+
../scripts/setup-ubuntu.sh && \
4352
../velox/scripts/setup-ubuntu.sh install_adapters && \
4453
../scripts/setup-adapters.sh ) && \
4554
rm -rf build

0 commit comments

Comments
 (0)