-
Notifications
You must be signed in to change notification settings - Fork 9
229 lines (221 loc) · 7.86 KB
/
package.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# 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@v6
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 }}