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
153 changes: 98 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'new_version'
type: 'choice'
options:
- new_version
- from_version
version:
description: 'Version to release(e.g. 12)'
required: false
type: 'string'
images:
description: 'Comma-separated list of images to release (e.g. "centos7-oj8,hdp3.1-hive")'
required: true
Expand All @@ -28,22 +16,40 @@ on:
env:
GIT_CI_USER: ${{ vars.GIT_CI_USER || 'prestodb-ci' }}
GIT_CI_EMAIL: ${{ vars.GIT_CI_EMAIL || 'ci@lists.prestodb.io' }}
LOCAL_IMAGES: ${{ vars.LOCAL_IMAGES || '' }}
MULTI_IMAGES: ${{ vars.MULTI_IMAGES || '' }}

jobs:
validate-branch:
name: Validate branch
runs-on: ubuntu-latest
steps:
- name: Check branch name
run: |
BRANCH_NAME="${{ github.ref }}"
echo "Branch: ${BRANCH_NAME}"

if [[ "${BRANCH_NAME}" == "refs/heads/master" ]] || \
[[ "${BRANCH_NAME}" == refs/heads/release-* ]] || \
[[ "${BRANCH_NAME}" == refs/heads/patch-* ]]; then
echo "βœ“ Branch is allowed: ${BRANCH_NAME}"
else
echo "βœ— Error: Release workflow can only be run on master, release-*, or patch-* branches"
echo " Current branch: ${BRANCH_NAME}"
exit 1
fi

release-branch:
name: Prepare release branch
if: ${{ github.event.inputs.release_type == 'new_version' }}
needs: [validate-branch]
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
outputs:
release_version: ${{ steps.release_tag.outputs.release_version }}
steps:
- name: Check for master branch
if: ${{ github.ref != 'refs/heads/master' }}
run: echo "Invalid branch. New release can only be run on the master branch." && exit 1

- name: Checkout code
uses: actions/checkout@v4
with:
Expand All @@ -57,38 +63,45 @@ jobs:
git config --global alias.ls 'log --pretty=format:"%cd %h %ce: %s" --date=short --no-merges'
git ls -5

- name: Create release tag
- name: Create release branch and tag
id: release_tag
if: ${{ github.ref == 'refs/heads/master' }}
run: |
CURRENT_VERSION=$(grep "VERSION :=" Makefile | sed 's/VERSION := //' | sed 's/-SNAPSHOT//')
NEW_VERSION=${{ github.event.inputs.version }}
NEW_VERSION=${CURRENT_VERSION}

if [ -z "$NEW_VERSION" ]; then
NEW_VERSION=${CURRENT_VERSION}
fi
# Create release branch
git checkout -b release-${NEW_VERSION}

# Update version in Makefile
sed -i "s/VERSION := .*/VERSION := ${NEW_VERSION}/" Makefile
echo "release_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
git add Makefile
git commit -m "[release-action] release version ${NEW_VERSION}"
git ls -5

# Create release tag
git tag -a -m "Release version ${NEW_VERSION}" ${NEW_VERSION}

# Push release branch and tag
git push origin release-${NEW_VERSION} --tags

# Switch back to master for next snapshot version
git checkout master

- name: Prepare next snapshot version
run: |
sed -i "s/VERSION := .*/VERSION := $((NEW_VERSION + 1))-SNAPSHOT/" Makefile
sed -i "s/VERSION := .*/VERSION := $((${{ steps.release_tag.outputs.release_version }} + 1))-SNAPSHOT/" Makefile
git add Makefile
git commit -m "[release-action] prepare for next development iteration"
git ls -5
git push origin master --tags
git push origin master

publish-images:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
needs: [release-branch]
needs: [validate-branch, release-branch]
if: (!failure() && !cancelled())
steps:
- name: Validate inputs
Expand All @@ -97,28 +110,23 @@ jobs:
echo "Error: Image names are required."
exit 1
fi
if [ "${{ github.event.inputs.release_type }}" != "new_version" ]; then
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "Error: Version is required for from_version release type."
exit 1
fi
fi

- name: Get checkout branch
run: |
echo "Get checking out branch"
if [ "${{ github.event.inputs.release_type }}" = "new_version" ]; then
echo "RELEASE_VERSION=${{ needs.release-branch.outputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
fi
echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}"

