-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (217 loc) · 9.63 KB
/
Copy pathrelease.yml
File metadata and controls
249 lines (217 loc) · 9.63 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Release
run-name: psqlodbc2 Release - ${{ github.ref_name }}
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
# ---------------------------------------------------------------------------
# Unix builds (Linux + macOS): produce stripped shared objects in a tarball.
# ---------------------------------------------------------------------------
build-release:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: linux-x64
artifact_suffix: linux-x64
- os: macos-latest
name: macos-arm64
artifact_suffix: macos-arm64
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
steps:
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
meson ninja-build \
libpq-dev unixodbc-dev libodbcinst2
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install meson ninja libpq unixodbc
- name: Checkout
uses: actions/checkout@v4
# ref_name can be a tag (v1.2.3) or, for a workflow_dispatch dry run, a
# branch name that may contain a slash (e.g. ci/windows-msi-release). A
# slash in an artifact filename makes tar treat the leading segment as a
# directory and fail, so collapse any path separators to dashes.
- name: Compute package version
run: echo "PKG_VERSION=$(echo '${{ github.ref_name }}' | tr '/' '-')" >> "$GITHUB_ENV"
- name: Configure (release)
run: meson setup builddir --buildtype=release --strip
- name: Build
run: meson compile -C builddir
- name: Package
run: |
mkdir -p dist
cp builddir/src/libpsqlodbc2w* dist/ 2>/dev/null || true
cp LICENSE dist/
tar -czf psqlodbc2-${PKG_VERSION}-${{ matrix.artifact_suffix }}.tar.gz -C dist .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: psqlodbc2-${{ matrix.artifact_suffix }}
path: psqlodbc2-${{ env.PKG_VERSION }}-${{ matrix.artifact_suffix }}.tar.gz
retention-days: 5
# ---------------------------------------------------------------------------
# Windows builds (x64 + arm64): build the driver DLL with MSVC/Meson, bundle
# the libpq runtime DLLs beside it, and wrap everything in a WiX MSI that
# registers the driver with the Windows ODBC subsystem. This mirrors how
# upstream psqlodbc ships psqlodbc_x64.msi — an end user just runs the MSI and
# the driver appears in the ODBC Data Source Administrator.
# ---------------------------------------------------------------------------
build-windows:
strategy:
fail-fast: false
matrix:
include:
# arch = MSVC target passed to Meson / vcpkg triplet selector
# msvc_arch = argument to msvc-dev-cmd (amd64, or amd64_arm64 cross)
# vcpkg_triplet chooses the prebuilt libpq flavor to link against
- arch: x64
msvc_arch: amd64
vcpkg_triplet: x64-windows
cross_file: ""
- arch: arm64
msvc_arch: amd64_arm64
vcpkg_triplet: arm64-windows
cross_file: "--cross-file build-aux/windows-arm64.cross"
name: Build (windows-${{ matrix.arch }})
runs-on: windows-latest
# Route vcpkg's binary cache to a NuGet feed hosted on GitHub Packages. On a
# hit, `vcpkg install libpq` restores a prebuilt package in seconds instead
# of compiling libpq + OpenSSL/zlib/lz4 from source (~10-15 min). The vcpkg
# "x-gha" (Actions cache) provider was REMOVED in 2025, so NuGet is the
# supported GitHub-native option. The package id embeds vcpkg's ABI hash, so
# each triplet gets its own entry and a dependency/compiler change
# invalidates automatically — no manual key to maintain.
# Writing to GitHub Packages needs the packages:write permission (below).
permissions:
contents: read
packages: write
env:
VCPKG_BINARY_SOURCES: "clear;nuget,GitHubPackages,readwrite"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up MSVC (${{ matrix.msvc_arch }})
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc_arch }}
- name: Install Meson + Ninja
run: pip install meson ninja
# Register the GitHub Packages NuGet feed as a vcpkg binary source. vcpkg
# ships its own nuget.exe; we point it at this repo's owner feed and
# authenticate with the job's GITHUB_TOKEN.
- name: Configure vcpkg NuGet binary cache
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$nugetSource = "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
$nuget = & "$env:VCPKG_INSTALLATION_ROOT/vcpkg" fetch nuget | Select-Object -Last 1
& $nuget sources add -Source $nugetSource -Name GitHubPackages `
-Username '${{ github.repository_owner }}' -Password $env:GITHUB_TOKEN `
-StorePasswordInClearText
& $nuget setapikey $env:GITHUB_TOKEN -Source $nugetSource
# libpq is not on the runner by default. vcpkg builds a per-triplet libpq
# (with its OpenSSL/zlib/lz4 deps) matching the target architecture under
# installed/<triplet>/. Restored from the NuGet binary cache when available.
- name: Install libpq via vcpkg
shell: pwsh
run: |
vcpkg install libpq:${{ matrix.vcpkg_triplet }}
# Expose the install prefix for meson's -Dlibpq_prefix below.
$installed = "$env:VCPKG_INSTALLATION_ROOT/installed/${{ matrix.vcpkg_triplet }}"
echo "LIBPQ_PREFIX=$installed" >> $env:GITHUB_ENV
- name: Configure (release)
shell: pwsh
run: |
# Link libpq via find_library against the explicit vcpkg prefix rather
# than pkg-config: Meson's MSVC pkg-config backend drops vcpkg's
# "-llibpq" flag, so a pkg-config build compiles but fails to link with
# unresolved PQ* symbols. -Dlibpq_prefix takes the reliable path (see
# meson.build) and is arch-correct for both x64 and the arm64 cross.
meson setup builddir --buildtype=release `
"-Dlibpq_prefix=$env:LIBPQ_PREFIX" ${{ matrix.cross_file }}
- name: Build
run: meson compile -C builddir
# Gather the driver DLL plus every runtime DLL it needs (libpq + OpenSSL +
# zlib, etc.) into one staging dir. The MSI's <Files> wildcard packages
# whatever lands here, so the installed driver has all its dependencies
# sitting next to it — the ODBC loader resolves them from the same folder.
- name: Stage payload
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path stage | Out-Null
Copy-Item builddir/src/psqlodbc2w.dll stage/
# The DSN setup DLL (ConfigDSN et al.) is registered by the MSI via the
# <ODBCDriver SetupFile=...> element, so it must be present in the stage.
Copy-Item builddir/src/psqlodbc2setup.dll stage/
$vcpkgBin = "$env:VCPKG_INSTALLATION_ROOT/installed/${{ matrix.vcpkg_triplet }}/bin"
Copy-Item "$vcpkgBin/*.dll" stage/
# Pin WiX and its UI extension to the same concrete version. The extension
# reference must carry an exact version (or none) — a "/5.*" wildcard is
# rejected by `wix extension add` with "Invalid extension version".
- name: Install WiX toolset
run: dotnet tool install --global wix --version 5.0.2
- name: Add WiX UI extension
run: wix extension add -g WixToolset.UI.wixext/5.0.2
# MSI ProductVersion must be a 4-part numeric string (a.b.c.d). Tags look
# like "v1.2.3"; strip the leading v and append ".0". A manual
# workflow_dispatch run has no version tag, so fall back to 0.0.0.0.
- name: Compute MSI version
id: ver
shell: pwsh
run: |
$ref = "${{ github.ref_name }}"
if ($ref -match '^v(\d+)\.(\d+)\.(\d+)$') {
$v = "$($matches[1]).$($matches[2]).$($matches[3]).0"
} else {
# workflow_dispatch dry run (no version tag) — MSI needs a 4-part
# numeric ProductVersion, so use a placeholder.
$v = "0.0.0.0"
}
echo "msi_version=$v" >> $env:GITHUB_OUTPUT
# Filename version: sanitize slashes from branch refs (see Unix job).
echo "pkg_version=$($ref -replace '/','-')" >> $env:GITHUB_OUTPUT
- name: Build MSI
run: >
wix build installer/psqlodbc2.wxs
-arch ${{ matrix.arch }}
-d Version=${{ steps.ver.outputs.msi_version }}
-d BinSource=stage
-ext WixToolset.UI.wixext
-o psqlodbc2-${{ steps.ver.outputs.pkg_version }}-windows-${{ matrix.arch }}.msi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: psqlodbc2-windows-${{ matrix.arch }}
path: psqlodbc2-${{ steps.ver.outputs.pkg_version }}-windows-${{ matrix.arch }}.msi
retention-days: 5
# ---------------------------------------------------------------------------
# Publish: gather every platform's artifact and attach to the GitHub release.
# ---------------------------------------------------------------------------
create-release:
needs: [build-release, build-windows]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
makeLatest: true
draft: false
prerelease: false
artifacts: "artifacts/**/*.tar.gz,artifacts/**/*.msi"