-
-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (73 loc) · 2.39 KB
/
ci.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
name: CI
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"
workflow_dispatch:
jobs:
build-windows:
name: Build & Test (Windows)
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run tests
run: dotnet test -c Release -p:CollectCoverage=false
build-linux:
name: Build, Test & Pack (Linux)
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build
run: dotnet build -c Release -p:ContinuousIntegrationBuild=true
- name: Run tests
run: dotnet test --no-build -c Release
- name: Publish to Codecov
uses: codecov/codecov-action@v3
- name: Set Dev version
if: github.ref == 'refs/heads/main'
run: echo "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 "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.VERSION }}"
- name: Upload artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: src/**/*nupkg
github:
name: Deploy to GitHub
needs: [build-windows, build-linux]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: nupkgs
- name: Push to GitHub
run: dotnet nuget push "**/*.nupkg" -s https://nuget.pkg.github.com/phnx47/index.json -k ${{ secrets.GH_PKG_PAT }} --skip-duplicate
nuget:
name: Deploy to NuGet
needs: [build-windows, build-linux]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: nupkgs
- name: Push to NuGet
run: dotnet nuget push "**/*.nupkg" -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json