- name: Checkout code
uses: actions/checkout@v4
with:
show-progress: false
ref: refs/tags/${{ env.RELEASE_VERSION }}

- name: Determine release version
run: |
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
# New release from master
echo "RELEASE_VERSION=${{ needs.release-branch.outputs.release_version }}" >> $GITHUB_ENV
else
# Publishing from release/patch branch - extract version from Makefile
RELEASE_VERSION=$(grep "VERSION :=" Makefile | sed 's/VERSION := //' | sed 's/-SNAPSHOT//')
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
fi
echo "Release version: ${{ env.RELEASE_VERSION }}"

- name: Configure Git
run: |
Expand All @@ -127,6 +135,9 @@ jobs:
git config --global alias.ls 'log --pretty=format:"%cd %h %ce: %s" --date=short --no-merges'
git ls -5

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -136,28 +147,60 @@ jobs:
- name: Release Selected Images
env:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
DOCKER_ORG: ${{ github.repository_owner }}
LOCAL_IMAGES: ${{ env.LOCAL_IMAGES }}
MULTI_IMAGES: ${{ env.MULTI_IMAGES }}
run: |
IMAGES="${{ github.event.inputs.images }}"

IFS=',' read -ra IMAGE_ARRAY <<< "$IMAGES"
IFS=',' read -ra LOCAL_ARRAY <<< "$LOCAL_IMAGES"
IFS=',' read -ra MULTI_ARRAY <<< "$MULTI_IMAGES"

# Function to check if image is in array
contains() {
local item="$1"
shift
for elem in "$@"; do
[[ "$elem" == "$item" ]] && return 0
done
return 1
}

for IMAGE in "${IMAGE_ARRAY[@]}"; do
echo "Building image: $IMAGE"
if [ "$IMAGE" = "centos7-oj8" ]; then
echo "Processing image: $IMAGE"

if contains "$IMAGE" "${MULTI_ARRAY[@]}"; then
echo "Building multi-arch image: $IMAGE"
make "prestodb/$IMAGE@multi" DOCKER_ORG="${DOCKER_ORG}" VERSION="${RELEASE_VERSION}"
echo "Multi-arch image built and pushed"

elif contains "$IMAGE" "${LOCAL_ARRAY[@]}"; then
echo "Building local single-arch image: $IMAGE"
make "prestodb/$IMAGE@local"

# Tag and push the local image
echo "Tagging and pushing image: $IMAGE"
docker tag "prestodb/$IMAGE:latest" "${DOCKER_ORG}/$IMAGE:${RELEASE_VERSION}"
docker push "${DOCKER_ORG}/$IMAGE:${RELEASE_VERSION}"

if [ "${{ github.event.inputs.tag_latest }}" = "true" ]; then
docker tag "prestodb/$IMAGE:latest" "${DOCKER_ORG}/$IMAGE:latest"
docker push "${DOCKER_ORG}/$IMAGE:latest"
fi

else
echo "Image $IMAGE not found in LOCAL_IMAGES or MULTI_IMAGES variables"
make "prestodb/$IMAGE"
fi
docker images
done

for IMAGE in "${IMAGE_ARRAY[@]}"; do
echo "Publishing image: $IMAGE"
docker tag "prestodb/$IMAGE:latest" "${{ github.repository_owner }}/$IMAGE:$RELEASE_VERSION"
docker push "${{ github.repository_owner }}/$IMAGE:$RELEASE_VERSION"
docker tag "prestodb/$IMAGE:latest" "${DOCKER_ORG}/$IMAGE:${RELEASE_VERSION}"
docker push "${DOCKER_ORG}/$IMAGE:${RELEASE_VERSION}"

if [ "${{ github.event.inputs.tag_latest }}" = "true" ]; then
docker tag "prestodb/$IMAGE:latest" "${{ github.repository_owner }}/$IMAGE:latest"
docker push "${{ github.repository_owner }}/$IMAGE:latest"
if [ "${{ github.event.inputs.tag_latest }}" = "true" ]; then
docker tag "prestodb/$IMAGE:latest" "${DOCKER_ORG}/$IMAGE:latest"
docker push "${DOCKER_ORG}/$IMAGE:latest"
fi
fi

