-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (72 loc) · 2.47 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
name: "publish packages"
on:
push:
branches: [ master ]
paths:
- 'Source/**'
- '.github/workflows/publish.yml'
- '*.props'
workflow_dispatch:
jobs:
build:
name: build
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.create-cache-keys.outputs.cache-key }}
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.203
- name: Create cache keys
id: create-cache-keys
run: |
echo cache-key=${{ runner.os }}-${{ hashFiles('Source/**') }}-packages >> "$GITHUB_OUTPUT"
- name: cache packages
id: cache-packages
uses: actions/cache@v3
with:
path: .packages
key: ${{ steps.create-cache-keys.outputs.cache-key }}
restore-keys: ${{ steps.create-cache-keys.outputs.cache-key }}
- name: Cache nuget packages
uses: actions/cache@v3
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/*.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: restore
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
run: dotnet restore FluentSpreadsheets.sln
- name: build
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
run: dotnet build FluentSpreadsheets.sln -c Release --no-restore /p:PatchVersion=${{ github.run_number }}
- name: move packages
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
run: |
rm -rf .packages
mkdir .packages
mv Source/FluentSpreadsheets/bin/Release/*.nupkg .packages/
mv Source/FluentSpreadsheets.ClosedXML/bin/Release/*.nupkg .packages/
mv Source/FluentSpreadsheets.GoogleSheets/bin/Release/*.nupkg .packages/
publish:
name: publish
runs-on: ubuntu-latest
needs: build
environment: nuget.org
steps:
- name: load packages
uses: actions/cache@v3
with:
fail-on-cache-miss: true
path: .packages
key: ${{ needs.build.outputs.cache-key }}
- name: publish to GitHub nuget repository
run: |
for file in .packages/*.nupkg
do
dotnet nuget push "${file#/}" --source "nuget.org" --api-key ${{ secrets.NUGET_API_KEY }}
done