Skip to content

Commit e947e6b

Browse files
committed
Add github action to publish dependency image
1 parent 1762f52 commit e947e6b

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
74+
- name: Checkout submodules
75+
run: |
76+
df -h
77+
cd presto-native-execution && make submodules
78+
echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
79+
80+
- name: Extract version
81+
run: |
82+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
83+
echo "Raw version: $VERSION"
84+
85+
if [[ "$VERSION" == *"-SNAPSHOT" ]]; then
86+
# Remove -SNAPSHOT and append commit SHA
87+
CLEAN_VERSION=${VERSION%-SNAPSHOT}
88+
TAG_VERSION="${CLEAN_VERSION}-${COMMIT_SHA}"
89+
echo "SNAPSHOT version detected, using: $TAG_VERSION"
90+
else
91+
TAG_VERSION="$VERSION"
92+
echo "Release version detected, using: $TAG_VERSION"
93+
fi
94+
95+
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV
96+
97+
- name: Login to DockerHub
98+
uses: docker/login-action@v3
99+
with:
100+
username: ${{ secrets.DOCKERHUB_USERNAME }}
101+
password: ${{ secrets.DOCKERHUB_TOKEN }}
102+
103+
- name: Set up QEMU
104+
uses: docker/setup-qemu-action@v3
105+
106+
- name: Set up buildx
107+
uses: docker/setup-buildx-action@v3
108+
109+
- name: Set up builder
110+
run: |
111+
docker buildx create --name container --use
112+
docker buildx inspect --bootstrap
113+
114+
- name: Set image tag
115+
run: |
116+
TAG_BASE="${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ inputs.os }}-${{ env.VERSION }}-${{ matrix.arch }}"
117+
118+
if [[ -n "${{ inputs.tag_suffix }}" ]]; then
119+
echo "IMAGE_TAG=${TAG_BASE}-${{ inputs.tag_suffix }}" >> $GITHUB_ENV
120+
else
121+
echo "IMAGE_TAG=${TAG_BASE}" >> $GITHUB_ENV
122+
fi
123+
124+
if [[ "${{ inputs.os }}" == "ubuntu" ]]; then
125+
echo "DEPENDENCY_TARGET=ubuntu-native-dependency" >> $GITHUB_ENV
126+
echo "LOCAL_IMAGE_TAG=presto/prestissimo-dependency:ubuntu-22.04" >> $GITHUB_ENV
127+
else
128+
echo "DEPENDENCY_TARGET=centos-native-dependency" >> $GITHUB_ENV
129+
echo "LOCAL_IMAGE_TAG=presto/prestissimo-dependency:centos9" >> $GITHUB_ENV
130+
fi
131+
132+
- name: Build image
133+
working-directory: presto-native-execution
134+
run: |
135+
df -h
136+
echo "Using image tag: $IMAGE_TAG"
137+
138+
if [[ "${{ matrix.arch }}" == "arm64" ]]; then
139+
BUILD_ARGS="--build-arg ARM_BUILD_TARGET=generic"
140+
else
141+
BUILD_ARGS=""
142+
fi
143+
144+
echo "BUILD_ARGS=${BUILD_ARGS}"
145+
docker compose build ${BUILD_ARGS} ${{ env.DEPENDENCY_TARGET }}
146+
147+
- name: Publish image
148+
run: |
149+
docker tag ${{ env.LOCAL_IMAGE_TAG }} ${{ env.IMAGE_TAG }}
150+
docker push ${{ env.IMAGE_TAG }}
151+
152+
if [[ "${{ inputs.tag_latest }}" == "true" ]]; then
153+
LATEST_TAG="${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ inputs.os }}-${{ matrix.arch }}-latest"
154+
docker tag ${{ env.LOCAL_IMAGE_TAG }} ${LATEST_TAG}
155+
docker push ${LATEST_TAG}
156+
echo "Tagged and pushed as latest: ${LATEST_TAG}"
157+
fi

0 commit comments

Comments
 (0)