Skip to content

Commit b4b337f

Browse files
committed
Fix architecture-specific builds in GitHub workflows
- Modify release scripts to detect and use current architecture instead of looping through architectures - Update GitHub workflows to use matrix for Ubuntu versions (20.04, 22.04, 24.04) - Pass Ubuntu version from matrix to release scripts - Fix incorrect architecture builds by ensuring binaries are compiled on the proper architecture
1 parent 49babb6 commit b4b337f

File tree

4 files changed

+116
-71
lines changed

4 files changed

+116
-71
lines changed

.github/workflows/ubuntu-packages-and-docker-image.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
fail-fast: false # Let the other job finish
1515
matrix:
1616
os: ["buildjet-4vcpu-ubuntu-2204", "buildjet-8vcpu-ubuntu-2204-arm"]
17+
ubuntu_version: ["20.04", "22.04", "24.04"]
1718
runs-on: ${{ matrix.os }}
1819
steps:
1920
- uses: actions/checkout@v3
@@ -152,7 +153,7 @@ jobs:
152153
# Always build using latest scripts
153154
git checkout master
154155
155-
bash packages/postgresql-pgml/release.sh ${{ inputs.packageVersion }}
156+
bash packages/postgresql-pgml/release.sh ${{ inputs.packageVersion }} ${{ matrix.ubuntu_version }}
156157
157158
#
158159
# PostgresML meta package which installs
@@ -173,7 +174,7 @@ jobs:
173174
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
174175
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
175176
run: |
176-
bash packages/postgresml/release.sh ${{ inputs.packageVersion }}
177+
bash packages/postgresml/release.sh ${{ inputs.packageVersion }} ${{ matrix.ubuntu_version }}
177178
178179
#
179180
# PostgresML dashboard.
@@ -183,6 +184,7 @@ jobs:
183184
fail-fast: false # Let the other job finish
184185
matrix:
185186
os: ["ubuntu-22.04", "buildjet-4vcpu-ubuntu-2204-arm"]
187+
ubuntu_version: ["20.04", "22.04", "24.04"]
186188
runs-on: ${{ matrix.os }}
187189
steps:
188190
- uses: actions/checkout@v3
@@ -196,7 +198,7 @@ jobs:
196198
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
197199
run: |
198200
cargo install cargo-pgml-components
199-
bash packages/postgresml-dashboard/release.sh ${{ inputs.packageVersion }}
201+
bash packages/postgresml-dashboard/release.sh ${{ inputs.packageVersion }} ${{ matrix.ubuntu_version }}
200202
201203
#
202204
# PostgresML Docker image.

.github/workflows/ubuntu-postgresml-python-package.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ jobs:
1111
strategy:
1212
fail-fast: false # Let the other job finish
1313
matrix:
14-
os: ["buildjet-4vcpu-ubuntu-2204", "buildjet-4vcpu-ubuntu-2204-arm", "ubuntu-24.04"]
14+
os: ["buildjet-4vcpu-ubuntu-2204", "buildjet-4vcpu-ubuntu-2204-arm"]
15+
ubuntu_version: ["20.04", "22.04", "24.04"]
1516
runs-on: ${{ matrix.os }}
1617
steps:
1718
- uses: actions/checkout@v3
@@ -21,4 +22,4 @@ jobs:
2122
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2223
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
2324
run: |
24-
bash packages/postgresml-python/release.sh ${{ inputs.packageVersion }}
25+
bash packages/postgresml-python/release.sh ${{ inputs.packageVersion }} ${{ matrix.ubuntu_version }}

packages/postgresml-python/release.sh

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ set -e
33

44
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
55
package_version="$1"
6+
target_ubuntu_version="$2"
67

78
if [[ -z "$package_version" ]]; then
89
echo "postgresml-python package build and release script"
9-
echo "Usage: $0 <package version, e.g. 2.10.0>"
10+
echo "Usage: $0 <package version, e.g. 2.10.0> [ubuntu version, e.g. 22.04]"
1011
exit 1
1112
fi
1213

@@ -17,8 +18,17 @@ declare -A ubuntu_versions=(
1718
["24.04"]="noble"
1819
)
1920

