-
-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (63 loc) · 1.86 KB
/
Copy pathdotnet.yml
File metadata and controls
71 lines (63 loc) · 1.86 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
name: .NET
on:
push:
branches: [ master ]
tags:
- '*.*.*'
pull_request:
branches: [ master ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Run Unit Tests
run: |
dotnet restore
dotnet build
dotnet test test/NosCore.Algorithm.Tests -v m
release:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Check Tag
id: check-tag
run: |
if [[ "$GITHUB_REF" =~ ^refs/tags/[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
echo "match=true" >> $GITHUB_OUTPUT
fi
- name: Pack and push to NuGet
if: steps.check-tag.outputs.match == 'true'
id: build_artifact
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
dotnet restore
dotnet build -c Release
dotnet pack -c Release -o /tmp/nupkgs -v m -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:PackageVersion=${TAG_NAME}
dotnet nuget push /tmp/nupkgs/NosCore.Algorithm.${TAG_NAME}.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}}
echo "ARTIFACT_PATH=/tmp/nupkgs/NosCore.Algorithm.${TAG_NAME}.nupkg" >> $GITHUB_OUTPUT
- name: Upload Release Asset
if: steps.check-tag.outputs.match == 'true'
uses: softprops/action-gh-release@v3
with:
files: ${{ steps.build_artifact.outputs.ARTIFACT_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}