-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (110 loc) · 3.87 KB
/
Copy pathdotnet.yml
File metadata and controls
133 lines (110 loc) · 3.87 KB
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
name: .NET
on:
push:
branches: [ "main" ]
tags-ignore: v=*
pull_request:
branches: [ "main" ]
create:
tags: v=*
release:
types: [published]
tags: v=*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout latest
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Extract version base
id: extract_version_base
shell: pwsh
env:
## set-env is no longer considered safe:
## https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
## Need to run this once to get the dotnet init message out of the way
dotnet msbuild ./Versions.props /t:DumpVersions /nologo
$vdumpJson = & dotnet msbuild ./Versions.props /t:DumpVersions /nologo
Write-Output "Got Version Dump JSON:"
Write-Output $vdumpJson
$vdump = $vdumpJson | ConvertFrom-Json
Write-Output "Got Version Dump:"
Write-Output $vdump
## Export as output and ENV VARS for subsequent steps
$versionBase = "$($vdump.Major).$($vdump.Minor).$($vdump.Patch)"
Write-Host "Found matching Tag Version info:"
Write-Host "::set-output name=version_base::$versionBase"
Write-Host "::set-env name=VERSION_BASE::$versionBase"
- name: Compute build nums
uses: zyborg/gh-action-buildnum@v1
with:
gist_token: ${{ secrets.GIST_TOKEN }}
version_key: ${{ steps.extract_version_base.outputs.version_base }}
set_env: true
- name: Dump build nums
shell: pwsh
run: |
Write-Host "Computed build num: $($env:BUILDNUM_FOR_VERSION)"
- name: Restore dependencies
run: dotnet restore
- name: Build & pack
shell: pwsh
run: |
dotnet build --no-restore --configuration Release /p:VersionBuild=$env:BUILDNUM_FOR_VERSION
dotnet pack --no-restore --configuration Release /p:VersionBuild=$env:BUILDNUM_FOR_VERSION
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Upload package as artifact
if: startsWith(github.ref, 'refs/tags/v=')
uses: actions/upload-artifact@v1
with:
name: package
path: src/Zyborg.CommandLine.ModelBinder/bin/Release
push-nuget-preview:
needs: build
if: (github.event_name == 'create')
runs-on: ubuntu-latest
steps:
- name: download package from artifact
uses: actions/download-artifact@v1
with:
name: package
- name: setup nuget
uses: nuget/setup-nuget@v1
- name: register nuget repo
## As per:
## https://help.github.com/en/articles/configuring-nuget-for-use-with-github-package-registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
nuget sources Add -Name "GPR" \
-Source "https://nuget.pkg.github.com/ebekker/index.json" \
-UserName ebekker -Password $GITHUB_TOKEN
find . -name *.nupkg
nuget setapikey $GITHUB_TOKEN -Source "GPR"
- name: publish
run: nuget push package/Zyborg.CommandLine.ModelBinder*.nupkg -Source GPR
push-nuget-release:
needs: build
if: (github.event_name == 'release')
runs-on: ubuntu-latest
environment:
name: nuget.org
url: https://www.nuget.org/packages/Zyborg.CommandLine.ModelBinder/
steps:
- name: download package from artifact
uses: actions/download-artifact@v1
with:
name: package
- name: setup nuget
uses: nuget/setup-nuget@v1
- name: publish
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
run: nuget push package/Zyborg.CommandLine.ModelBinder*.nupkg -Source nuget.org -ApiKey $NUGET_TOKEN