-
Notifications
You must be signed in to change notification settings - Fork 192
257 lines (215 loc) · 11.6 KB
/
create_github_release.yaml
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
name: Create Github Release
on:
workflow_dispatch:
inputs:
Release_Version:
description: "Provide a release version. e.g. v3.1.0"
required: true
type: string
jobs:
# generate_extractor_artifacts:
# name: Generate extractor artifacts
# strategy:
# matrix:
# dotnet-runtime: [linux-x64, linux-arm64, linux-musl-x64, linux-musl-arm64, win-x64, osx-arm64, osx-x64]
# # Dynamically set the runner OS based on the .NET runtime
# runs-on: ${{ fromJSON('{"linux-x64":"ubuntu-latest", "linux-arm64":"ubuntu-latest", "linux-musl-x64":"ubuntu-latest", "linux-musl-arm64":"ubuntu:latest", "win-x64":"windows-latest", "osx-arm64":"macos-latest", "osx-x64":"macos-latest"}')[matrix.dotnet-runtime] }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Setup .NET
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: 8.x
# - name: Generate executable
# run: |
# Set-StrictMode -Version Latest
# $ErrorActionPreference = "Stop"
# $VerbosePreference = "Continue"
# $InformationPreference = "Continue"
# Write-Information "Creating output directory..."
# $outputFolderPath = Join-Path "${{ runner.temp }}" "extractor-output"
# New-Item -Path "$outputFolderPath" -ItemType "Directory"
# Write-Information "Publishing application..."
# $sourcePath = Join-Path "${{ github.workspace }}" "tools" "code" "extractor" "extractor.csproj"
# & dotnet publish "$sourcePath" --self-contained --runtime "${{ matrix.dotnet-runtime }}" -p:PublishSingleFile=true --output "$outputFolderPath"
# if ($LASTEXITCODE -ne 0) { throw "Generating extractor failed."}
# Write-Information "Zipping application..."
# $sourceFolderPath = Join-Path "$outputFolderPath" "*"
# $extractorFileNameWithoutExtension = "${{ format('extractor.{0}', matrix.dotnet-runtime) }}"
# $destinationFilePath = Join-Path "$outputFolderPath" "$($extractorFileNameWithoutExtension).zip"
# Compress-Archive -Path $sourceFolderPath -DestinationPath $destinationFilePath
# "{ZIP_FILE_PATH}=$destinationFilePath" | Out-File -FilePath $env:GITHUB_ENV -Append
# Write-Information "Execution complete."
# shell: pwsh
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# path: ${{ format('{0}/{1}', runner.temp, env.ZIP_FILE_PATH) }}
generate_publisher_artifacts:
name: Generate publisher artifacts
strategy:
matrix:
dotnet-runtime: [linux-x64, linux-arm64, linux-musl-x64, linux-musl-arm64, win-x64, osx-arm64, osx-x64]
# Dynamically set the runner OS based on the .NET runtime
runs-on: ${{ fromJSON('{"linux-x64":"ubuntu-latest", "linux-arm64":"ubuntu-latest", "linux-musl-x64":"ubuntu-latest", "linux-musl-arm64":"ubuntu:latest", "win-x64":"windows-latest", "osx-arm64":"macos-latest", "osx-x64":"macos-latest"}')[matrix.dotnet-runtime] }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.x
- name: Generate executable
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$VerbosePreference = "Continue"
$InformationPreference = "Continue"
Write-Information "Creating output directory..."
$outputFolderPath = Join-Path "${{ runner.temp }}" "publisher-output"
New-Item -Path "$outputFolderPath" -ItemType "Directory"
Write-Information "Publishing application..."
$sourcePath = Join-Path "${{ github.workspace }}" "tools" "code" "publisher" "publisher.csproj"
& dotnet publish "$sourcePath" --self-contained --runtime "${{ matrix.dotnet-runtime }}" -p:PublishSingleFile=true --output "$outputFolderPath"
if ($LASTEXITCODE -ne 0) { throw "Generating publisher failed."}
Write-Information "Zipping application..."
## DELETE
Get-ChildItem -Path $outputFolderPath -Recurse
$sourceFolderPath = Join-Path "$outputFolderPath" "*"
$destinationFilePath = Join-Path "$outputFolderPath" "publisher.${{ matrix.dotnet-runtime) }}.zip"
Compress-Archive -Path $sourceFolderPath -DestinationPath $destinationFilePath -CompressionLevel Optimal
"{ZIP_FILE_PATH}=$destinationFilePath" | Out-File -FilePath $env:GITHUB_ENV -Append
Write-Information "Execution complete."
shell: pwsh
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: publisher-${{ matrix.dotnet-runtime }}
path: ${{ format('{0}/{1}', runner.temp, env.ZIP_FILE_PATH) }}
# generate_github_pipeline_artifacts:
# name: Generate GitHub artifacts
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Update versions in YAML
# run: |
# Set-StrictMode -Version Latest
# $ErrorActionPreference = "Stop"
# $VerbosePreference = "Continue"
# $InformationPreference = "Continue"
# $runExtractorPath = Join-Path "${{ github.workspace }}" "tools" "github_workflows" "run-extractor.yaml"
# (Get-Content -Path "$runExtractorPath") |
# ForEach-Object {$_ -Replace 'desired-version-goes-here', '${{ github.event.inputs.Release_Version }}'} |
# Set-Content -Path "$runExtractorPath"
# $runPublisherWithEnvPath = Join-Path "${{ github.workspace }}" "tools" "github_workflows" "run-publisher-with-env.yaml"
# (Get-Content -Path "$runPublisherWithEnvPath") |
# ForEach-Object {$_ -Replace 'desired-version-goes-here', '${{ github.event.inputs.Release_Version }}'} |
# Set-Content -Path "$runPublisherWithEnvPath"
# Write-Information "Execution complete."
# shell: pwsh
# - name: Setup artifact contents
# run: |
# Set-StrictMode -Version Latest
# $ErrorActionPreference = "Stop"
# $VerbosePreference = "Continue"
# $InformationPreference = "Continue"
# $artifactsFolderPath = Join-Path "${{ runner.temp }}" "github_artifacts"
# Write-Information "Copying GitHub workflows..."
# $sourceFolderPath = Join-Path "${{ github.workspace }}" "tools" "github_workflows" "*"
# $destinationFolderPath = Join-Path "$artifactsFolderPath" ".github" "workflows"
# New-Item -Path "$destinationFolderPath" -ItemType "Directory"
# Copy-Item -Path "$sourceFolderPath" -Destination "$destinationFolderPath" -Recurse
# Write-Information "Zipping artifacts..."
# $destinationFilePath = Join-Path "${{ runner.temp }}" "Github.zip"
# # We use System.IO.Compression.ZipFile instead of Compress-Archive because of this issue: https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/66
# [System.IO.Compression.ZipFile]::CreateFromDirectory("$artifactsFolderPath", "$destinationFilePath")
# Write-Information "Execution complete."
# shell: pwsh
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# path: ${{ runner.temp }}/Github.zip
# generate_ado_pipeline_artifacts:
# name: Generate Azure DevOps artifacts
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Update versions in YAML
# run: |
# Set-StrictMode -Version Latest
# $ErrorActionPreference = "Stop"
# $VerbosePreference = "Continue"
# $InformationPreference = "Continue"
# $runExtractorPath = Join-Path "${{ github.workspace }}" "tools" "azdo_pipelines" "run-extractor.yaml"
# (Get-Content -Path "$runExtractorPath") |
# ForEach-Object {$_ -Replace 'desired-version-goes-here', '${{ github.event.inputs.Release_Version }}'} |
# Set-Content -Path "$runExtractorPath"
# $runPublisherWithEnvPath = Join-Path "${{ github.workspace }}" "tools" "azdo_pipelines" "run-publisher-with-env.yaml"
# (Get-Content -Path "$runPublisherWithEnvPath") |
# ForEach-Object {$_ -Replace 'desired-version-goes-here', '${{ github.event.inputs.Release_Version }}'} |
# Set-Content -Path "$runPublisherWithEnvPath"
# Write-Information "Execution complete."
# shell: pwsh
# - name: Setup artifact contents
# run: |
# Set-StrictMode -Version Latest
# $ErrorActionPreference = "Stop"
# $VerbosePreference = "Continue"
# $InformationPreference = "Continue"
# $artifactsFolderPath = Join-Path "${{ runner.temp }}" "azdo_artifacts"
# Write-Information "Copying Azure DevOps pipelines..."
# $sourceFolderPath = Join-Path "${{ github.workspace }}" "tools" "azdo_pipelines" "*"
# $destinationFolderPath = Join-Path "$artifactsFolderPath" "tools" "pipelines"
# New-Item -Path "$destinationFolderPath" -ItemType "Directory"
# Copy-Item -Path "$sourceFolderPath" -Destination "$destinationFolderPath" -Recurse
# Write-Information "Zipping artifacts..."
# $destinationFilePath = Join-Path "${{ runner.temp }}" "Azure_DevOps.zip"
# # We use System.IO.Compression.ZipFile instead of Compress-Archive because of this issue: https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/66
# [System.IO.Compression.ZipFile]::CreateFromDirectory("$artifactsFolderPath", "$destinationFilePath")
# Write-Information "Execution complete."
# shell: pwsh
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# path: ${{ runner.temp }}/Azure_DevOps.zip
# generate_release:
# name: Generate release
# needs:
# [
# generate_extractor_artifacts,
# generate_publisher_artifacts,
# generate_github_pipeline_artifacts,
# generate_ado_pipeline_artifacts,
# ]
# runs-on: ubuntu-latest
# permissions:
# contents: write
# steps:
# - name: Download artifacts
# uses: actions/download-artifact@v3
# - name: Create release
# uses: softprops/action-gh-release@v1
# with:
# files: |
# ${{github.workspace}}/artifact/extractor.win-x64.exe
# ${{github.workspace}}/artifact/extractor.linux-x64
# ${{github.workspace}}/artifact/extractor.linux-arm64
# ${{github.workspace}}/artifact/extractor.linux-musl-x64
# ${{github.workspace}}/artifact/extractor.linux-musl-arm64
# ${{github.workspace}}/artifact/extractor.osx-arm64
# ${{github.workspace}}/artifact/extractor.osx-x64
# ${{github.workspace}}/artifact/publisher.win-x64.exe
# ${{github.workspace}}/artifact/publisher.linux-x64
# ${{github.workspace}}/artifact/publisher.linux-arm64
# ${{github.workspace}}/artifact/publisher.linux-musl-x64
# ${{github.workspace}}/artifact/publisher.linux-musl-arm64
# ${{github.workspace}}/artifact/publisher.osx-arm64
# ${{github.workspace}}/artifact/publisher.osx-x64
# ${{github.workspace}}/artifact/Github.zip
# ${{github.workspace}}/artifact/Azure_DevOps.zip
# name: APIOps Toolkit for Azure APIM ${{ github.event.inputs.Release_Version }}
# tag_name: ${{ github.event.inputs.Release_Version }}
# generate_release_notes: true