-
Notifications
You must be signed in to change notification settings - Fork 50
132 lines (104 loc) · 4.53 KB
/
build.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
name: Build, Publish, Tag
on:
push:
branches: [ "master", "release/**", "features/**" ]
pull_request:
branches: [ "master", "develop" ]
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
env:
Solution_Name: PrimS.Telnet.sln
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
- name: Install nuget
run: Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile Nuget.exe
- name: Nuget restore
run: Nuget.exe restore
- name: Build Debug
run: msbuild $env:Solution_Name /p:Configuration=Debug /p:Platform="Any CPU"
- name: Telnet.CiTests
uses: rusty-bender/vstest-action@main
with:
testAssembly: PrimS.Telnet.CiTests.dll
searchFolder: ./**/bin/Debug/**/
runInParallel: true
- name: Remove File
uses: JesseTG/[email protected]
if: startsWith(github.ref, 'refs/heads/release/')
with:
path: ../../_actions/rusty-bender/vstest-action/main/dist
# Can't apparently run both full fat and core test suites together.'
- name: Telnet.*.CiTests
uses: rusty-bender/vstest-action@main
with:
testAssembly: PrimS.Telnet.*.CiTests.dll
searchFolder: ./**/bin/Debug/**/
runInParallel: true
- name: GitVersion
run: dotnet tool install --global GitVersion.Tool
- name: Run GitVersion
run: |
dotnet-gitversion /showConfig
$str = dotnet-gitversion /updateprojectfiles | out-string
$json = ConvertFrom-Json $str
$json
$semVer = $json.SemVer
$fullSemVer = $json.FullSemVer
$nuGetVersionV2 = $json.MajorMinorPatch
$buildMetaDataPadded = "$($json.MajorMinorPatch)$($json.PreReleaseTagWithDash)$($json.WeightedPreReleaseNumber)"
Write-Host $json
Write-Host "semVer:" $semVer
Write-Host "fullSemVer:" $fullSemVer
Write-Host "nuGetVersionV2:" $nuGetVersionV2
Write-Host "Pre buildMetaDataPadded:" $buildMetaDataPadded
if (${buildMetaDataPadded} = "0000") {
${buildMetaDataPadded} = ''
}
Write-Host "Post buildMetaDataPadded:" $buildMetaDataPadded
Write-Host "NuGetVersionV2ext:${nuGetVersionV2}${buildMetaDataPadded}"
echo "FullSemVer=$fullSemVer" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "SemVer=$semVer" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "NuGetVersionV2=$nuGetVersionV2" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "NuGetVersionV2ext=${nuGetVersionV2}${buildMetaDataPadded}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Build Release
run: msbuild $env:Solution_Name /p:Configuration=Release /p:Platform="Any CPU"
- name: Nuget pack
run: nuget pack Telnet.nuspec -Version $Env:SemVer
# Navigate to https://github.com/settings/tokens and check to see if the old token has expired
# https://github.com/settings/tokens to create a new classic token, permission write:packages, name & copy paste to PUBLISH_TO_GITHUB_PACKAGES
# Navigate to repo->Settings->Secrets and variables->Actions and check PUBLISH_TO_GITHUB_PACKAGES
- name: Publish to GitHub
run: dotnet nuget push "Telnet.$Env:SemVer.nupkg" --api-key ${{ secrets.PUBLISH_TO_GITHUB_PACKAGES }} --source "https://nuget.pkg.github.com/9swampy/index.json"
- name: Nuget pack
if: github.ref == 'refs/heads/master'
run: nuget pack Telnet.nuspec -Version $Env:NuGetVersionV2
# Login to Nuget 9swampy->Api Keys and regenerate, copy to...
# GitHub navigate to repo->Settings->Secrets and variables->Actions and set NUGET_APIKEY
- name: Publish to Nuget
if: github.ref == 'refs/heads/master'
run: nuget push "Telnet.$Env:NuGetVersionV2.nupkg" ${{ secrets.NUGET_APIKEY }} -source https://api.nuget.org/v3/index.json
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: published-nuget-package
path: Telnet.*.nupkg
- name: Setup Git User
uses: fregante/[email protected]
- name: Git tag
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')
run: |
git tag v$Env:FullSemVer
git push origin v$Env:FullSemVer