echo "Completed processing: $IMAGE"
done
26 changes: 24 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BUILDDIR=build
DEPDIR=$(BUILDDIR)/depends
FLAGDIR=$(BUILDDIR)/flags
ORGDIR=prestodb
DOCKER_ORG?=prestodb
FORCE_PULL?=false

#
Expand Down Expand Up @@ -56,6 +57,7 @@ UNLABELLED_TAGS := $(addsuffix @unlabelled,$(IMAGE_DIRS))
PARENT_CHECKS := $(addsuffix -parent-check,$(IMAGE_DIRS))
LATEST_TAGS := $(addsuffix @latest,$(IMAGE_DIRS))
LOCAL_TAGS := $(addsuffix @local,$(IMAGE_DIRS))
MULTI_TAGS := $(addsuffix @multi,$(IMAGE_DIRS))
VERSION_TAGS := $(addsuffix @$(VERSION),$(IMAGE_DIRS))
GIT_HASH := $(shell git rev-parse --short HEAD)
GIT_HASH_TAGS := $(addsuffix @$(GIT_HASH),$(IMAGE_DIRS))
Expand Down Expand Up @@ -95,7 +97,7 @@ docker-tag = $(subst @,:,$(1))
# continues to build them if a file with a matching name somehow comes into
# existence
#
.PHONY: $(IMAGE_DIRS) $(LATEST_TAGS) $(UNLABELLED_TAGS) $(VERSION_TAGS) $(GIT_HASH_TAGS)
.PHONY: $(IMAGE_DIRS) $(LATEST_TAGS) $(UNLABELLED_TAGS) $(VERSION_TAGS) $(GIT_HASH_TAGS) $(MULTI_TAGS)
.PHONY: $(PARENT_CHECKS) $(IMAGE_TESTS) $(EXTERNAL_DEPS)

# By default, build all of the images.
Expand Down Expand Up @@ -234,6 +236,26 @@ $(LOCAL_TAGS): %@local: %/Dockerfile %-parent-check
@echo
cd $* && time $(SHELL) -c "( tar -czh . | docker build ${BUILD_ARGS} ${BUILD_ARGS_$*} $(DBFLAGS_$*) -t $(call docker-tag,$@) --label $(LABEL) - )"
docker tag $(call docker-tag,$@) $(shell $(SHELL) $(LABEL_PARENT_SH) $*:latest)

#
# Multi-arch build target using buildx
# This builds and pushes multi-architecture images directly to the registry
# Supports linux/amd64 and linux/arm64 platforms
#
$(MULTI_TAGS): %@multi: %/Dockerfile %-parent-check
@echo
@echo "Building multi-arch [$@] image and pushing to $(DOCKER_ORG)"
@echo
docker buildx create --use --name multiarch-builder --driver docker-container || docker buildx use multiarch-builder
cd $* && docker buildx build \
${BUILD_ARGS} ${BUILD_ARGS_$*} $(DBFLAGS_$*) \
--platform linux/amd64,linux/arm64 \
--label $(LABEL) \
-t $(DOCKER_ORG)/$(notdir $*):latest \
-t $(DOCKER_ORG)/$(notdir $*):$(VERSION) \
--push \
.
@echo "Multi-arch image pushed to $(DOCKER_ORG)/$(notdir $*)"
#
# Targets and variables for creating the dependency graph of the docker images
# as an image file.
Expand All @@ -260,7 +282,7 @@ $(GVFRAGS): $(GVDIR)/%.gv.frag: %/Dockerfile $(DEPEND_SH)
$(SHELL) $(DEPEND_SH) -g $< $(call docker-tag,$(UNLABELLED_TAGS)) >$@

.PHONY: test
test:
test:
$(TEST_SH) $(IMAGE_TO_TEST)

.PHONY: clean
Expand Down
4 changes: 3 additions & 1 deletion prestodb/centos7-oj8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM azul/zulu-openjdk-centos:11
FROM azul/zulu-openjdk-centos:17
LABEL maintainer="Presto community <https://prestodb.io/community.html>"

COPY ./files /tmp/files
Expand All @@ -28,6 +28,8 @@ RUN \
yum --enablerepo=extras install -y setuptools epel-release && \
yum install -y python-pip && \
pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org supervisor && \
# install python 3
yum install -y python3 python3-pip && \
\
# install commonly needed packages
yum install -y \
Expand Down
Loading