Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.13.1'
python-version: '3.13.5'

- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.13.1'
python-version: '3.13.5'

- name: Check out code
uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
[![Github All Releases](https://img.shields.io/github/downloads/cybertec-postgresql/patroni-windows-packaging/total?style=flat-square)](https://github.com/cybertec-postgresql/patroni-windows-packaging/releases)

# patroni-windows-packaging

Automate installing and launching of Patroni under Windows

## Install

Download the archive from [Releases](https://github.com/cybertec-postgresql/patroni-windows-packaging/releases) page.
To install from zip, please, check the [Setup Guide](doc/setup.md).

## Authors

[Pavlo Golub](https://github.com/pashagolub) and [Julian Markwort](https://github.com/markwort)
135 changes: 130 additions & 5 deletions env.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,138 @@
$MD = "PES"
$VCREDIST_REF = "https://aka.ms/vs/17/release/vc_redist.x64.exe"
$ETCD_REF = "https://github.com/etcd-io/etcd/releases/download/v3.5.18/etcd-v3.5.18-windows-amd64.zip"
$PATRONI_REF = "https://github.com/patroni/patroni/archive/refs/tags/v4.0.5.zip"
$ETCD_REF = "https://github.com/etcd-io/etcd/releases/download/v3.5.21/etcd-v3.5.21-windows-amd64.zip"
$PATRONI_REF = "https://github.com/patroni/patroni/archive/refs/tags/v4.0.6.zip"
$MICRO_REF = "https://github.com/zyedidia/micro/releases/download/v2.0.14/micro-2.0.14-win64.zip"
$WINSW_REF = "https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW.NET461.exe"
$VIP_REF = "https://github.com/cybertec-postgresql/vip-manager/releases/download/v3.0.0/vip-manager_3.0.0_Windows_x86_64.zip"
$PGSQL_REF = "https://get.enterprisedb.com/postgresql/postgresql-15.12-1-windows-x64-binaries.zip"
$PYTHON_REF = "https://www.python.org/ftp/python/3.13.2/python-3.13.2-amd64.exe"
$VIP_REF = "https://github.com/cybertec-postgresql/vip-manager/releases/download/v4.0.0/vip-manager_4.0.0_Windows_x86_64.zip"
$PGSQL_REF = "https://get.enterprisedb.com/postgresql/postgresql-17.5-1-windows-x64-binaries.zip"
$PYTHON_REF = "https://www.python.org/ftp/python/3.13.5/python-3.13.5-amd64.exe"
# one should change python version in github action workflows when changed here

$SEVENZIP = "C:\Program Files\7-Zip\7z.exe"

function Extract-ZipFile {
param (
[string]$zipFilePath,
[string]$destinationPath
)
if (Test-Path $SEVENZIP) {
& $SEVENZIP x "$zipFilePath" -o"$destinationPath"
Start-Sleep -Seconds 5
}
else {
Expand-Archive -Path "$zipFilePath" -DestinationPath "$destinationPath"
}
Remove-Item -Force "$zipFilePath" -ErrorAction Ignore
}

function Compress-ToZipFile {
param (
[string]$sourcePath,
[string]$destinationPath
)
if (Test-Path $SEVENZIP) {
& $SEVENZIP a "$destinationPath" -y "$sourcePath"
}
else {
Compress-Archive -Path "$sourcePath" -DestinationPath "$destinationPath"
}
}

function Start-Bootstrapping {
Write-Host "`n--- Start bootstrapping ---" -ForegroundColor blue
& ./clean.ps1
New-Item -ItemType Directory -Path $MD
Copy-Item "src\*.bat" $MD
Copy-Item "src\*.ps1" $MD
Copy-Item "doc" "$MD\doc" -Recurse
Write-Host "`n--- End bootstrapping ---" -ForegroundColor green
}

function Get-VCRedist {
Write-Host "`n--- Download VCREDIST ---" -ForegroundColor blue
Invoke-WebRequest -Uri $VCREDIST_REF -OutFile "$MD\vc_redist.x64.exe"
Write-Host "`n--- VCREDIST downloaded ---" -ForegroundColor green
}

function Get-ETCD {
Write-Host "`n--- Download ETCD ---" -ForegroundColor blue
Invoke-WebRequest -Uri $ETCD_REF -OutFile "$env:TEMP\etcd.zip"
Extract-ZipFile "$env:TEMP\etcd.zip" "$MD"
Rename-Item "$MD\etcd-*" "etcd"
Copy-Item "src\etcd.yaml" "$MD\etcd"
Write-Host "`n--- ETCD downloaded ---" -ForegroundColor green
}

function Get-Micro {
Write-Host "`n--- Download MICRO ---" -ForegroundColor blue
Invoke-WebRequest -Uri $MICRO_REF -OutFile "$env:TEMP\micro.zip"
Extract-ZipFile "$env:TEMP\micro.zip" "$MD"
Rename-Item "$MD\micro-*" "micro"
Write-Host "`n--- MICRO downloaded ---" -ForegroundColor green
}

function Get-VIPManager {
Write-Host "`n--- Download VIP-MANAGER ---" -ForegroundColor blue
Invoke-WebRequest -Uri $VIP_REF -OutFile "$env:TEMP\vip.zip"
Extract-ZipFile "$env:TEMP\vip.zip" "$MD"
Rename-Item "$MD\vip-manager*" "vip-manager"
Remove-Item "$MD\vip-manager\*.yml" -ErrorAction Ignore
Copy-Item "src\vip.yaml" "$MD\vip-manager"
Write-Host "`n--- VIP-MANAGER downloaded ---" -ForegroundColor green
}

function Get-PostgreSQL {
Write-Host "`n--- Download POSTGRESQL ---" -ForegroundColor blue
# Example: prompt for credentials if not already set
if (-not $PGSQL_CREDENTIAL) {
$global:PGSQL_CREDENTIAL = Get-Credential -Message "Enter credentials for PostgreSQL download"
}
Invoke-WebRequest -Uri $PGSQL_REF -OutFile "$env:TEMP\pgsql.zip" -Credential $PGSQL_CREDENTIAL
Extract-ZipFile "$env:TEMP\pgsql.zip" "$MD"
Remove-Item -Recurse -Force "$MD\pgsql\pgAdmin 4", "$MD\pgsql\symbols" -ErrorAction Ignore
Write-Host "`n--- POSTGRESQL downloaded ---" -ForegroundColor green
}

function Get-Patroni {
Write-Host "`n--- Download PATRONI ---" -ForegroundColor blue
Invoke-WebRequest -Uri $PATRONI_REF -OutFile "$env:TEMP\patroni.zip"
Extract-ZipFile "$env:TEMP\patroni.zip" "$MD"
Rename-Item "$MD\patroni-*" "patroni"
Remove-Item "$MD\patroni\postgres?.yml" -ErrorAction Ignore
Copy-Item "src\patroni.yaml" "$MD\patroni"
Write-Host "`n--- PATRONI downloaded ---" -ForegroundColor green
}

function Update-PythonAndPIP {
Write-Host "`n--- Update Python and PIP installation ---" -ForegroundColor blue
& "./install-python.ps1"
Move-Item "python-install.exe" "$MD"
Write-Host "`n--- Python and PIP installation updated ---" -ForegroundColor green
}

function Get-PatroniPackages {
Write-Host "`n--- Download PATRONI packages ---" -ForegroundColor blue
Set-Location "$MD\patroni"
& $PIP download -r requirements.txt -d .patroni-packages
& $PIP download pip pip_install setuptools wheel cdiff psycopg psycopg-binary -d .patroni-packages
Set-Location -Path "..\.."
Write-Host "`n--- PATRONI packages downloaded ---" -ForegroundColor green
}

function Get-WinSW {
Write-Host "`n--- Download WINSW ---" -ForegroundColor blue
Invoke-WebRequest -Uri $WINSW_REF -OutFile "$MD\patroni\patroni_service.exe"
Copy-Item "src\patroni_service.xml" "$MD\patroni"
Copy-Item "$MD\patroni\patroni_service.exe" "$MD\etcd\etcd_service.exe" -Force
Copy-Item "src\etcd_service.xml" "$MD\etcd"
Copy-Item "$MD\patroni\patroni_service.exe" "$MD\vip-manager\vip_service.exe" -Force
Copy-Item "src\vip_service.xml" "$MD\vip-manager"
Write-Host "`n--- WINSW downloaded ---" -ForegroundColor green
}

function Export-Assets {
Write-Host "`n--- Prepare archive ---" -ForegroundColor blue
Compress-ToZipFile "$MD" "$MD.zip"
Write-Host "`n--- Archive compressed ---" -ForegroundColor green
}
4 changes: 2 additions & 2 deletions install-python.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ $PIP = "pip3.exe"

if (-Not $env:RUNNER_TOOL_CACHE) {
Write-Host "Running on a local machine builder" -ForegroundColor Yellow
$PYTHON = "$env:ProgramFiles\Python312\python.exe"
$PIP = "$env:ProgramFiles\Python312\Scripts\pip3.exe"
$PYTHON = "$env:ProgramFiles\Python313\python.exe"
$PIP = "$env:ProgramFiles\Python313\Scripts\pip3.exe"
}

Write-Host "Loading the Python installation..." -ForegroundColor Blue
Expand Down
120 changes: 0 additions & 120 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,126 +4,6 @@ $ErrorActionPreference = "Stop"
# Set the environment variables
. .\env.ps1

function Extract-ZipFile {
param (
[string]$zipFilePath,
[string]$destinationPath
)
if (Test-Path $SEVENZIP) {
& $SEVENZIP x "$zipFilePath" -o"$destinationPath"
Start-Sleep -Seconds 5
} else {
Expand-Archive -Path "$zipFilePath" -DestinationPath "$destinationPath"
}
Remove-Item -Force "$zipFilePath" -ErrorAction Ignore
}

function Compress-ToZipFile {
param (
[string]$sourcePath,
[string]$destinationPath
)
if (Test-Path $SEVENZIP) {
& $SEVENZIP a "$destinationPath" -y "$sourcePath"
} else {
Compress-Archive -Path "$sourcePath" -DestinationPath "$destinationPath"
}
}

function Start-Bootstrapping {
Write-Host "`n--- Start bootstrapping ---" -ForegroundColor blue
& ./clean.ps1
New-Item -ItemType Directory -Path $MD
Copy-Item "src\*.bat" $MD
Copy-Item "src\*.ps1" $MD
Copy-Item "doc" "$MD\doc" -Recurse
Write-Host "`n--- End bootstrapping ---" -ForegroundColor green
}

function Get-VCRedist {
Write-Host "`n--- Download VCREDIST ---" -ForegroundColor blue
Invoke-WebRequest -Uri $VCREDIST_REF -OutFile "$MD\vc_redist.x64.exe"
Write-Host "`n--- VCREDIST downloaded ---" -ForegroundColor green
}

function Get-ETCD {
Write-Host "`n--- Download ETCD ---" -ForegroundColor blue
Invoke-WebRequest -Uri $ETCD_REF -OutFile "$env:TEMP\etcd.zip"
Extract-ZipFile "$env:TEMP\etcd.zip" "$MD"
Rename-Item "$MD\etcd-*" "etcd"
Copy-Item "src\etcd.yaml" "$MD\etcd"
Write-Host "`n--- ETCD downloaded ---" -ForegroundColor green
}

function Get-Micro {
Write-Host "`n--- Download MICRO ---" -ForegroundColor blue
Invoke-WebRequest -Uri $MICRO_REF -OutFile "$env:TEMP\micro.zip"
Extract-ZipFile "$env:TEMP\micro.zip" "$MD"
Rename-Item "$MD\micro-*" "micro"
Write-Host "`n--- MICRO downloaded ---" -ForegroundColor green
}

function Get-VIPManager {
Write-Host "`n--- Download VIP-MANAGER ---" -ForegroundColor blue
Invoke-WebRequest -Uri $VIP_REF -OutFile "$env:TEMP\vip.zip"
Extract-ZipFile "$env:TEMP\vip.zip" "$MD"
Rename-Item "$MD\vip-manager*" "vip-manager"
Remove-Item "$MD\vip-manager\*.yml" -ErrorAction Ignore
Copy-Item "src\vip.yaml" "$MD\vip-manager"
Write-Host "`n--- VIP-MANAGER downloaded ---" -ForegroundColor green
}

function Get-PostgreSQL {
Write-Host "`n--- Download POSTGRESQL ---" -ForegroundColor blue
Invoke-WebRequest -Uri $PGSQL_REF -OutFile "$env:TEMP\pgsql.zip"
Extract-ZipFile "$env:TEMP\pgsql.zip" "$MD"
Remove-Item -Recurse -Force "$MD\pgsql\pgAdmin 4", "$MD\pgsql\symbols" -ErrorAction Ignore
Write-Host "`n--- POSTGRESQL downloaded ---" -ForegroundColor green
}

function Get-Patroni {
Write-Host "`n--- Download PATRONI ---" -ForegroundColor blue
Invoke-WebRequest -Uri $PATRONI_REF -OutFile "$env:TEMP\patroni.zip"
Extract-ZipFile "$env:TEMP\patroni.zip" "$MD"
Rename-Item "$MD\patroni-*" "patroni"
Remove-Item "$MD\patroni\postgres?.yml" -ErrorAction Ignore
Copy-Item "src\patroni.yaml" "$MD\patroni"
Write-Host "`n--- PATRONI downloaded ---" -ForegroundColor green
}

function Update-PythonAndPIP {
Write-Host "`n--- Update Python and PIP installation ---" -ForegroundColor blue
& "./install-python.ps1"
Move-Item "python-install.exe" "$MD"
Write-Host "`n--- Python and PIP installation updated ---" -ForegroundColor green
}

function Get-PatroniPackages {
Write-Host "`n--- Download PATRONI packages ---" -ForegroundColor blue
Set-Location "$MD\patroni"
& $PIP download -r requirements.txt -d .patroni-packages
& $PIP download pip pip_install setuptools wheel cdiff psycopg psycopg-binary -d .patroni-packages
Set-Location -Path "..\.."
Write-Host "`n--- PATRONI packages downloaded ---" -ForegroundColor green
}

function Get-WinSW {
Write-Host "`n--- Download WINSW ---" -ForegroundColor blue
Invoke-WebRequest -Uri $WINSW_REF -OutFile "$MD\patroni\patroni_service.exe"
Copy-Item "src\patroni_service.xml" "$MD\patroni"
Copy-Item "$MD\patroni\patroni_service.exe" "$MD\etcd\etcd_service.exe" -Force
Copy-Item "src\etcd_service.xml" "$MD\etcd"
Copy-Item "$MD\patroni\patroni_service.exe" "$MD\vip-manager\vip_service.exe" -Force
Copy-Item "src\vip_service.xml" "$MD\vip-manager"
Write-Host "`n--- WINSW downloaded ---" -ForegroundColor green
}

function Export-Assets {
Write-Host "`n--- Prepare archive ---" -ForegroundColor blue
Compress-ToZipFile "$MD" "$MD.zip"
Write-Host "`n--- Archive compressed ---" -ForegroundColor green
}

Start-Bootstrapping
Get-VCRedist
Get-ETCD
Expand Down