diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 29addef..435516e 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -1,15 +1,25 @@ -name: "create github release" - +name: "2. create github release" + on: workflow_dispatch: + jobs: tagged-release: name: "Tagged Release" runs-on: "ubuntu-latest" steps: + - uses: actions/checkout@v3 + - name: "Get Version info from src/Directory.Build.props" + id: "get_version" + shell: pwsh + run: | + $version_info = & ./scripts/get_build_version.ps1 + echo "version: $version_info" + Write-Output "::set-output name=version_str::$('v'+$($version_info.OriginalVersion))" # Create GitHub.com Release - name: "Create GitHub Release" uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" - \ No newline at end of file + automatic_release_tag: "${{ steps.get_version.outputs.version_str }}" + prerelease: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44eb43a..78d11df 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ # This is a basic workflow to help you get started with Actions -name: "build library src" +name: "0. build library src" # Controls when the action will run. on: @@ -9,10 +9,9 @@ on: branches: [ main ] paths-ignore: - 'examples/**' + - 'scripts/**' pull_request: branches: [ main ] - paths-ignore: - - 'examples/**' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 631f51e..d3e506f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: publish to nuget +name: "1. publish to nuget" on: workflow_dispatch: @@ -13,13 +13,13 @@ jobs: with: global-json-file: global.json # Publish - - name: publish on version change - id: publish_nuget + - name: publish Blazor.Bootstrap.SwitchButton nuget package uses: alirezanet/publish-nuget@v3.0.4 with: # Filepath of the project to be packaged, relative to root of repository PROJECT_FILE_PATH: src/GranDen.Blazor.Bootstrap.SwitchButton/GranDen.Blazor.Bootstrap.SwitchButton.csproj VERSION_FILE_PATH: src/Directory.Build.props VERSION_REGEX: ^\s*(.*)<\/Version>\s*$ + TAG_COMMIT: false NUGET_KEY: ${{secrets.NUGET_API_KEY}} INCLUDE_SYMBOLS: true diff --git a/scripts/get_build_version.ps1 b/scripts/get_build_version.ps1 new file mode 100644 index 0000000..904f567 --- /dev/null +++ b/scripts/get_build_version.ps1 @@ -0,0 +1,48 @@ +#!/usr/bin/env pwsh +Set-StrictMode -Version 3 +Set-Variable -Name build_version_text -Value ` +(Select-Xml -Path './src/Directory.Build.props' -XPath "/Project/PropertyGroup/Version[contains(@Condition, `"`'`$(Version)`'==`'`'`")]//text()[1]").Node.Value -Option Constant; +Set-Variable -Name package_name -Value 'Nuget.Versioning' -Option Constant; +Set-Variable -Name package_version -Value '6.3.0' -Option Constant; +Set-Variable -Name type_name -Value 'NuGet.Versioning.NuGetVersion' -Option Constant; +Set-Variable -Name nuget_source -Value 'https://api.nuget.org/v3/index.json' -Option Constant; + +if ($type_name -as [type]) +{ + Write-Debug "{$type_name} already loaded"; + $ret = New-Object -TypeName $type_name -ArgumentList "$build_version_text"; + return $ret; +} +$package = get-package -ProviderName Nuget | Where-Object { $_.Name -eq $package_name }; +if ($null -eq $package) +{ + Write-Debug "Package $package_name not found"; + # Get nuget package and find the extraced dll in first occurence + Write-Debug "try to download `"$package_name`" nuget package..." + $error.Clear(); + (Install-Package -Verbose -Name "$package_name" -RequiredVersion $package_version -SkipDependencies -ProviderName NuGet -Source $nuget_source -Scope CurrentUser -Force) | Out-Null; + $package = Get-Package $package_name; +} + +$nuget_versioning_source = $package.Source; +if ($null -eq $nuget_versioning_source) +{ + Write-Debug "get package `"$package_name`" again"; + $nuget_versioning_source = (Get-Package $package_name).Source; +} +$nuget_dll_path = ` + (Get-ChildItem -File -Filter "$package_name.dll" -Recurse (Split-Path $nuget_versioning_source) | Where-Object { $_.Directory -like '*netstandard2.0*' }).FullName; + +Write-Debug "`"$package_name.dll`" real path: $nuget_dll_path" + +$execute_job = Start-Job -ScriptBlock { + (Add-Type -Path $args[0]) | Out-Null; + $ret = New-Object -TypeName $args[1] -ArgumentList $args[2]; + return $ret; +} -ArgumentList $nuget_dll_path, $type_name, $build_version_text; + +(Wait-Job $execute_job) | Out-Null; +$job_result = Receive-Job $execute_job -Keep; +$ret = $job_result | Where-Object { $_.RunspaceId -ne $null } | Select-Object * -ExcludeProperty PSComputerName, PSShowComputerName, RunspaceId; + +return $ret; diff --git a/src/Directory.Build.props b/src/Directory.Build.props index abaf7d6..1aef14b 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,9 +1,8 @@ - 1.0.1 - 1.0.1 : - 1. Add README.md file in nuget package. - 2. Add Blazor Hybrid on WPF example. + 1.0.2-preview + 1.0.2 : + Add Blazor Hybrid on Windows Forms example. true