-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (73 loc) · 2.36 KB
/
dotnet_deploy.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
89
90
name: 'Deploy'
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
configuration: Release
zip-name: artifact-nuget
release-draft: false
jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
sdk:
- version: 7.0.x
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.sdk.version }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c ${{ env.configuration }}
- name: Test
run: dotnet test --no-build --verbosity normal -c ${{ env.configuration }}
- name: Pack nugets
if: ${{ matrix.os == 'ubuntu-latest' }}
run: dotnet pack -c ${{ env.configuration }} --no-build
- name: Upload artifact
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.zip-name }}
path: |
./src/JsonRepairUtils/bin/${{ env.configuration }}/*.nupkg
./src/JsonRepairUtils/bin/${{ env.configuration }}/*.snupkg
release:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs: [build]
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.zip-name }}
- name: Variables
id: vars
shell: pwsh
run: |
$fileName = Split-Path -Path "*.nupkg" -LeafBase -Resolve
Write-Output "::set-output name=version::$($filename.Substring("JsonRepairUtils.".Length))"
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.vars.outputs.version }}
draft: ${{ env.release-draft }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.sdk.version }}
- name: Push nuget
if: ${{ env.release-draft == 'false' }}
run: dotnet nuget push *nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json