-
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (79 loc) · 2.38 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
87
88
name: CI
on:
push:
branches:
- "main"
tags:
- "v*"
jobs:
build:
name: CI Build
uses: ./.github/workflows/build.yml
secrets: inherit
pack:
name: Create NuGet packages
needs: [build]
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Dev version
if: github.ref == 'refs/heads/main'
run: |
version="$(git describe --long --tags | sed 's/^v//;0,/-/s//./')"
if [ -z "${version}" ]; then
version="0.0.0.$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)"
fi
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Set Release version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Pack artifacts
run: dotnet pack -p:PackageVersion="${{ env.VERSION }}" -o packages
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: packages/*nupkg
github:
name: Deploy to GitHub
needs: [pack]
runs-on: ubuntu-24.04
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: packages
- name: Push to pkg.github.com
run: dotnet nuget push "*.nupkg" -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -k ${{ secrets.GH_FULL_PAT }} --skip-duplicate
release:
name: Create GitHub release
needs: [pack]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
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-24.04
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: packages
- name: Push to nuget.org
run: dotnet nuget push "*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_DEPLOY_KEY }}