test123 #220
Workflow file for this run
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: Build & Test | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: windows-latest | |
defaults: | |
run: | |
working-directory: ./src | |
shell: pwsh | |
outputs: | |
semver: ${{ steps.gitversion.outputs.semver }} | |
win-x64-fileName: ${{ steps.packageBuildResults.outputs.win-x64-fileName }} | |
nupkg-binary-fileName: ${{ steps.createNupkg.outputs.nupkg-binary-fileName }} | |
nupkg-client-fileName: ${{ steps.createNupkg.outputs.nupkg-client-fileName }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v2 | |
id: cache | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Add msbuild to PATH | |
uses: microsoft/[email protected] | |
- name: Restore Packages | |
# if: steps.cache.outputs.cache-hit != 'true' | |
run: dotnet restore _ALL.sln --use-lock-file | |
- name: Build | |
run: msbuild -m -t:Rebuild -p:Configuration=Release -bl:opc-ua-pubsub-dotnet.binlog -noconlog _All.sln | |
- name: Archive Build Log | |
uses: actions/upload-artifact@v2 | |
if: ${{ success() || failure() }} | |
with: | |
name: log-win-x64-release | |
path: | | |
src/*.binlog | |
- name: Store SemVer | |
id: gitversion | |
run: | | |
Set-Variable -Name "GITHUB_OUTPUT" -Value "semver=$($env:GitVersion_SemVer)" | |
Write-Host "$GITHUB_OUTPUT" | |
- name: Create zip | |
id: packageBuildResults | |
run: | | |
$sourceFolder = Join-Path $env:GITHUB_WORKSPACE "src" | Join-Path -ChildPath "_Out" | Join-Path -ChildPath "Release" | Join-Path -ChildPath "*" | |
$outFolder = Join-Path $env:GITHUB_WORKSPACE "src" | Join-Path -ChildPath "_Out" | Join-Path -ChildPath "GitHub" | |
New-Item -ItemType Directory -Force -Path $outFolder | |
$fileName = "win-x64-$($env:GitVersion_SemVer).zip" | |
Write-Host "Filename: '$fileName'" | |
Set-Variable -Name "GITHUB_OUTPUT" -Value "win-x64-fileName=$($fileName)" | |
$outPath = Join-Path $outFolder $fileName | |
Compress-Archive -DestinationPath $outPath -Path $sourceFolder -CompressionLevel Optimal | |
- name: Archive Build Result | |
uses: actions/upload-artifact@v2 | |
with: | |
name: win-x64-release | |
path: | | |
src/_Out/GitHub | |
- name: Create Nuget Packages | |
id: createNupkg | |
run: | | |
$packageOutFolder = Join-Path $env:GITHUB_WORKSPACE "src" | Join-Path -ChildPath "_Out" | Join-Path -ChildPath "NuGet" | |
dotnet pack _ALL.sln --no-build --configuration Release --output $packageOutFolder | |
Write-Host "Save filenames of created NuGet packages..." | |
$packages = gci -Path $packageOutFolder -File -Filter "*.nupkg" | select -ExpandProperty Name | |
$binary = $packages | where {$_ -match "binary"} | |
Write-Host "Binary NuGet Package: '$binary'" | |
Set-Variable -Name "GITHUB_OUTPUT" -Value "nupkg-binary-fileName=$($binary)" | |
$client = $packages | where {$_ -match "client"} | |
Write-Host "Client NuGet Package: '$client'" | |
Set-Variable -Name "GITHUB_OUTPUT" -Value "nupkg-client-fileName=$($client)" | |
- name: Archive NuGet Packages | |
uses: actions/upload-artifact@v2 | |
with: | |
name: nuget-win-x64-release | |
path: | | |
src/_Out/NuGet | |
- name: Test | |
run: | | |
dotnet test --no-build --configuration Release | |
release: | |
if: github.ref == 'refs/heads/main' | |
runs-on: windows-latest | |
needs: build | |
defaults: | |
run: | |
shell: pwsh | |
steps: | |
- name: Download Build Results | |
uses: actions/download-artifact@v2 | |
with: | |
name: win-x64-release | |
- name: Download NuGet Packages | |
uses: actions/download-artifact@v2 | |
with: | |
name: nuget-win-x64-release | |
- name: Debug | |
run: | | |
tree | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: ${{ needs.build.outputs.semver }} | |
release_name: Release ${{ needs.build.outputs.semver }} | |
body: | | |
${{ github.event.head_commit.message }} | |
draft: true | |
prerelease: false | |
- name: Upload Zip | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./${{ needs.build.outputs.win-x64-fileName }} | |
asset_name: ${{ needs.build.outputs.win-x64-fileName }} | |
asset_content_type: application/zip | |
- name: Upload Binary Nupkg | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./${{ needs.build.outputs.nupkg-binary-fileName }} | |
asset_name: ${{ needs.build.outputs.nupkg-binary-fileName }} | |
asset_content_type: application/zip | |
- name: Upload Client Nupkg | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./${{ needs.build.outputs.nupkg-client-fileName }} | |
asset_name: ${{ needs.build.outputs.nupkg-client-fileName }} | |
asset_content_type: application/zip |