-
Notifications
You must be signed in to change notification settings - Fork 25
135 lines (107 loc) · 3.75 KB
/
publish.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Publish NuGet
on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
push:
branches:
- 'main' # Run the workflow when pushing to the main branch
pull_request:
branches:
- '*' # Run the workflow for all pull requests
release:
types:
- published # Run the workflow when a new GitHub release is published
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace }}/nuget
defaults:
run:
shell: pwsh
jobs:
create_nuget:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/Jitter2
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Add MinVer and Reproducible Builds
run: |
dotnet add package MinVer
dotnet add package DotNet.ReproducibleBuilds
# Pack single-precision version
- name: Pack Single Precision
run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
# Pack double-precision version
- name: Pack Double Precision
run: dotnet pack --configuration Release -p:DoublePrecision=true --output ${{ env.NuGetDirectory }}
# Upload artifacts
- uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*
validate_nuget:
runs-on: ubuntu-latest
needs: [create_nuget]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Download NuGet Packages
uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Install NuGet Validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
- name: Validate NuGet Packages
run: |
foreach ($file in Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg) {
meziantou.validate-nuget-package $file
}
run_test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/Jitter2
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Run Tests - Single Precision
run: dotnet test --configuration Release
- name: Run Tests - Double Precision
run: dotnet test --configuration Release -p:DoublePrecision=true
deploy:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [validate_nuget, run_test]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Download NuGet Packages
uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Publish NuGet Packages
run: |
dotnet nuget add source --username notgiven688 --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/notgiven688/index.json"
foreach ($file in Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push $file --source "github" --skip-duplicate
}