1
0
mirror of synced 2025-04-18 07:24:20 +03:00

On the Ubuntu runner, uninstall the default PostgreSQL version before installing any other PostgreSQL version.

This commit is contained in:
Yogesh Mahajan 2025-03-10 15:39:41 +05:30 committed by GitHub
parent 074db05f7a
commit 708a570ba0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -32,6 +32,18 @@ jobs:
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- name: Uninstall PostgreSQL if already present
run: |
if [ -n "$(ls /etc/postgresql/*/*/postgresql.conf 2>/dev/null)" ]; then
# Extract the major version from pg_config
installed_pg_version=$( pg_config --version | cut -d ' ' -f 2 | cut -d '.' -f 1 )
echo "Installed PostgreSQL version: $installed_pg_version"
if [ $installed_pg_version != ${{ matrix.pgver }} ]; then
sudo pg_dropcluster $installed_pg_version main --stop
sudo apt-get -y remove "postgresql-${installed_pg_version}"
fi
fi
- name: Install platform dependencies
run: |
sudo apt update

View File

@ -34,6 +34,19 @@ jobs:
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- name: Uninstall PostgreSQL if already present on linux
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
if [ -n "$(ls /etc/postgresql/*/*/postgresql.conf 2>/dev/null)" ]; then
# Extract the major version from pg_config
installed_pg_version=$( pg_config --version | cut -d ' ' -f 2 | cut -d '.' -f 1 )
echo "Installed PostgreSQL version: $installed_pg_version"
if [ $installed_pg_version != ${{ matrix.pgver }} ]; then
sudo pg_dropcluster $installed_pg_version main --stop
sudo apt-get -y remove "postgresql-${installed_pg_version}"
fi
fi
- name: Install platform dependencies on Linux
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
@ -46,7 +59,7 @@ jobs:
brew install postgresql@${{ matrix.pgver }}
echo "/opt/homebrew/opt/postgresql@${{ matrix.pgver }}/bin" >> $GITHUB_PATH
- name: Uninstall PostgreSQL if already present
- name: Uninstall PostgreSQL if already present on windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
if exist "C:\Program Files\PostgreSQL\{{ matrix.pgver }}\uninstall-postgresql.exe" (