-
Notifications
You must be signed in to change notification settings - Fork 19
51 lines (49 loc) · 1.53 KB
/
build-release.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
name: Build-Release
on:
push:
tags: v*
release:
types: [published]
jobs:
build:
runs-on: windows-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.100
- name: Build Version
# run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:11}) // deprecated
run: echo "RELEASE_VERSION=$($env:GITHUB_REF.SubString(11))" >> $env:GITHUB_ENV
- name: Build Project
run: dotnet build --configuration Release -p:Version=$env:RELEASE_VERSION
- name: Test Project
run: dotnet test --no-build --configuration Release --logger trx
- name: Pack Project
run: dotnet pack --no-build --output ./artifacts --configuration Release -p:Version=$env:RELEASE_VERSION
- uses: actions/upload-artifact@v4
with:
name: artifacts
path: ./artifacts
publish-nuget:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ build ]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_APIKEY }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.100
source-url: https://api.nuget.org/v3/index.json
- uses: actions/download-artifact@v4
with:
name: artifacts
path: ./artifacts
- name: Upload to NuGet
run: dotnet nuget push ./artifacts/**/*.nupkg --skip-duplicate -n -k $env:NUGET_AUTH_TOKEN