Repository navigation
191 lines (172 loc) · 6.8 KB
/
Copy pathworkflow.yml
File metadata and controls
191 lines (172 loc) · 6.8 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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
on:
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "docs/**"
- "configurationFiles/**"
- "kusto/**"
branches:
- master
- main
push:
paths-ignore:
- "docs/**"
- "configurationFiles/**"
- "kusto/**"
branches:
- master
- main
permissions: {}
jobs:
build:
permissions:
contents: read
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- name: Validate release policy
shell: cmd
run: node --test .github\tests\release-policy.test.cjs
- name: environment
shell: cmd
run: |
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: |
dotnet build %project_root%\%project_name%\%project_name%.csproj -v detailed -c Release
if errorlevel 1 exit /b %errorlevel%
dir
- name: build output
shell: cmd
run: |
dir /s
- name: copy artifacts
shell: powershell
run: |
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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: Release
path: ${{ env.artifacts_path }}
if-no-files-found: error
release_metadata:
if: github.event_name == 'push'
runs-on: windows-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
publish: ${{ steps.release_policy.outputs.publish }}
prerelease: ${{ steps.release_policy.outputs.prerelease }}
steps:
- name: Check merged pull request release labels
id: release_policy
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
script: |
const pullRequests = await github.paginate(
github.rest.repos.listPullRequestsAssociatedWithCommit,
{ ...context.repo, commit_sha: context.sha, per_page: 100 }
);
const branch = context.ref.replace(/^refs\/heads\//, '');
const mergedPullRequests = pullRequests.filter(pr =>
pr.merged_at &&
pr.merge_commit_sha === context.sha &&
pr.base.repo.id === context.payload.repository.id &&
pr.base.ref === branch
);
if (mergedPullRequests.length > 1) {
throw new Error('Multiple merged pull requests match the pushed commit.');
}
const labels = mergedPullRequests[0]?.labels.map(label => label.name) ?? [];
core.setOutput('publish', labels.includes('Release') || labels.includes('Pre-release'));
core.setOutput('prerelease', labels.includes('Pre-release'));
release:
if: github.event_name == 'push' && needs.release_metadata.outputs.publish == 'true'
needs: [build, release_metadata]
runs-on: windows-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: download artifact
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
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
# https://github.com/marketplace/actions/gh-release
- name: create release
id: create_release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
files: |
**/${{ env.project_name }}.zip
**/*${{ env.project_name }}*.nupkg
tag_name: ${{ steps.prepare_release_asset.outputs.file_version }}
target_commitish: ${{ github.sha }}
name: ${{ env.project_name }}
draft: false
token: ${{ github.token }}
prerelease: ${{ needs.release_metadata.outputs.prerelease == 'true' }}
generate_release_notes: true