-
-
Notifications
You must be signed in to change notification settings - Fork 209
146 lines (131 loc) · 3.78 KB
/
ci.yml
File metadata and controls
146 lines (131 loc) · 3.78 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
name: CI
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"
workflow_dispatch:
env:
TEST_DB_PASS: "Password12!"
PKG_VERSION: "0.0.0"
permissions:
id-token: write
contents: write
packages: write
jobs:
build:
name: Build, Test & Pack
runs-on: ubuntu-latest
services:
mysql:
image: mysql:9-oracle
env:
MYSQL_ROOT_PASSWORD: ${{ env.TEST_DB_PASS }}
ports:
- "3306:3306"
mssql:
image: mcr.microsoft.com/mssql/server:2025-latest
env:
ACCEPT_EULA: "Y"
SA_PASSWORD: ${{ env.TEST_DB_PASS }}
ports:
- "1433:1433"
oracle:
image: gvenzl/oracle-free:23-slim-faststart
env:
ORACLE_PASSWORD: ${{ env.TEST_DB_PASS }}
ports:
- "1521:1521"
postgres:
image: postgres:18-alpine
ports:
- "5432:5432"
env:
POSTGRES_PASSWORD: ${{ env.TEST_DB_PASS }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 100
fetch-tags: true
- name: Build
run: dotnet build -c Release
- name: Run tests
run: dotnet test --no-build -c Release
- name: Publish to Codecov
uses: codecov/codecov-action@v6
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Set Dev version
if: github.ref == 'refs/heads/main'
run: echo "PKG_VERSION=$(git describe --long --tags | sed 's/^v//;0,/-/s//./')" >> $GITHUB_ENV
- name: Set Release version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "PKG_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Pack NuGet artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
run: dotnet pack --no-build -c Release -p:PackageVersion="${{ env.PKG_VERSION }}" -o packages
- name: Upload artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v7
with:
name: packages
path: packages/*nupkg
github:
name: Deploy to GitHub
needs: [build]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: packages
- name: Push to GitHub
run: |
dotnet nuget push "*.nupkg" \
--skip-duplicate \
-k ${{ secrets.GITHUB_TOKEN }} \
-s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
release:
name: Create GitHub release
needs: [build]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: packages
path: packages
- name: Create GitHub Release
run: gh release create ${{ github.ref_name }} packages/*nupkg
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
nuget:
name: Deploy to NuGet
needs: [release]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: packages
- name: NuGet Login
uses: NuGet/login@v1
id: login
with:
user: ${{ github.repository_owner }}
- name: Push to NuGet
run: |
dotnet nuget push "*.nupkg" \
-k ${{ steps.login.outputs.NUGET_API_KEY }} \
-s https://api.nuget.org/v3/index.json