-
Notifications
You must be signed in to change notification settings - Fork 47
135 lines (112 loc) · 4.99 KB
/
build-win.yml
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
name: Build and Run Windows Tests
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
pg-version:
- 9.3.25-1
- 9.4.26-1
- 9.5.25-1
- 9.6.24-1
- 10.23-1
- 11.21-1
- 12.16-1
- 13.12-1
- 14.9-1
- 15.4-1
- 16.0-1
platform:
- x64
include:
- pg-version: 9.3.25-1
platform: x86
- pg-version: 9.4.26-1
platform: x86
- pg-version: 9.5.25-1
platform: x86
- pg-version: 9.6.24-1
platform: x86
- pg-version: 10.23-1
platform: x86
steps:
- name: Install PostgreSQL
run: |
$ErrorActionPreference = "Stop"
$pg_full_version = "${{ matrix.pg-version }}"
$pg_version = $pg_full_version.Substring(0, $pg_full_version.lastIndexOf('.'))
if ("${{ matrix.platform }}" -eq "x64") {
$x64 = "-x64"
$pg_root = "C:\Program Files\PostgreSQL\$pg_version"
$release_dir = "x64\Release"
} else {
$pg_root = "C:\Program Files (x86)\PostgreSQL\$pg_version"
$release_dir = "Release"
}
if (("$pg_version" -eq "9.3") -or ("$pg_version" -eq "9.4")) {
$psql_opt = "--psqldir"
} else {
$psql_opt = "--bindir"
}
if ("$pg_version" -eq "14") {
& "C:\Program Files\PostgreSQL\14\uninstall-postgresql.exe" --mode unattended 2>&1 | Out-Default
Remove-Item -Recurse -Force "C:\Program Files\PostgreSQL\14"
}
"PG_VERSION=$pg_version" >> $env:GITHUB_ENV
"PG_ROOT=$pg_root" >> $env:GITHUB_ENV
"X64=$x64" >> $env:GITHUB_ENV
"RELEASE_DIR=$release_dir" >> $env:GITHUB_ENV
"PSQL_OPT=$psql_opt" >> $env:GITHUB_ENV
Invoke-webrequest -uri https://get.enterprisedb.com/postgresql/postgresql-${pg_full_version}-windows${x64}.exe -OutFile postgresql.exe
if ("$pg_version" -eq "9.6") {
& ".\postgresql.exe" --unattendedmodeui none --mode unattended --superpassword password --servicepassword password --install_runtimes 0 2>&1 | Out-Default
} else {
& ".\postgresql.exe" --unattendedmodeui none --mode unattended --superpassword password --servicepassword password 2>&1 | Out-Default
}
- uses: actions/checkout@v3
- uses: microsoft/[email protected]
- name: Build app for release
run: |
msbuild temporal_tables.vcxproj -t:rebuild -verbosity:minimal -property:Configuration=Release -property:Platform=${{ matrix.platform }} -property:PlatformToolset=v143
env:
pgversion: ${{ matrix.pg-version }}
pgroot: ${{ env.PG_ROOT }}
- name: Run Tests
run: |
$ErrorActionPreference = "Stop"
Stop-Service -Name "postgresql$env:X64-$env:PG_VERSION"
Copy ".\$env:RELEASE_DIR\temporal_tables.dll" "$env:PG_ROOT\lib"
Copy ".\*.sql" "$env:PG_ROOT\share\extension"
Copy ".\*.control" "$env:PG_ROOT\share\extension"
Set-Content -path pg.pass -value $env:PGPASSWORD -encoding ascii
& "$env:PG_ROOT\bin\initdb.exe" -A md5 -U postgres --pwfile=pg.pass C:\pgdata 2>&1 | Out-Default
& "$env:PG_ROOT\bin\pg_ctl.exe" register -S demand -N "postgresql$env:X64-$env:PG_VERSION" -D c:\pgdata 2>&1 | Out-Default
Start-Service -Name "postgresql$env:X64-$env:PG_VERSION"
& "$env:PG_ROOT\bin\pg_regress.exe" "$env:PSQL_OPT=$env:PG_ROOT\bin" --dbname=pl_regression install no_system_period invalid_system_period no_history_table no_history_system_period invalid_types invalid_system_period_values versioning versioning_custom_system_time structure uninstall 2>&1 | Out-Default
if ($LASTEXITCODE -ne 0) {
Get-Content -Path ".\regression.diffs" | Out-Printer
Write-Error "Tests failed"
}
env:
PGUSER: postgres
PGPASSWORD: password
- name: Package Artifacts
if: startsWith(github.ref, 'refs/tags/')
run: |
$ErrorActionPreference = "Stop"
New-Item -ItemType Directory -Force -Path .\package\lib
New-Item -ItemType Directory -Force -Path .\package\share\extension
Copy ".\LICENSE" ".\package\TEMPORAL_TABLES_LICENSE"
Copy ".\$env:RELEASE_DIR\temporal_tables.dll" ".\package\lib"
Copy ".\*.sql" ".\package\share\extension"
Copy ".\*.control" ".\package\share\extension"
Compress-Archive -Path ".\package\*" -DestinationPath temporal_tables-pg${{ env.PG_VERSION }}-${{ matrix.platform }}.zip
- name: Deploy Artifacts
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
fail_on_unmatched_files: true
files: |
temporal_tables-pg${{ env.PG_VERSION }}-${{ matrix.platform }}.zip