20-
# Supported architectures
21-
declare -a architectures=("amd64" "arm64")
21+
# Detect current architecture
22+
if [[ $(arch) == "x86_64" ]]; then
23+
export ARCH=amd64
24+
elif [[ $(arch) == "aarch64" ]]; then
25+
export ARCH=arm64
26+
else
27+
echo "Unsupported architecture: $(arch)"
28+
exit 1
29+
fi
30+
31+
echo "Building for architecture: ${ARCH}"
2232

2333
# Install deb-s3 if not present
2434
if ! which deb-s3; then
@@ -36,32 +46,43 @@ function package_name() {
3646
echo "postgresml-python-${package_version}-ubuntu${ubuntu_version}-${arch}.deb"
3747
}
3848

39-
# Loop through Ubuntu versions
40-
for ubuntu_version in "${!ubuntu_versions[@]}"; do
41-
codename=${ubuntu_versions[$ubuntu_version]}
49+
build_package() {
50+
local ubuntu_version=$1
51+
local codename=$2
52+
4253
echo "Building packages for Ubuntu ${ubuntu_version} (${codename})"
4354

44-
# Loop through architectures
45-
for arch in "${architectures[@]}"; do
46-
echo "Building for architecture: ${arch}"
47-
export ARCH=${arch}
55+
# Build the Python package
56+
bash ${SCRIPT_DIR}/build.sh "$package_version" "$ubuntu_version"
4857

49-
# Build the Python package
50-
bash ${SCRIPT_DIR}/build.sh "$package_version" "$ubuntu_version"
58+
if [[ ! -f $(package_name ${ubuntu_version} ${ARCH}) ]]; then
59+
echo "File $(package_name ${ubuntu_version} ${ARCH}) doesn't exist"
60+
exit 1
61+
fi
5162

52-
if [[ ! -f $(package_name ${ubuntu_version} ${arch}) ]]; then
53-
echo "File $(package_name ${ubuntu_version} ${arch}) doesn't exist"
54-
exit 1
55-
fi
63+
# Upload to S3
64+
deb-s3 upload \
65+
--lock \
66+
--bucket apt.postgresml.org \
67+
$(package_name ${ubuntu_version} ${ARCH}) \
68+
--codename ${codename}
5669

57-
# Upload to S3
58-
deb-s3 upload \
59-
--lock \
60-
--bucket apt.postgresml.org \
61-
$(package_name ${ubuntu_version} ${arch}) \
62-
--codename ${codename}
70+
# Clean up the package file
71+
rm $(package_name ${ubuntu_version} ${ARCH})
72+
}
6373

64-
# Clean up the package file
65-
rm $(package_name ${ubuntu_version} ${arch})
74+
# If a specific Ubuntu version is provided, only build for that version
75+
if [[ ! -z "$target_ubuntu_version" ]]; then
76+
if [[ -z "${ubuntu_versions[$target_ubuntu_version]}" ]]; then
77+
echo "Error: Ubuntu version $target_ubuntu_version is not supported."
78+
echo "Supported versions: ${!ubuntu_versions[@]}"
79+
exit 1
80+
fi
81+
82+
build_package "$target_ubuntu_version" "${ubuntu_versions[$target_ubuntu_version]}"
83+
else
84+
# If no version specified, loop through all supported Ubuntu versions
85+
for ubuntu_version in "${!ubuntu_versions[@]}"; do
86+
build_package "$ubuntu_version" "${ubuntu_versions[$ubuntu_version]}"
6687
done
67-
done
88+
fi

packages/postgresql-pgml/release.sh

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ set -e
44
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
55

66
if [[ -z "${1}" ]]; then
7-
echo "Usage: $0 <package version, e.g. 2.10.0>"
7+
echo "Usage: $0 <package version, e.g. 2.10.0> [ubuntu version, e.g. 22.04]"
88
exit 1
99
fi
1010

1111
export PACKAGE_VERSION=${1}
12+
export TARGET_UBUNTU_VERSION=${2}
1213

