-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (62 loc) · 1.98 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
name: "publish packages"
on:
push:
branches: [ master ]
paths:
- '.github/workflows/publish.yml'
- 'templates/**'
- 'Itmo.Dev.Templates.csproj'
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('**') }}-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: restore
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
run: dotnet restore Itmo.Dev.Templates.sln
- name: build
if: ${{ steps.cache-packages.outputs.cache-hit != 'true' }}
run: dotnet build Itmo.Dev.Templates.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 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