-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (65 loc) · 2.12 KB
/
build.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
name: Build
on:
workflow_dispatch:
push:
branches: #This workflow is only triggered when commits are pushed. Pushing tags won't trigger it.
- '**'
pull_request:
release:
types:
- published
env:
PACKAGE_NAME: OpenApiLINQPadDriver
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: 1
SLN: OpenApiLINQPadDriver.sln
CONFIGURATION: Release
RETENTION_DAYS: 1
NUGET_OUTPUT_DIRECTORY: ${{ github.workspace }}/nuget
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name : Restore Cache
id: cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore ${{ env.SLN }} --locked-mode
- name: ${{ env.SLN }} ${{ env.CONFIGURATION }} Build
run: dotnet build ${{ env.SLN }} --no-restore --configuration ${{ env.CONFIGURATION }} -p:GITHUB_ACTIONS=true
- name: Publish Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}
if-no-files-found: error
path: |
${{ env.PACKAGE_NAME }}/bin/${{ env.CONFIGURATION }}/${{ env.PACKAGE_NAME }}.*.*nupkg
retention-days: ${{ env.RETENTION_DAYS }}
deploy:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{ env.NUGET_OUTPUT_DIRECTORY }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Publish NuGet package
run: |
for packageFile in "${{ env.NUGET_OUTPUT_DIRECTORY }}"/"${{ env.PACKAGE_NAME }}"*.nupkg
do
if [ -f "$packageFile" ]; then
dotnet nuget push "$packageFile" --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
fi
done