1314
# Active LTS Ubuntu versions and their codenames
1415
declare -A ubuntu_versions=(
@@ -17,8 +18,17 @@ declare -A ubuntu_versions=(
1718
["24.04"]="noble"
1819
)
1920

20-
# Supported architectures
21-
declare -a architectures=("amd64" "arm64")
21+
# Detect current architecture
22+
if [[ $(arch) == "x86_64" ]]; then
23+
export ARCH=amd64
24+
elif [[ $(arch) == "aarch64" ]]; then
25+
export ARCH=arm64
26+
else
27+
echo "Unsupported architecture: $(arch)"
28+
exit 1
29+
fi
30+
31+
echo "Building for architecture: ${ARCH}"
2232

2333
# Install deb-s3 if not present
2434
if ! which deb-s3; then
@@ -36,44 +46,55 @@ function package_name() {
3646
echo "postgresql-pgml-${pg_version}_${PACKAGE_VERSION}-ubuntu${ubuntu_version}-${arch}.deb"
3747
}
3848

39-
# Loop through Ubuntu versions
40-
for ubuntu_version in "${!ubuntu_versions[@]}"; do
41-
codename=${ubuntu_versions[$ubuntu_version]}
49+
build_packages() {
50+
local ubuntu_version=$1
51+
local codename=$2
52+
4253
echo "Building packages for Ubuntu ${ubuntu_version} (${codename})"
4354

44-
# Loop through architectures
45-
for arch in "${architectures[@]}"; do
46-
echo "Building for architecture: ${arch}"
47-
export ARCH=${arch}
48-
49-
# Loop through PostgreSQL versions
50-
for pg in {11..17}; do
51-
echo "Building PostgreSQL ${pg} package..."
52-
53-
release_dir="$extension_dir/target/release/pgml-pg${pg}"
54-
mkdir -p "$release_dir/DEBIAN"
55-
56-
export PGVERSION=${pg}
57-
# Update control file with Ubuntu version
58-
(cat ${SCRIPT_DIR}/DEBIAN/control |
59-
envsubst '${PGVERSION} ${PACKAGE_VERSION} ${ARCH}') > "$release_dir/DEBIAN/control"
60-
61-
# Build the package
62-
dpkg-deb \
63-
--root-owner-group \
64-
-z1 \
65-
--build "$release_dir" \
66-
$(package_name ${pg} ${ubuntu_version} ${arch})
67-
68-
# Upload to S3
69-
deb-s3 upload \
70-
--lock \
71-
--bucket apt.postgresml.org \
72-
$(package_name ${pg} ${ubuntu_version} ${arch}) \
73-
--codename ${codename}
74-
75-
# Clean up the package file
76-
rm $(package_name ${pg} ${ubuntu_version} ${arch})
77-
done
55+
# Loop through PostgreSQL versions
56+
for pg in {11..17}; do
57+
echo "Building PostgreSQL ${pg} package..."
58+
59+
release_dir="$extension_dir/target/release/pgml-pg${pg}"
60+
mkdir -p "$release_dir/DEBIAN"
61+
62+
export PGVERSION=${pg}
63+
# Update control file with Ubuntu version
64+
(cat ${SCRIPT_DIR}/DEBIAN/control |
65+
envsubst '${PGVERSION} ${PACKAGE_VERSION} ${ARCH}') > "$release_dir/DEBIAN/control"
66+
67+
# Build the package
68+
dpkg-deb \
69+
--root-owner-group \
70+
-z1 \
71+
--build "$release_dir" \
72+
$(package_name ${pg} ${ubuntu_version} ${ARCH})
73+
74+
# Upload to S3
75+
deb-s3 upload \
76+
--lock \
77+
--bucket apt.postgresml.org \
78+
$(package_name ${pg} ${ubuntu_version} ${ARCH}) \
79+
--codename ${codename}
80+
81+
# Clean up the package file
82+
rm $(package_name ${pg} ${ubuntu_version} ${ARCH})
83+
done
84+
}
85+
86+
# If a specific Ubuntu version is provided, only build for that version
87+
if [[ ! -z "$TARGET_UBUNTU_VERSION" ]]; then
88+
if [[ -z "${ubuntu_versions[$TARGET_UBUNTU_VERSION]}" ]]; then
89+
echo "Error: Ubuntu version $TARGET_UBUNTU_VERSION is not supported."
90+
echo "Supported versions: ${!ubuntu_versions[@]}"
91+
exit 1
92+
fi
93+
94+
build_packages "$TARGET_UBUNTU_VERSION" "${ubuntu_versions[$TARGET_UBUNTU_VERSION]}"
95+
else
96+
# If no version specified, loop through all supported Ubuntu versions
97+
for ubuntu_version in "${!ubuntu_versions[@]}"; do
98+
build_packages "$ubuntu_version" "${ubuntu_versions[$ubuntu_version]}"
7899
done
79-
done
100+
fi

0 commit comments

Comments
 (0)