blob: cd492cbf83d6d5daa5845b008bf79a3d8418540c [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Package
on:
pull_request:
push:
branches:
- "*"
tags:
- "*-rc*"
concurrency:
group: ${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write
packages: write
jobs:
source:
name: Source
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
- name: Build archive
run: |
rake dist
- uses: actions/upload-artifact@v4
with:
name: source
path: apache-arrow-flight-sql-postgresql-*.tar.gz
- name: Upload to release
if: |
github.ref_type == 'tag'
run: |
rake release:note:latest > release-note.md
rc=${GITHUB_REF_NAME#*-rc}
title="$(head -n1 release-note.md | sed -e 's/^## //') RC${rc}"
tail -n +2 release-note.md > release-note-without-version.md
gh release create ${GITHUB_REF_NAME} \
--prerelease \
--notes-file release-note-without-version.md \
--title "${title}" \
apache-arrow-flight-sql-postgresql-*.tar.gz
env:
GH_TOKEN: ${{ github.token }}
linux:
name: Linux
needs:
- source
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
target:
- "debian-bookworm-amd64-postgresql-15-pgdg"
- "ubuntu-jammy-amd64-postgresql-15-pgdg"
- "debian-bookworm-amd64-postgresql-16-pgdg"
- "ubuntu-jammy-amd64-postgresql-16-pgdg"
steps:
- uses: actions/checkout@v4
with:
repository: apache/arrow
path: arrow
- uses: actions/download-artifact@v4
with:
name: source
- name: Prepare
run: |
BASE_NAME=apache-arrow-flight-sql-postgresql
echo "BASE_NAME=${BASE_NAME}" >> $GITHUB_ENV
echo "ARROW_SOURCE=$(pwd)/arrow" >> $GITHUB_ENV
full_target=${{ matrix.target }}
# debian-bookworm-amd64-postgresql-15-pgdg ->
# postgresql-15-pgdg
PACKAGE=postgresql-${full_target#*-postgresql-}
echo "PACKAGE=${PACKAGE}" >> $GITHUB_ENV
# debian-bookworm-amd64-postgresql-15-pgdg ->
# 15 ->
POSTGRESQL_VERSION=${full_target#*-postgresql-}
POSTGRESQL_VERSION=${POSTGRESQL_VERSION%-pgdg}
echo "POSTGRESQL_VERSION=${POSTGRESQL_VERSION}" >> $GITHUB_ENV
# debian-bookworm-amd64-postgresql-15-pgdg ->
# debian-bookworm-amd64
PACKAGE_TARGET=${full_target%-postgresql-*}
echo "APT_TARGETS=${PACKAGE_TARGET}" >> $GITHUB_ENV
echo "YUM_TARGETS=${PACKAGE_TARGET}" >> $GITHUB_ENV
case ${PACKAGE_TARGET} in
almalinux-*)
echo "TASK_NAMESPACE=yum" >> $GITHUB_ENV
;;
debian-*|ubuntu-*)
echo "TASK_NAMESPACE=apt" >> $GITHUB_ENV
;;
esac
DISTRIBUTION=${PACKAGE_TARGET%%-*}
echo "DISTRIBUTION=${DISTRIBUTION}" >> $GITHUB_ENV
DISTRIBUTION_VERSION=${PACKAGE_TARGET#*-}
DISTRIBUTION_VERSION=${DISTRIBUTION_VERSION%-*}
echo "DISTRIBUTION_VERSION=${DISTRIBUTION_VERSION}" >> $GITHUB_ENV
ARCHITECTURE=${PACKAGE_TARGET##*-}
echo "ARCHITECTURE=${ARCHITECTURE}" >> $GITHUB_ENV
case ${PACKAGE_TARGET} in
debian-bookworm-*)
DOCKER_IMAGE_BUILD=yes
DOCKER_TAG_PREFIX="ghcr.io/${GITHUB_REPOSITORY}:"
DOCKER_TAG_SUFFIX="-bookworm-${POSTGRESQL_VERSION}"
DOCKER_TAGS="${DOCKER_VERSION}"
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
DOCKER_TAGS="${DOCKER_TAG_PREFIX}${GITHUB_REF_NAME}${DOCKER_TAG_SUFFIX}"
DOCKER_TAGS+=",${DOCKER_TAG_PREFIX}latest${DOCKER_TAG_SUFFIX}"
else
DOCKER_TAGS="${DOCKER_TAG_PREFIX}main${DOCKER_TAG_SUFFIX}"
fi
echo "DOCKER_TAGS=${DOCKER_TAGS}" >> $GITHUB_ENV
;;
*)
DOCKER_IMAGE_BUILD=no
;;
esac
echo "DOCKER_IMAGE_BUILD=${DOCKER_IMAGE_BUILD}" >> $GITHUB_ENV
source_archive=$(echo ${BASE_NAME}-*.tar.gz)
VERSION=${source_archive#${BASE_NAME}-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Extract source archive
run: |
tar xf ${BASE_NAME}-${VERSION}.tar.gz
ln -s ${BASE_NAME}-${VERSION} ${BASE_NAME}
mv ${BASE_NAME}-${VERSION}.tar.gz ${BASE_NAME}/
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
- name: Login to GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build
run: |
pushd ${BASE_NAME}/package/${PACKAGE}
if [ "${GITHUB_REF_TYPE}" != "tag" ]; then
rake version:update
fi
rake docker:pull || :
rake --trace ${TASK_NAMESPACE}:build
popd
- name: Prepare artifacts
run: |
cp -a \
${BASE_NAME}/package/${PACKAGE}/${TASK_NAMESPACE}/repositories/${DISTRIBUTION} \
./
tar czf ${{ matrix.target }}.tar.gz ${DISTRIBUTION}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: |
${{ matrix.target }}.tar.gz
- name: Upload to release
if: |
github.ref_type == 'tag'
run: |
gh release upload --repo ${GITHUB_REPOSITORY} ${GITHUB_REF_NAME} \
${{ matrix.target }}.tar.gz
env:
GH_TOKEN: ${{ github.token }}
- name: Push Docker image for building packages
run: |
pushd ${BASE_NAME}/package/${PACKAGE}
rake docker:push || :
cp \
${TASK_NAMESPACE}/repositories/*/pool/*/*/*/*/*.deb \
../docker/
popd
- name: Test
run: |
pushd ${BASE_NAME}
docker run \
--rm \
--volume ${PWD}:/host \
${ARCHITECTURE}/${DISTRIBUTION}:${DISTRIBUTION_VERSION} \
/host/package/${TASK_NAMESPACE}/test.sh \
${VERSION} \
${POSTGRESQL_VERSION} \
local \
package/${PACKAGE}/${TASK_NAMESPACE}/repositories
popd
- uses: docker/setup-qemu-action@v3
if: env.DOCKER_IMAGE_BUILD == 'yes'
- uses: docker/setup-buildx-action@v3
if: env.DOCKER_IMAGE_BUILD == 'yes'
id: buildx
- uses: docker/build-push-action@v5
if: env.DOCKER_IMAGE_BUILD == 'yes'
id: build-push
with:
context: ${{ env.BASE_NAME }}
file: ${{ env.BASE_NAME }}/package/${{ env.PACKAGE }}/Dockerfile
platforms: linux/${{ env.ARCHITECTURE }}
push: ${{ github.event_name == 'push' }}
tags: ${{ env.DOCKER_TAGS }}