Create Github Release #75
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" "*" | |
$destinationFilePath = Join-Path "$outputFolderPath" "extractor-${{ 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: extractor-${{ matrix.dotnet-runtime }} | |
path: ${{ 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..." | |
$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: ${{ 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@v4 | |
with: | |
name: github | |
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@v4 | |
with: | |
name: ado | |
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@v4 | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{github.workspace}}/extractor-linux-arm64/extractor-linux-arm64.zip | |
${{github.workspace}}/extractor-linux-musl-arm64/extractor-linux-musl-arm64.zip | |
${{github.workspace}}/extractor-linux-musl-x64/extractor-linux-musl-x64.zip | |
${{github.workspace}}/extractor-linux-x64/extractor-linux-x64.zip | |
${{github.workspace}}/extractor-osx-arm64/extractor-osx-arm64.zip | |
${{github.workspace}}/extractor-osx-x64/extractor-osx-x64.zip | |
${{github.workspace}}/extractor.osx-x64/extractor.osx-x64.zip | |
${{github.workspace}}/extractor-win-x64/extractor-win-x64.zip | |
${{github.workspace}}/publisher-linux-arm64/publisher-linux-arm64.zip | |
${{github.workspace}}/publisher-linux-musl-arm64/publisher-linux-musl-arm64.zip | |
${{github.workspace}}/publisher-linux-musl-x64/publisher-linux-musl-x64.zip | |
${{github.workspace}}/publisher-linux-x64/publisher-linux-x64.zip | |
${{github.workspace}}/publisher-osx-arm64/publisher-osx-arm64.zip | |
${{github.workspace}}/publisher-osx-x64/publisher-osx-x64.zip | |
${{github.workspace}}/publisher.osx-x64/publisher.osx-x64.zip | |
${{github.workspace}}/publisher-win-x64/publisher-win-x64.zip | |
${{github.workspace}}/github/Github.zip | |
${{github.workspace}}/ado/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 |