-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (151 loc) · 5.66 KB
/
Copy pathrelease-ci.yml
File metadata and controls
174 lines (151 loc) · 5.66 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
name: release-ci
on:
push:
branches:
- release/**
tags:
- 'v*'
# Cancel in-progress runs on the same branch when a new push arrives
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
name: Build, Pack & Publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "Pa55w0rd!"
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'Pa55w0rd!' -No -Q 'SELECT 1'"
--health-interval 10s
--health-timeout 5s
--health-retries 10
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: Pa55w0rd
POSTGRES_DB: postgres
ports:
- 5455:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history required by GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v3
with:
useConfigFile: true
- name: Set package version
id: pkg_version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "version=$(echo '${{ github.ref_name }}' | sed 's/^v//')" >> $GITHUB_OUTPUT
else
echo "version=${{ steps.gitversion.outputs.semVer }}" >> $GITHUB_OUTPUT
fi
- name: Print version
run: |
echo "SemVer : ${{ steps.gitversion.outputs.semVer }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "PreReleaseTag : ${{ steps.gitversion.outputs.preReleaseTag }}"
echo "Package version: ${{ steps.pkg_version.outputs.version }}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Restore
run: dotnet restore ActiveForge.sln
- name: Build
run: dotnet build ActiveForge.sln --configuration Release --no-restore
- name: Start MongoDB replica set
run: |
docker run -d --name mongo \
-p 27017:27017 \
mongo:7 --replSet rs0 --bind_ip_all
# Wait for mongod to accept connections
for i in $(seq 1 30); do
docker exec mongo mongosh --quiet --eval "db.adminCommand('ping')" \
&& break || sleep 2
done
# Initialise the single-node replica set
docker exec mongo mongosh --quiet --eval \
"rs.initiate({_id:'rs0',members:[{_id:0,host:'127.0.0.1:27017'}]})"
# Wait until the node becomes PRIMARY
for i in $(seq 1 20); do
STATUS=$(docker exec mongo mongosh --quiet --eval "rs.status().myState")
[ "$STATUS" = "1" ] && break || sleep 2
done
- name: Test
env:
SS_ADMIN_CONNSTR: "Server=localhost,1433;Database=master;User Id=sa;Password=Pa55w0rd!;TrustServerCertificate=True"
PG_ADMIN_CONNSTR: "Host=localhost;Port=5455;Database=postgres;Username=postgres;Password=Pa55w0rd"
run: dotnet test ActiveForge.sln --configuration Release --no-build --framework net8.0
- name: Pack — Core
run: |
dotnet pack src/ActiveForge/ActiveForge.csproj \
--configuration Release --no-build \
-p:PackageVersion=${{ steps.pkg_version.outputs.version }} \
--output ./artifacts
- name: Pack — SqlServer
run: |
dotnet pack src/ActiveForge.SqlServer/ActiveForge.SqlServer.csproj \
--configuration Release --no-build \
-p:PackageVersion=${{ steps.pkg_version.outputs.version }} \
--output ./artifacts
- name: Pack — PostgreSQL
run: |
dotnet pack src/ActiveForge.PostgreSQL/ActiveForge.PostgreSQL.csproj \
--configuration Release --no-build \
-p:PackageVersion=${{ steps.pkg_version.outputs.version }} \
--output ./artifacts
- name: Pack — SQLite
run: |
dotnet pack src/ActiveForge.SQLite/ActiveForge.SQLite.csproj \
--configuration Release --no-build \
-p:PackageVersion=${{ steps.pkg_version.outputs.version }} \
--output ./artifacts
- name: Pack — MongoDB
run: |
dotnet pack src/ActiveForge.MongoDB/ActiveForge.MongoDB.csproj \
--configuration Release --no-build \
-p:PackageVersion=${{ steps.pkg_version.outputs.version }} \
--output ./artifacts
- name: List artifacts
run: ls -la ./artifacts/
- name: Publish to GitHub Packages
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--api-key ${{ secrets.GITHUB_TOKEN }} \
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
--skip-duplicate
- name: Publish to NuGet.org
if: startsWith(github.ref, 'refs/tags/')
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate