-
Notifications
You must be signed in to change notification settings - Fork 2
96 lines (94 loc) · 3.21 KB
/
build-test-pack-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
name: Build, then publish
on:
push:
branches:
- "*"
pull_request:
types:
- opened
- synchronize
- reopened
- closed
branches:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch unshallow
run: git fetch --prune --tags --unshallow
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
- name: Restore dependencies
run: dotnet restore
- name: Build projects
run: dotnet build --configuration Release --no-restore
- name: Test projects
run: dotnet test
- name: Pack projects
run: dotnet pack --no-restore
- name: Upload packages (artifacts)
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
src/**/*.nupkg
src/**/*.snupkg
publish:
if: |
(
github.ref == 'main'
&& github.event_name == 'pull_request'
&& github.event.pull_request.merged == true
) ||
(
(
(
github.ref == 'refs/heads/develop'
&& github.event_name == 'push'
) ||
(
github.ref == 'develop'
&& github.event_name == 'pull_request'
&& github.event.pull_request.merged == true
&& !startsWith(github.base_ref, 'release/')
)
) &&
(
contains(toJSON(github.event.commits.*.message), 'feat: ')
|| contains(toJSON(github.event.commits.*.message), 'fix: ')
|| contains(toJSON(github.event.commits.*.message), 'perf: ')
)
)
needs: build
runs-on: windows-latest
steps:
- name: Download package artifacts
id: download-artifacts
uses: actions/download-artifact@v4
continue-on-error: true
- name: Push nupkg's
id: push-nupkg
if: ${{ steps.download-artifacts.outcome == 'success' }}
run: echo "::set-output name=CONSOLE::$(dotnet nuget push '**/*.nupkg' --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate)"
continue-on-error: true
- name: Push nupkg's console output
if: steps.push-nupkg.outcome != 'skipped'
run: echo "${{steps.push-nupkg.outputs.CONSOLE}}"
- name: Push nupkg's suceeded
if: "${{ steps.push-nupkg.outcome == 'failure' && !contains(steps.push-nupkg.outputs.CONSOLE, 'error: File does not exist') }}"
run: exit 1
- name: Push snupkg's
id: push-snupkg
if: ${{ steps.download-artifacts.outcome == 'success' }}
run: echo "::set-output name=CONSOLE::$(dotnet nuget push '**/*.snupkg' --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate)"
continue-on-error: true
- name: Push snupkg's console output
if: steps.push-snupkg.outcome != 'skipped'
run: echo "${{steps.push-snupkg.outputs.CONSOLE}}"
- name: Push snupkg's suceeded
if: "${{ steps.push-snupkg.outcome == 'failure' && !contains(steps.push-snupkg.outputs.CONSOLE, 'error: File does not exist') }}"
run: exit 1