Skip to content

Commit

Permalink
Re-enable build-nuget.yml | Nightly builds (#5309)
Browse files Browse the repository at this point in the history
* Re-enable build-nuget.yml

* Add a build step that executes a powershell command to replace js version number

* build-nuget comment push nuget for now

* build-nuget set workflow_dispatch for now

* use windows-latest

* remove echo tag

* try on push instead

* hard code version for now

* Drop powershell version | Use a MSBuild C# based task

* go back to ubuntu

* Add additional debug info

* add automatic version number

* Build version as 1.5.0 | Package version as 1.5.0-dev-buildnumber

* Just use the $(Version) | We should make sure we set the $(Version) correctly.

* MatchExpression change to match ?v= with or without digits | Build entire solution for js file changes | Add Try Catch to Task

* Remove powershell commented version | Rename Task to ReplaceVersionInJsFiles

* MatchExpression | Adjust so not only digits are matched, but a -followed by any chars too

* Enable Nuget Push | artifact v3

* Run on Schedule | At 20:00, only on Friday

* add workflow_dispatch

* comment nuget publish | re-add push for tests

* Experiment with using regular version & package version

* ReplaceVersionInJsFiles | Remove extra line

* Set the BUILD_VERSION to 1.5.0.0 for proper js version replacement

* Can we simplify the env vars?

* Can we simplify the env vars?

* Move PACKAGE_VERSION to the step. Env $BUILD_VERSION is not available at the top

* disable some steps to test faster.

* Need to use long version

* adjust env placement

* Re-add all steps & publish

* Remove pipeline on push

* update checkout & setup-dotnet to v4 | Install multiple .NET version in a single step | Re-enable pipeline on push to test changes

* Remove pipeline on push

* Redo bulma modal.js and rebuild

* ReplaceVersionInJsFiles | Adjust so the file only gets written if there's a regex match & the version value is different

* Fix the version back to 1.4.2.0

* Set version as 1.4.2 | ReplaceVersionInJsFiles | Expect only Files & version to replace | Try to always have a version with at least 4 version groups | Empty groups will be 0

* Autoformat Blazorise.props

* Update help.md

* revert js files to originals

* Revert js files

* Revert chart js

---------

Co-authored-by: Mladen Macanovic <[email protected]>
Co-authored-by: Mladen Macanovic <[email protected]>
  • Loading branch information
3 people authored Feb 16, 2024
1 parent c3b70ee commit 8ac5241
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 107 deletions.
54 changes: 0 additions & 54 deletions .github/disabled-workflows/build-nuget.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/build-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: NuGet Build

on:
schedule:
- cron: "0 20 * * 5"
workflow_dispatch:

env:
BUILD_VERSION: '1.5.0.0'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Restore NuGet Packages
run: dotnet restore

- name: Build - Release
run: dotnet build --configuration Release --no-restore /p:Version=$BUILD_VERSION

- name: Run Unit Tests - Release
run: dotnet test ./Tests/Blazorise.Tests/Blazorise.Tests.csproj --configuration Release --no-restore --no-build --verbosity normal

- name: Prepare E2E Tests Dependencies
run: pwsh ./Tests/Blazorise.E2E.Tests/bin/Release/net8.0/playwright.ps1 install --with-deps

- name: Run E2E Tests - Release
run: dotnet test ./Tests/Blazorise.E2E.Tests/Blazorise.E2E.Tests.csproj --configuration Release --no-restore --no-build --verbosity normal

- name: Pack - Release
run: dotnet pack --configuration Release --no-restore -o ./Packages /p:Version=$BUILD_VERSION /p:PackageVersion=$PACKAGE_VERSION
env:
PACKAGE_VERSION: ${{ env.BUILD_VERSION }}-dev-${{ github.run_number }}

- name: Push - Release
run: dotnet nuget push ./Packages/ -s https://www.myget.org/F/blazorise/api/v3/index.json -k ${{ secrets.MYGET_API_KEY }}

- name: Upload Blazorise.Components
uses: actions/upload-artifact@v3
with:
name: Blazorise-Packages
path: ./Packages/
190 changes: 139 additions & 51 deletions Build/Blazorise.props
Original file line number Diff line number Diff line change
@@ -1,64 +1,152 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>1.4.2</Version>
<PackageVersion>1.4.2</PackageVersion>
<PropertyGroup>
<Version>1.4.2</Version>
<PackageVersion>1.4.2</PackageVersion>

<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageIcon>Blazorise.png</PackageIcon>
<PackageProjectUrl>https://blazorise.com/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Megabit/Blazorise</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageIcon>Blazorise.png</PackageIcon>
<PackageProjectUrl>https://blazorise.com/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Megabit/Blazorise</RepositoryUrl>
<RepositoryType>git</RepositoryType>

<Description>Blazorise is a component library built on top of Blazor and CSS frameworks like Bootstrap, Bulma and Material.</Description>
<Authors>Megabit</Authors>
<Company>Megabit</Company>
<Copyright>Copyright 2018-2024 Megabit</Copyright>

<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<LangVersion>10.0</LangVersion>
<Description>Blazorise is a component library built on top of Blazor and CSS frameworks like Bootstrap, Bulma and Material.</Description>
<Authors>Megabit</Authors>
<Company>Megabit</Company>
<Copyright>Copyright 2018-2024 Megabit</Copyright>

<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<LangVersion>10.0</LangVersion>

<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

<ItemGroup>
<Content Remove="package.json" />
<None Include="package.json" />
</ItemGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>

<ItemGroup>
<Content Remove="package.json" />
<None Include="package.json" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<DefineConstants>$(DefineConstants);NET6_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<DefineConstants>$(DefineConstants);NET6_0</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<DefineConstants>$(DefineConstants);NET7_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<DefineConstants>$(DefineConstants);NET7_0</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<DefineConstants>$(DefineConstants);NET8_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<DefineConstants>$(DefineConstants);NET8_0</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="6.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="6.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.*" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="7.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="7.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.*" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.*" />
</ItemGroup>

<UsingTask
TaskName="ReplaceVersionInJsFiles"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<SourceFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<Version ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System"/>
<Using Namespace="System.IO"/>
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage(MessageImportance.High, $"------ Custom Build Step : ReplaceVersionInJsFiles : [{SourceFiles.Count()}] files ------");
var matchExpression = @"\?v=([\d.]*-?\w+-?\d*)";
var expectedVersion = string.Empty;;
try {
string[] versionGroups = Version.Split('.');
if (versionGroups.Length < 4)
{
expectedVersion = string.Empty;
for (int i = 0; i < 4; i++)
{
if (i>0)
{
expectedVersion += ".";
}
if (versionGroups.Length > i)
{
expectedVersion += $"{versionGroups[i]}";
}
else
{
expectedVersion += $"0";
}
}
}
else
{
expectedVersion = Version;
}
}
catch (Exception ex)
{
Log.LogMessage(MessageImportance.High, $"------ Custom Build Step : ReplaceVersionInJsFiles : Unable to resolve version : Exception : [{ex.Message}] ------");
return false;
}
var replacementText = $"?v={expectedVersion}";
Log.LogMessage(MessageImportance.High, $"------ Custom Build Step : ReplaceVersionInJsFiles : Match : [{matchExpression}] | Replace : [{replacementText}] ------");
try {
foreach (ITaskItem item in SourceFiles)
{
string fileName = item.ItemSpec;
Log.LogMessage(MessageImportance.High, "------ Custom Build Step : ReplaceVersionInJsFiles : Evaluating File '{0}'.", fileName);
var fileContent = File.ReadAllText(fileName);
var regexMatch = Regex.Match(fileContent, matchExpression);
if (regexMatch.Success && regexMatch.Value != replacementText)
{
Log.LogMessage(MessageImportance.High, "------ Custom Build Step : ReplaceVersionInJsFiles : Updating File '{0}'.", fileName);
File.WriteAllText(fileName, Regex.Replace(File.ReadAllText(fileName), matchExpression, replacementText).Trim());
}
}
}
catch (Exception ex)
{
Log.LogMessage(MessageImportance.High, $"------ Custom Build Step : ReplaceVersionInJsFiles : Exception : [{ex.Message}] ------");
}
]]>
</Code>
</Task>
</UsingTask>

<Target Name="BeforeBuildStep" BeforeTargets="Build">
<ItemGroup>
<JsFiles Include='wwwroot\*.js' />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.*" />
</ItemGroup>
<ReplaceVersionInJsFiles
SourceFiles="@(JsFiles)"
Version="$(Version)" />
</Target>
</Project>
6 changes: 4 additions & 2 deletions NuGet/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ Before creating NuGet packages make sure that documentation is updated to match
1. Update release notes
2. Update _readme.md_
3. Update quick start & usage pages if necessary
4. Update version number in the demo home-page
5. Make sure that Blazor version number is matching the one in *.props files
4. Make sure that Blazor version number is matching the one in *.props files

## Nugets

### Update project files

1. Open Blazorise.props file in the Build folder and raise the version numbers.
1.1 Update the Version number with the expected assembly version. I.E: 1.5.0
1.1.1 It's important to keep the version number with the format [0.0.0] or [0.0.0.0] as the JS files are using this format to determine the version.
1.2 Update the PackageVersion number with the expected package version. I.E: 1.5.0-preview-1

### Build & Publish

Expand Down

0 comments on commit 8ac5241

Please sign in to comment.