forked from npgsql/efcore.pg
-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (165 loc) · 7.59 KB
/
build.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
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
name: Build
on:
push:
branches:
- main
- 'hotfix/**'
- 'release/**'
tags:
- v*
pull_request:
env:
dotnet_sdk_version: '6.0.100-rc.1.21463.6'
postgis_version: 3
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Temporarily disable Windows because of PG installation issues
# os: [ ubuntu-20.04, windows-2019 ]
os: [ ubuntu-20.04 ]
pg_major: [ 13, 12, 11, 10 ]
config: [Release]
# PostgreSQL 14 is out, but there's no PostGIS binary for Windows yet (http://download.osgeo.org/postgis/windows/)
include:
- os: ubuntu-20.04
pg_major: 13
config: Debug
- os: ubuntu-20.04
pg_major: 14
config: Release
pg_prerelease: 'PG Prerelease'
outputs:
is_release: ${{ steps.analyze_tag.outputs.is_release }}
is_prerelease: ${{ steps.analyze_tag.outputs.is_prerelease }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnet_sdk_version }}
- name: Build
run: dotnet build --configuration Debug
shell: bash
- name: Start PostgreSQL ${{ matrix.pg_major }} (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
# First uninstall any PostgreSQL installed on the image
dpkg-query -W --showformat='${Package}\n' 'postgresql-*' | xargs sudo dpkg -P postgresql
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main 14" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update -qq
sudo apt-get install -qq postgresql-${{ matrix.pg_major }}
# To disable PostGIS for prereleases (because it usually isn't available until late), surround with the following:
if [ -z "${{ matrix.pg_prerelease }}" ]; then
sudo apt-get install -qq postgresql-${{ matrix.pg_major }}-postgis-${{ env.postgis_version }}
fi
sudo sed -i 's/max_connections = 100/max_connections = 200/g' /etc/postgresql/${{ matrix.pg_major }}/main/postgresql.conf
sudo systemctl restart postgresql
sudo -u postgres psql -c "CREATE USER npgsql_tests SUPERUSER PASSWORD 'npgsql_tests'"
- name: Start PostgreSQL ${{ matrix.pg_major }} (Windows)
if: startsWith(matrix.os, 'windows')
run: |
# Find EnterpriseDB version number
EDB_VERSION=$(\
curl -Ls 'http://sbp.enterprisedb.com/applications.xml' |
sed -n '\#<id>postgresql_${{ matrix.pg_major }}</id>#{n;p;n;p;}' |
sed -n '\#<platform>windows-x64</platform>#{n;p;}' |
sed -E 's#.*<version>([^<]+)</version>#\1#')
# Install PostgreSQL
echo "Installing PostgreSQL (version: ${EDB_VERSION})"
curl -o pgsql.zip -L https://get.enterprisedb.com/postgresql/postgresql-${EDB_VERSION}-windows-x64-binaries.zip
unzip pgsql.zip -x 'pgsql/include/**' 'pgsql/doc/**' 'pgsql/pgAdmin 4/**' 'pgsql/StackBuilder/**'
# Match Npgsql CI Docker image and stash one level up
cp {$GITHUB_WORKSPACE/.build,pgsql}/server.crt
cp {$GITHUB_WORKSPACE/.build,pgsql}/server.key
# Find OSGEO version number
OSGEO_VERSION=$(\
curl -Ls https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }} |
sed -n 's/.*>postgis-bundle-pg${{ matrix.pg_major }}-\(${{ env.postgis_version }}.[0-9]*.[0-9]*\)x64.zip<.*/\1/p')
# Install PostGIS
echo "Installing PostGIS (version: ${OSGEO_VERSION})"
POSTGIS_FILE="postgis-bundle-pg${{ matrix.pg_major }}-${OSGEO_VERSION}x64"
curl -o postgis.zip -L https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }}/${POSTGIS_FILE}.zip
unzip postgis.zip -d postgis
cp -a postgis/$POSTGIS_FILE/. pgsql/
# Start PostgreSQL
pgsql/bin/initdb -D pgsql/PGDATA -E UTF8 -U postgres
pgsql/bin/pg_ctl -D pgsql/PGDATA -l logfile -o '-c max_connections=200 -c max_prepared_transactions=10 -c ssl=true -c ssl_cert_file=../server.crt -c ssl_key_file=../server.key' start
# Configure test account
pgsql/bin/psql -U postgres -c "CREATE ROLE npgsql_tests SUPERUSER LOGIN PASSWORD 'npgsql_tests'"
pgsql/bin/psql -U postgres -c "CREATE DATABASE npgsql_tests OWNER npgsql_tests"
shell: bash
- name: Test
run: dotnet test -c ${{ matrix.config }} --logger "GitHubActions;report-warnings=false"
shell: bash
- id: analyze_tag
name: Analyze tag
shell: bash
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Release tag detected"
echo "::set-output name=is_release::true"
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+.*- ]]; then
echo "Prerelease tag detected"
echo "::set-output name=is_prerelease::true"
fi
fi
publish-ci:
needs: build
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.repository, 'npgsql/')
environment: myget
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnet_sdk_version }}
- name: Pack
run: dotnet pack --configuration Release --output nupkgs --version-suffix "ci.$(date -u +%Y%m%dT%H%M%S)+sha.${GITHUB_SHA:0:9}" -p:ContinuousIntegrationBuild=true
- name: Upload artifacts
uses: actions/[email protected]
with:
name: EFCore.PG.CI
path: nupkgs
- name: Publish packages to MyGet (vnext)
if: startsWith(github.ref, 'refs/heads/') && startsWith(github.ref, 'refs/heads/hotfix/') == false
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.MYGET_FEED_TOKEN }} --source https://www.myget.org/F/npgsql-unstable/api/v3/index.json
working-directory: nupkgs
- name: Publish packages to MyGet (patch)
if: startsWith(github.ref, 'refs/heads/hotfix/')
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.MYGET_FEED_TOKEN }} --source https://www.myget.org/F/npgsql/api/v3/index.json
working-directory: nupkgs
release:
needs: build
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.repository, 'npgsql/') && needs.build.outputs.is_release == 'true'
environment: nuget.org
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnet_sdk_version }}
- name: Pack
run: dotnet pack --configuration Release --output nupkgs -p:ContinuousIntegrationBuild=true
- name: Upload artifacts
uses: actions/[email protected]
with:
name: EFCore.PG.Release
path: nupkgs
- name: Create Github release
uses: ncipollo/[email protected]
with:
prerelease: ${{ needs.build.outputs.is_prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to nuget.org
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json
working-directory: nupkgs