forked from kasthack-labs/kasthack.binding.wf
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (79 loc) · 3.18 KB
/
build-and-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
87
88
89
90
91
92
93
94
95
96
name: Build and Deploy
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
defaults:
run:
working-directory: src
jobs:
build:
runs-on: windows-latest
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
strategy:
matrix:
configuration: [Debug, Release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8
- name: Install dotnet-script
run: dotnet tool install --global dotnet-script
shell: pwsh
- name: Update version in project
run: dotnet script "${{ github.workspace }}/UpdateVersion.csx"
env:
GITHUB_RUN_NUMBER: ${{ github.run_number }}
shell: pwsh
- name: Get version from project
id: get_version
run: |
$version_file = "${{ github.workspace }}/src/kasthack.binding.wf.csproj"
$current_version = (Get-Content $version_file | Select-String -Pattern '<Version>(.*?)</Version>').Matches.Groups[1].Value
if (-not $current_version) {
throw "Could not read version from: $version_file"
}
echo "Current version is: $current_version"
echo "PROJECT_VERSION=$current_version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Restore dependencies in project
run: dotnet restore
- name: Build project
run: dotnet build --configuration ${{ matrix.configuration }} --verbosity minimal
- name: Pack NuGet package [Debug]
if: matrix.configuration == 'Debug'
run: dotnet pack --configuration Debug --output "${{ github.workspace }}/src/nupkg"
- name: Pack NuGet package [Release]
if: matrix.configuration == 'Release'
run: dotnet pack --configuration Release --output "${{ github.workspace }}/src/nupkg"
- name: Upload the artifact [Debug]
if: matrix.configuration == 'Debug'
uses: actions/upload-artifact@v4
with:
name: debug.kasthack.binding.wf.${{ env.PROJECT_VERSION }}.nupkg
path: "${{ github.workspace }}/src/nupkg/kasthack.binding.wf.${{ env.PROJECT_VERSION }}.nupkg"
- name: Upload the artifact [Release]
if: matrix.configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: debug.kasthack.binding.wf.${{ env.PROJECT_VERSION }}.nupkg
path: ${{ github.workspace }}/src/nupkg/kasthack.binding.wf.${{ env.PROJECT_VERSION }}.nupkg"
# - name: Push NuGet package
# if: matrix.configuration == 'Release'
# run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Create GitHub Release
if: matrix.configuration == 'Release'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.PROJECT_VERSION }}
name: ${{ env.PROJECT_VERSION }}
files: ${{ github.workspace }}/src/nupkg/*.nupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}