-
Notifications
You must be signed in to change notification settings - Fork 17
149 lines (131 loc) · 5.13 KB
/
workflow.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
name: CI CollectSFData
env:
project_name: CollectSFData
project_root: ${{ github.workspace }}\\src
artifacts_path: ${{ github.workspace }}\\src\\bin\\artifacts
release_path: ${{ github.workspace }}\\src\\bin\\Release
release_config: ${{ github.workspace }}\\configurationFiles\\collectsfdata.options.json
github_owner: ${{ github.event.repository.owner.name }}
on:
pull_request_target:
types: [closed, opened]
paths-ignore:
- "docs/**"
- "configurationFiles/**"
- "kusto/**"
branches:
- master
- main
jobs:
build:
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v1
- name: environment
shell: cmd
run: |
set
dotnet --info
dotnet nuget locals all --clear
- name: dotnet restore
shell: powershell
run: |
# delete ado internal nuget config for external build
$adoInternalNugetConfig = ".\Nuget.Config"
if(Test-Path $adoInternalNugetConfig) {
write-host "deleting ado internal nuget config: $adoInternalNugetConfig"
del $adoInternalNugetConfig
}
write-host "dotnet restore $env:project_root\$env:project_name\$env:project_name.csproj -v detailed"
dotnet restore $env:project_root\$env:project_name\$env:project_name.csproj -v detailed
- name: dotnet build / pack
shell: cmd
run: |
set
dotnet build %project_root%\%project_name%\%project_name%.csproj -v detailed -c Release
dir
- name: build output
shell: cmd
run: |
set
dir /s
- name: copy artifacts
shell: powershell
run: |
[environment]::GetEnvironmentVariables()
write-host "copy "$($env:release_path)" "$($env:artifacts_path)" -recurse -force"
copy "$($env:release_path)" "$($env:artifacts_path)" -recurse -force
write-host "copy "$($env:release_config)" "$($env:artifacts_path)" -recurse -force"
copy "$($env:release_config)" "$($env:artifacts_path)" -recurse -force
dir "$($env:artifacts_path)" -recurse
- name: artifacts output
shell: powershell
run: dir "$($env:artifacts_path)" -recurse
- name: upload artifacts
uses: actions/upload-artifact@v1
with:
name: Release
path: ${{ env.artifacts_path }}
release:
if: success() && github.event.pull_request.merged == true && github.event.action == 'closed' && (contains(github.event.pull_request.labels.*.name, 'Release') || contains(github.event.pull_request.labels.*.name, 'Pre-release'))
needs: build
runs-on: windows-latest
permissions:
contents: write
packages: write
steps:
- name: checkout
uses: actions/checkout@v1
- name: environment
shell: cmd
run: set
- name: download artifact
uses: actions/download-artifact@v1
with:
name: Release
path: ${{ env.release_path }}
- name: release output
shell: powershell
run: dir "$($env:release_path)" -recurse
- name: set nuget package
shell: powershell
id: set_nuget_package
run: |
$nugetPackage = (get-item "$($env:release_path)\*.nupkg").FullName
$nugetPackageName = (get-item "$($env:release_path)\*.nupkg").Name
echo "nuget_package=$nugetPackage" >> $env:GITHUB_OUTPUT
echo "nuget_package_name=$nugetPackageName" >> $env:GITHUB_OUTPUT
write-host "nuget_package=$nugetPackage"
write-host "nuget_package_name=$nugetPackageName"
- name: prepare release asset
shell: powershell
id: prepare_release_asset
run: |
$source = "$($env:release_path)\\*"
$destination = "$($env:release_path)\\$($env:project_name).zip"
write-host "compress-archive -path $source -destinationPath $destination -force"
compress-archive -path $source -destinationPath $destination -force
$exeFileRef = @(get-childItem -recurse "$($env:release_path)\$($env:project_name).exe")[0].FullName
$fileVersion = [io.fileinfo]::new($exeFileRef).VersionInfo.FileVersion
write-host "fileVersion=$fileVersion"
echo "::log-command parameter1=$fileVersion::fileVersion"
echo "file_version=v$fileVersion" >> $env:GITHUB_OUTPUT
write-host "dir $env:release_path -recurse"
dir $env:release_path -recurse
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/marketplace/actions/gh-release
- name: create release
id: create_release
uses: softprops/action-gh-release@v2
with:
files: |
**/${{ env.project_name }}.zip
**/*${{ env.project_name }}*.nupkg
tag_name: ${{ steps.prepare_release_asset.outputs.file_version }}
name: ${{ env.project_name }}
draft: false
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ contains(github.event.pull_request.labels.*.name, 'Pre-release') }}
generate_release_notes: true