Skip to content

Commit c96a533

Browse files
committed
Moved ci/cd version detection to extension-build step.
1 parent fd8336c commit c96a533

1 file changed

Lines changed: 37 additions & 17 deletions

File tree

.github/workflows/pg-extension-build.yaml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ jobs:
6767
(github.event_name == 'workflow_dispatch') ||
6868
(github.event_name == 'pull_request' &&
6969
(github.event.action == 'labeled' && contains(join(github.event.pull_request.labels.*.name, ','), 'pg_extension')))
70+
outputs:
71+
version: ${{ steps.extract-version.outputs.version }}
7072
strategy:
7173
fail-fast: true
7274
matrix:
@@ -122,6 +124,26 @@ jobs:
122124
123125
echo -e "${GREEN}Done.${DEFAULT}"
124126
127+
- name: extract version
128+
id: extract-version
129+
shell: bash
130+
run: |-
131+
# Use provided version or extract from pkg-config or git tag
132+
if [ -n "${{ inputs.version }}" ]; then
133+
VERSION="${{ inputs.version }}"
134+
echo "Using provided version: ${VERSION}"
135+
elif [ -f "cpp/.ext/deeplake_api/lib/pkgconfig/deeplake_api.pc" ]; then
136+
VERSION=$(PKG_CONFIG_PATH="cpp/.ext/deeplake_api/lib/pkgconfig" pkg-config --modversion deeplake_api)
137+
echo "Extracted version from pkg-config: ${VERSION}"
138+
elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
139+
VERSION="${GITHUB_REF#refs/tags/v}"
140+
echo "Extracted version from git tag: ${VERSION}"
141+
else
142+
echo "Error: Could not determine version"
143+
exit 1
144+
fi
145+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
146+
125147
- name: test built packages
126148
shell: bash
127149
run: |-
@@ -171,6 +193,7 @@ jobs:
171193
env:
172194
REPOSITORY: "/tmp/activeloop-packages"
173195
SUPPORTED_VERSIONS: ${{ needs.setup.outputs.versions-list }}
196+
PACKAGE_VERSION: ${{ needs.extension-build.outputs.version }}
174197
runs-on: ubuntu-latest
175198
container: "quay.io/activeloopai/repo-builder:latest"
176199
steps:
@@ -218,14 +241,13 @@ jobs:
218241
mkdir -p "${REPOSITORY}"/scripts/pg-deeplake/ &&
219242
cp -f postgres/scripts/install.sh "${REPOSITORY}"/scripts/pg-deeplake/
220243
221-
# Extract version using pkg-config if VERSION is not set
222-
if [ -z "${VERSION}" ]; then
223-
echo -e "${YELLOW}VERSION not set, extracting from pkg-config...${DEFAULT}"
224-
PKG_VERSION=$(PKG_CONFIG_PATH="cpp/.ext/deeplake_api/lib/pkgconfig" pkg-config --modversion deeplake_api)
225-
VERSION="${PKG_VERSION}-1"
226-
echo -e "${GREEN}Detected version: ${VERSION}${DEFAULT}"
244+
# Use version from extension-build job output
245+
if [ -n "${PACKAGE_VERSION}" ]; then
246+
VERSION="${PACKAGE_VERSION}-1"
247+
echo -e "${GREEN}Using version from build job: ${VERSION}${DEFAULT}"
227248
else
228-
VERSION="${VERSION}-1"
249+
echo -e "${RED}Error: PACKAGE_VERSION not set${DEFAULT}"
250+
exit 1
229251
fi
230252
231253
for type in deb rpm; do
@@ -249,7 +271,7 @@ jobs:
249271
250272
build_container_images:
251273
name: Build Container Images
252-
needs: [setup, repo-build]
274+
needs: [setup, extension-build, repo-build]
253275
runs-on: ubuntu-latest
254276
strategy:
255277
fail-fast: false
@@ -284,19 +306,17 @@ jobs:
284306
shell: bash
285307
env:
286308
PG_VERSION: ${{ matrix.version }}
309+
PACKAGE_VERSION: ${{ needs.extension-build.outputs.version }}
287310
run: |-
288311
mkdir -p ./debs
289312
290-
# Extract version from tag or use default
291-
if [ -n "${{ inputs.version }}" ]; then
292-
VERSION="${{ inputs.version }}"
293-
elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
294-
# Extract version from tag (e.g., v4.4.4 -> 4.4.4)
295-
VERSION="${GITHUB_REF#refs/tags/v}"
296-
else
297-
# Default version if neither input nor tag is available
298-
VERSION="latest"
313+
# Use version from extension-build job output
314+
if [ -z "${PACKAGE_VERSION}" ]; then
315+
echo "Error: PACKAGE_VERSION not set"
316+
exit 1
299317
fi
318+
VERSION="${PACKAGE_VERSION}"
319+
echo "Using package version: ${VERSION}"
300320
301321
wget https://packages.activeloop.io/deb/pg-deeplake/pool/main/pg-deeplake-${PG_VERSION}_${VERSION}-1_amd64.deb -O ./debs/pg-deeplake-${PG_VERSION}_${VERSION}-1_amd64.deb
302322
wget https://packages.activeloop.io/deb/pg-deeplake/pool/main/pg-deeplake-${PG_VERSION}_${VERSION}-1_arm64.deb -O ./debs/pg-deeplake-${PG_VERSION}_${VERSION}-1_arm64.deb

0 commit comments

Comments
 (0)