-
Notifications
You must be signed in to change notification settings - Fork 7
166 lines (141 loc) · 6.6 KB
/
dotnet.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Build & Test
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
defaults:
run:
working-directory: ./src
shell: pwsh
outputs:
semver: ${{ steps.gitversion.outputs.semver }}
win-x64-fileName: ${{ steps.packageBuildResults.outputs.win-x64-fileName }}
nupkg-binary-fileName: ${{ steps.createNupkg.outputs.nupkg-binary-fileName }}
nupkg-client-fileName: ${{ steps.createNupkg.outputs.nupkg-client-fileName }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Restore Packages
# if: steps.cache.outputs.cache-hit != 'true'
run: dotnet restore _ALL.sln --use-lock-file
- name: Build
run: msbuild -m -t:Rebuild -p:Configuration=Release -bl:opc-ua-pubsub-dotnet.binlog -noconlog _All.sln
- name: Archive Build Log
uses: actions/upload-artifact@v4
if: ${{ success() || failure() }}
with:
name: log-win-x64-release
path: |
src/*.binlog
- name: Store SemVer
id: gitversion
run: |
echo "semver=$($env:GitVersion_SemVer)" >> $Env:GITHUB_OUTPUT
- name: Create zip
id: packageBuildResults
run: |
$sourceFolder = Join-Path $env:GITHUB_WORKSPACE "src" | Join-Path -ChildPath "_Out" | Join-Path -ChildPath "Release" | Join-Path -ChildPath "*"
$outFolder = Join-Path $env:GITHUB_WORKSPACE "src" | Join-Path -ChildPath "_Out" | Join-Path -ChildPath "GitHub"
New-Item -ItemType Directory -Force -Path $outFolder
$fileName = "win-x64-$($env:GitVersion_SemVer).zip"
Write-Host "Filename: '$fileName'"
echo "win-x64-fileName=$($fileName)" >> $Env:GITHUB_OUTPUT
$outPath = Join-Path $outFolder $fileName
Compress-Archive -DestinationPath $outPath -Path $sourceFolder -CompressionLevel Optimal
- name: Archive Build Result
uses: actions/upload-artifact@v4
with:
name: win-x64-release
path: |
src/_Out/GitHub
- name: Create Nuget Packages
id: createNupkg
run: |
$packageOutFolder = Join-Path $env:GITHUB_WORKSPACE "src" | Join-Path -ChildPath "_Out" | Join-Path -ChildPath "NuGet"
dotnet pack _ALL.sln --no-build --configuration Release --output $packageOutFolder
Write-Host "Save filenames of created NuGet packages..."
$packages = gci -Path $packageOutFolder -File -Filter "*.nupkg" | select -ExpandProperty Name
$binary = $packages | where {$_ -match "binary"}
Write-Host "Binary NuGet Package: '$binary'"
echo "nupkg-binary-fileName=$($binary)" >> $Env:GITHUB_OUTPUT
$client = $packages | where {$_ -match "client"}
Write-Host "Client NuGet Package: '$client'"
echo "nupkg-client-fileName=$($client)" >> $Env:GITHUB_OUTPUT
- name: Archive NuGet Packages
uses: actions/upload-artifact@v4
with:
name: nuget-win-x64-release
path: |
src/_Out/NuGet
- name: Test
run: |
dotnet test --no-build --configuration Release
release:
if: github.ref == 'refs/heads/main'
runs-on: windows-latest
needs: build
defaults:
run:
shell: pwsh
steps:
- name: Download Build Results
uses: actions/download-artifact@v2
with:
name: win-x64-release
- name: Download NuGet Packages
uses: actions/download-artifact@v2
with:
name: nuget-win-x64-release
- name: Debug
run: |
tree
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ needs.build.outputs.semver }}
release_name: Release ${{ needs.build.outputs.semver }}
body: |
${{ github.event.head_commit.message }}
draft: true
prerelease: false
- name: Upload Zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ needs.build.outputs.win-x64-fileName }}
asset_name: ${{ needs.build.outputs.win-x64-fileName }}
asset_content_type: application/zip
- name: Upload Binary Nupkg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ needs.build.outputs.nupkg-binary-fileName }}
asset_name: ${{ needs.build.outputs.nupkg-binary-fileName }}
asset_content_type: application/zip
- name: Upload Client Nupkg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ needs.build.outputs.nupkg-client-fileName }}
asset_name: ${{ needs.build.outputs.nupkg-client-fileName }}
asset_content_type: application/zip