-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (83 loc) · 2.89 KB
/
dotnet-publish.yml
File metadata and controls
98 lines (83 loc) · 2.89 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: publish
on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ '*' ]
release:
types: [ published ]
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace }}/nuget
defaults:
run:
shell: pwsh
jobs:
build_test_and_pack:
name: Build, Test, and Pack
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
10.x
9.x
- name: Restore Dependencies
run: dotnet restore TTSTextNormalization.sln
- name: Build Solution
run: dotnet build TTSTextNormalization.sln --configuration Release --no-restore
- name: Run Tests for .NET 10.0
run: dotnet test TTSTextNormalization.Tests/TTSTextNormalization.Tests.csproj --configuration Release --framework net10.0 --no-build --logger "trx;LogFileName=test-results-net10.trx"
- name: Run Tests for .NET 9.0
run: dotnet test TTSTextNormalization.Tests/TTSTextNormalization.Tests.csproj --configuration Release --framework net9.0 --no-build --logger "trx;LogFileName=test-results-net9.trx"
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: '**/*.trx'
retention-days: 7
- name: Pack Library
run: dotnet pack TTSTextNormalization/TTSTextNormalization.csproj --configuration Release --no-build --output ${{ env.NuGetDirectory }}
- name: Upload NuGet Packages Artifact
uses: actions/upload-artifact@v4
with:
name: nuget-packages
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
deploy:
name: Deploy Packages to NuGet.org
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
needs: [build_test_and_pack]
environment:
name: nuget.org
url: https://www.nuget.org/packages/Agash.TTSTextNormalization
permissions:
contents: read
steps:
- name: Download NuGet Packages Artifact
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ${{ env.NuGetDirectory }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x
- name: Publish NuGet Packages
env:
NUGET_API_KEY: ${{ secrets.NUGET_APIKEY }}
run: |
Get-ChildItem "${{ env.NuGetDirectory }}" -Filter *.nupkg | ForEach-Object {
Write-Host "Pushing $($_.FullName)..."
dotnet nuget push $_.FullName --api-key "$env:NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
}