-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (80 loc) · 3.24 KB
/
deploy.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
name: Deploy
on:
release:
types: [created]
defaults:
run:
shell: pwsh
env:
baseVersion: 1.0.0
jobs:
build-and-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0
- name: Setup Dependency Caching
uses: actions/cache@v4
id: nuget-cache
with:
path: |
~/.nuget/packages
${{ github.workspace }}/**/obj/project.assets.json
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Set Version
run: |
echo "${{ github.ref }}"
if ("${{ github.ref }}".startsWith("refs/tags/v")) {
$tagVersion = "${{ github.ref }}".substring(11)
echo "buildVersion=$tagVersion.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "nugetVersion=$tagVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "preRelease=false" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "buildVersion=${{ env.baseVersion }}.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "nugetVersion=${{ env.baseVersion }}-ci${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
- name: Build
run: dotnet build -p:Version=${{ env.buildVersion }} -p:ContinuousIntegrationBuild=True --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
- name: Pack
if: startsWith(github.ref, 'refs/tags/v')
run: dotnet pack -p:PackageVersion=${{ env.nugetVersion }} --configuration Release -o ${{github.workspace}}\IntelliTect.ListingManagerPack --no-build
- name: Upload Artifacts
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: NuGet
path: ${{github.workspace}}/IntelliTect.ListingManagerPack
deploy:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: build-and-test
environment:
name: 'Production'
url: 'https://www.nuget.org/packages/IntelliTect.EssentialCSharp.ListingManager'
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: NuGet
- name: Push NuGet
run: |
$tagVersion = "${{ github.ref }}".substring(11)
echo "::set-output name=TAG_VERSION::$tagVersion"
dotnet nuget push IntelliTect.EssentialCSharp.ListingManager.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
id: tag-version
- name: Upload nupkg to Releases
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
generate_release_notes: true
files: IntelliTect.EssentialCSharp.ListingManager.${{ steps.tag-version.outputs.TAG_VERSION }}.nupkg