next try on another branch (#59) #234
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@v4 | |
if: ${{ success() || failure() }} | |
with: | |
name: log-win-x64-release | |
path: | | |
src/*.binlog | |
- name: Store SemVer | |
id: gitversion | |
run: | | |
echo "semver=$($env:GitVersion_SemVer)" >> $Env: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'" | |
echo "win-x64-fileName=$($fileName)" >> $Env:GITHUB_OUTPUT | |
$outPath = Join-Path $outFolder $fileName | |
Compress-Archive -DestinationPath $outPath -Path $sourceFolder -CompressionLevel Optimal | |
- name: Archive Build Result | |
uses: actions/upload-artifact@v4 | |
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'" | |
echo "nupkg-binary-fileName=$($binary)" >> $Env:GITHUB_OUTPUT | |
$client = $packages | where {$_ -match "client"} | |
Write-Host "Client NuGet Package: '$client'" | |
echo "nupkg-client-fileName=$($client)" >> $Env:GITHUB_OUTPUT | |
- name: Archive NuGet Packages | |
uses: actions/upload-artifact@v4 | |
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 |