Skip to content

Commit

Permalink
update CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
windperson committed Aug 25, 2022
1 parent fd3b711 commit eac631d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 13 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -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 }}"

automatic_release_tag: "${{ steps.get_version.outputs.version_str }}"
prerelease: true
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish to nuget
name: "1. publish to nuget"
on:
workflow_dispatch:

Expand All @@ -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 Condition=\" \'\$\(Version\)\'==\'\' \">(.*)<\/Version>\s*$
TAG_COMMIT: false
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
INCLUDE_SYMBOLS: true
48 changes: 48 additions & 0 deletions scripts/get_build_version.ps1
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 3 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project>
<PropertyGroup>
<Version Condition=" '$(Version)'=='' ">1.0.1</Version>
<PackageReleaseNotes>1.0.1 :
&#xD;&#xA; 1. Add README.md file in nuget package.
&#xD;&#xA; 2. Add Blazor Hybrid on WPF example.
<Version Condition=" '$(Version)'=='' ">1.0.2-preview</Version>
<PackageReleaseNotes>1.0.2 :
&#xD;&#xA; Add Blazor Hybrid on Windows Forms example.
</PackageReleaseNotes>
<Deterministic>true</Deterministic>
</PropertyGroup>
Expand Down

0 comments on commit eac631d

Please sign in to comment.