-
Notifications
You must be signed in to change notification settings - Fork 3
271 lines (237 loc) · 9.12 KB
/
createRelease.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Build & Release
on:
workflow_dispatch:
inputs:
runUnitTest:
type: boolean
description: Run Unit Tests
default: true
runIntergrationTest:
type: boolean
description: Run Intergrations Tests
default: true
buildOptions:
required: false
type: choice
description: Build Options
default: Build
options:
- Build
releaseOption:
required: false
type: choice
description: Release Options
default: None
options:
- None
- PRE-RELEASE (release/** branches)
- RELEASE (main branch)
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
WindowsSDKPath: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools'
jobs:
manageVariable:
name: Manage Variables
runs-on: windows-latest
outputs:
releaseVersion: ${{ env.releaseVersion }}
packageVersion: ${{ env.packageVersion }}
publishPackages: ${{ env.publishPackages }}
release_sha: ${{ env.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Apply versioning
if: success()
uses: ./.github/actions/env
- name: Package information
run: |
Write-Host "Release version: ${{ env.releaseVersion }}"
Write-Host "Package version: ${{ env.packageVersion }}"
Write-Host "Publish package: ${{ env.publishPackages }}"
Write-Host "Build Suffix: ${{ env.buildSuffix }}"
Write-Host "DNX_BUILD_VERSION: ${{ env.DNX_BUILD_VERSION }}"
Write-output "::notice title=Build branch::${{ github.ref_name }}"
Write-output "::notice title=Release version::${{ env.releaseVersion }}"
Write-output "::notice title=Packages version::${{ env.packageVersion }}"
Write-output "::notice title=Publish packages::${{ env.publishPackages }}"
build:
name: Build
needs: [manageVariable]
runs-on: windows-latest
env:
releaseVersion: ${{ needs.manageVariable.outputs.releaseVersion }}
packageVersion: ${{ needs.manageVariable.outputs.packageVersion }}
publishPackages: ${{ needs.manageVariable.outputs.publishPackages }}
release_sha: ${{ needs.manageVariable.outputs.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Build
if: success()
run: msbuild\build.ps1 -configuration "Release" -skiptests "true" -verbosity "normal"
- name: Packages
if: success() && env.publishPackages == 'true'
run: msbuild\packGH.ps1 -version ${{ env.packageVersion }} -configuration "Release"
- name: Create Zip file
if: success() && env.publishPackages == 'true'
run: msbuild\createZipFile.ps1 -findVersion ${{ env.packageVersion }}
- name: Upload packages to artifacts
if: success() && env.publishPackages == 'true'
uses: actions/upload-artifact@v3
with:
name: Optimizely.Graph.Client-${{ env.packageVersion }}
path: ${{ github.workspace}}/artifacts/
# retention-days: 90
unit_test:
needs: [manageVariable, build]
name: Unit test
if: ${{ github.event.inputs.runUnitTest == 'true' }}
uses: ./.github/workflows/unitTest.yml
intergration_test:
needs: [manageVariable, build]
name: Intergrations test
if: ${{ github.event.inputs.runIntergrationTest == 'true' }}
uses: ./.github/workflows/intergrationTest.yml
secrets:
GATEWAYADDRESS: ${{ secrets.GATEWAYADDRESS }}
APPKEY: ${{ secrets.APPKEY }}
SECRET: ${{ secrets.SECRET }}
SINGLEKEY: ${{ secrets.SINGLEKEY }}
creatPreRelease:
name: Create Pre-Release
needs: [manageVariable, build, unit_test, intergration_test]
if: startsWith(github.ref, 'refs/heads/release') == true && github.event.inputs.releaseOption == 'PRE-RELEASE (release/** branches)'
runs-on: windows-latest
env:
releaseVersion: ${{ needs.manageVariable.outputs.releaseVersion }}
packageVersion: ${{ needs.manageVariable.outputs.packageVersion }}
publishPackages: ${{ needs.manageVariable.outputs.publishPackages }}
release_sha: ${{ needs.manageVariable.outputs.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Fetch all tags
run: |
git fetch --prune --unshallow
git fetch --tags
- name: Prepare release notes
shell: powershell
run: |
Write-Output "Prepare release note"
msbuild\github\GetReleaseNotes.ps1 | Set-Content -Path "msbuild\github\ReleaseNotes.txt" -Force
- name: Create Github Release
id: create_github_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.releaseVersion }}
release_name: ${{ env.releaseVersion }}
commitish: ${{ env.release_sha }}
body_path: "msbuild/github/ReleaseNotes.txt"
draft: false
prerelease: true
- name: Create artifacts folder
run: |
if (Test-Path -Path "artifacts") {
Remove-Item -LiteralPath "artifacts" -Force -Recurse
}
New-Item -Path "artifacts" -ItemType Directory
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Optimizely.Graph.Client-${{ env.packageVersion }}
path: artifacts
- name: Archive artifacts Release
uses: thedoctor0/zip-release@master
with:
type: 'zip'
filename: 'Optimizely.Graph.Client-${{ env.packageVersion }}.zip'
path: ./artifacts/*
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_github_release.outputs.upload_url }}
asset_path: ./Optimizely.Graph.Client-${{ env.packageVersion }}.zip
asset_name: Optimizely.Graph.Client-${{ env.packageVersion }}.zip
asset_content_type: application/zip
creatGitHubRelease:
name: Publish GitHub Release
needs: [manageVariable, build, unit_test, intergration_test]
if: github.ref == 'refs/heads/main' && github.event.inputs.releaseOption == 'RELEASE (main branch)'
runs-on: windows-latest
env:
releaseVersion: ${{ needs.manageVariable.outputs.releaseVersion }}
packageVersion: ${{ needs.manageVariable.outputs.packageVersion }}
publishPackages: ${{ needs.manageVariable.outputs.publishPackages }}
release_sha: ${{ needs.manageVariable.outputs.release_sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Check tag exist
uses: mukunku/tag-exists-action@v1.2.0
id: checkTag
with:
tag: ${{env.releaseVersion}}
- name: Delete Pre-Release if exist
if: ${{ steps.checkTag.outputs.exists }} == "true"
uses: dev-drprasad/delete-tag-and-release@v0.2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{env.releaseVersion}}
delete_release: true
- name: Fetch all tags
run: |
git fetch --prune --unshallow
git fetch --tags
- name: Prepare release notes
shell: powershell
run: |
Write-Output "Prepare release note"
msbuild\github\GetReleaseNotes.ps1 | Set-Content -Path "msbuild\github\ReleaseNotes.txt" -Force
- name: Create Github Release
id: create_github_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.releaseVersion }}
release_name: ${{ env.releaseVersion }}
commitish: ${{ env.release_sha }}
body_path: "msbuild/github/ReleaseNotes.txt"
draft: false
prerelease: false
- name: Create artifacts folder
run: |
if (Test-Path -Path "artifacts") {
Remove-Item -LiteralPath "artifacts" -Force -Recurse
}
New-Item -Path "artifacts" -ItemType Directory
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Optimizely.Graph.Client-${{ env.packageVersion }}
path: artifacts
- name: Archive artifacts Release
uses: thedoctor0/zip-release@master
with:
type: 'zip'
filename: 'Optimizely.Graph.Client-${{ env.packageVersion }}.zip'
path: ./artifacts/*
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_github_release.outputs.upload_url }}
asset_path: ./Optimizely.Graph.Client-${{ env.packageVersion }}.zip
asset_name: Optimizely.Graph.Client-${{ env.packageVersion }}.zip
asset_content_type: application/zip