-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (91 loc) · 3.55 KB
/
main.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: .NET CI/CD Workflow
on:
pull_request:
branches: [main]
push:
branches: [main]
release:
types: [published]
jobs:
prepare_versions:
runs-on: ubuntu-latest
outputs:
ReleaseVersion: ${{ steps.find.outputs.tag }}
PreviewAssemblyVersion: ${{ steps.set_version.outputs.preview_assembly_version }}
PreviewPackageVersion: ${{ steps.set_version.outputs.preview_package_version }}
steps:
- uses: actions/checkout@v2
- name: Find Latest Tag
id: find
uses: oprypin/[email protected]
with:
repository: ${{ github.repository }}
releases-only: true
- name: Set version output
id: set_version
run: |
echo "::set-output name=preview_assembly_version::${{ steps.find.outputs.tag }}.${{ github.run_number }}"
echo "::set-output name=preview_package_version::${{ steps.find.outputs.tag }}.${{ github.run_number }}-preview"
build_and_test:
needs: prepare_versions
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet --configuration Release build --configuration Release --no-restore /p:Version=${{ needs.prepare_versions.outputs.PreviewAssemblyVersion }}
- name: Test
run: dotnet --configuration Release test --no-build
build_pack_publish_preview:
needs: prepare_versions
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore /p:Version=${{ needs.prepare_versions.outputs.PreviewAssemblyVersion }}
- name: Test
run: dotnet test --configuration Release --no-build
- name: Pack
run: dotnet pack --configuration Release --no-build --output nupkgs /p:Version=${{ needs.prepare_versions.outputs.PreviewPackageVersion }}
- name: Publish NuGet
run: dotnet nuget push "nupkgs/*.nupkg" -k ${{ secrets.NugetKey }} -s https://api.nuget.org/v3/index.json --skip-duplicate
build_pack_publish_release:
needs: prepare_versions
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build (${{ needs.prepare_versions.outputs.ReleaseVersion }})
run: dotnet build --configuration Release --no-restore /p:Version=${{ needs.prepare_versions.outputs.ReleaseVersion }}
- name: Test
run: dotnet test --configuration Release --no-build
- name: Pack
run: dotnet pack --configuration Release --no-build --output nupkgs /p:Version=${{ needs.prepare_versions.outputs.ReleaseVersion }}
- name: Publish NuGet
run: dotnet nuget push "nupkgs/*.nupkg" -k ${{ secrets.NugetKey }} -s https://api.nuget.org/v3/index.json --skip-duplicate
- name: Upload Release Assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.find.outputs.tag }}
path: nupkgs