ci: Use GITHUB_OUTPUT envvar instead of set-output command #270
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: CI CollectSFData | |
env: | |
project_name: CollectSFData | |
project_root: .\src | |
artifacts_path: .\src\bin\artifacts | |
release_path: .\src\bin\Release | |
release_config: .\configurationFiles\collectsfdata.options.json | |
target_version: net48 | |
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() | |
dir | |
copy "$($env:release_path)" "$($env:artifacts_path)" -recurse -force | |
copy "$($env:release_config)" "$($env:artifacts_path)" -recurse -force | |
- 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 | |
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 | |
- name: prepare release asset | |
shell: powershell | |
id: prepare_release_asset | |
run: | | |
md "$($env:release_path)_upload" | |
$releaseFramework = "$($env:release_path)\$($env:target_version)" | |
copy "$($releaseFramework)\*.config" "$($env:release_path)_upload" | |
copy "$($releaseFramework)\*.exe" "$($env:release_path)_upload" | |
copy "$($releaseFramework)\*.dll" "$($env:release_path)_upload" | |
copy "$($releaseFramework)\*.json" "$($env:release_path)_upload" | |
compress-archive -path "$($env:release_path)_upload\*" -destinationPath "$($env:release_path)\$($env:project_name).zip" -force | |
$fileVersion = [io.fileinfo]::new("$($releaseFramework)\$($env:project_name).exe").VersionInfo.FileVersion | |
echo "::log-command parameter1=$fileVersion::fileVersion" | |
echo "file_version=v$fileVersion" >> $env:GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.prepare_release_asset.outputs.file_version }} | |
release_name: ${{ env.project_name }} | |
draft: false | |
prerelease: ${{ contains(github.event.pull_request.labels.*.name, 'Pre-release') }} | |
- name: upload release asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.release_path }}\${{ env.project_name }}.zip | |
asset_name: ${{ env.project_name }}.zip | |
asset_content_type: application/zip | |
- name: upload nuget release asset | |
id: upload-nuget-release-asset | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.set_nuget_package.outputs.nuget_package }} | |
asset_name: ${{ steps.set_nuget_package.outputs.nuget_package_name }} | |
asset_content_type: application/zip |