Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: PR Build

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: windows-latest
env:
OS: win
APP_NAME: YouTubeMusicStreamer
DOTNET_VERSION: "9.0"
ARCH: x64
RELEASE_NOTES_FILE: release-notes.md
VPK_OUTPUT_DIR: Releases
VPK_PACK_AUTHORS: XeroxDev
VPK_PACK_TITLE: "YouTube Music Streamer"
steps:
- uses: actions/checkout@v4

- name: Prepare build env
shell: pwsh
env:
GITHUB_SHA: ${{ github.sha }}
TWITCH_CLIENT_ID: pr-build
Comment thread
XeroxDev marked this conversation as resolved.
run: .\scripts\prepare-build-env.ps1

- name: Set dynamic VPK env vars
shell: pwsh
run: |
$envBlock = @"
VPK_CHANNEL=$($Env:OS)-$($Env:ARCH)
VPK_RUNTIME=$($Env:OS)-$($Env:ARCH)
VPK_PACK_DIR=./publish/$($Env:OS)-$($Env:ARCH)
VPK_FRAMEWORK=webview2,net$($Env:DOTNET_VERSION)-$($Env:ARCH)-desktop
VPK_ICON=./$($Env:APP_NAME)/wwwroot/favicon.ico
VPK_SPLASH_IMAGE=./$($Env:APP_NAME)/Resources/Splash/splash.png
VPK_PACK_VERSION=$($Env:VERSION)
VPK_RELEASE_NAME=v$($Env:VERSION)
VPK_TAG=v$($Env:VERSION)
VPK_TARGET_COMMITISH=$($Env:GITHUB_SHA)
VPK_REPO_URL=https://github.com/$($Env:GITHUB_REPOSITORY)
VPK_PACK_ID=$($Env:APP_NAME)
VPK_MAIN_EXE=$($Env:APP_NAME).exe
"@

Add-Content -Path $Env:GITHUB_ENV -Value $envBlock -Encoding utf8

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}.x

- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}

- name: Publish
run: dotnet publish YouTubeMusicStreamer/YouTubeMusicStreamer.csproj -c Release -p:PublishProfile=${{ env.VPK_CHANNEL }}
22 changes: 19 additions & 3 deletions YouTubeMusicStreamer/YouTubeMusicStreamer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,24 @@
</UsingTask>

<Target Name="GenerateThirdPartyLicenses" BeforeTargets="BeforeBuild" Condition="'$(Configuration)'=='Release'">
<Exec Command="dotnet tool restore"/>
<Exec Command="dotnet tool run nuget-license -i $(ProjectDir)$(MSBuildProjectFile) -t -o JsonPretty -d $(ProjectDir)Resources\Raw\ThirdPartyLicenses\ -fo $(ProjectDir)Resources\Raw\third-party-licenses.json -override $(ProjectDir)license-override.json" IgnoreExitCode="true"/>
<MakeDir Directories="$(ProjectDir)Resources\Raw\ThirdPartyLicenses" />
<Exec Command="dotnet tool restore" />
<Exec Command="dotnet tool run nuget-license -i $(ProjectDir)$(MSBuildProjectFile) -t -o JsonPretty -d $(ProjectDir)Resources\Raw\ThirdPartyLicenses\ -fo $(ProjectDir)Resources\Raw\third-party-licenses.json -override $(ProjectDir)license-override.json" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="NuGetLicenseExitCode" />
</Exec>
<Warning Condition="'$(NuGetLicenseExitCode)'=='3'" Text="nuget-license reported validation warnings; see generated files for details." />
<Error Condition="'$(NuGetLicenseExitCode)'!='0' AND '$(NuGetLicenseExitCode)'!='3'" Text="nuget-license failed with exit code $(NuGetLicenseExitCode)." />

<ItemGroup>
<MauiAsset Remove="Resources\Raw\third-party-licenses.json" />
<MauiAsset Remove="Resources\Raw\ThirdPartyLicenses\**" />
<MauiAsset Include="$(ProjectDir)Resources\Raw\third-party-licenses.json" LogicalName="third-party-licenses.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</MauiAsset>
<MauiAsset Include="$(ProjectDir)Resources\Raw\ThirdPartyLicenses\**" LogicalName="ThirdPartyLicenses\%(RecursiveDir)%(Filename)%(Extension)">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</MauiAsset>
</ItemGroup>
</Target>

</Project>
Loading