From 7eb7f73ce2b89943c5397d5e2999a7b881fc87ac Mon Sep 17 00:00:00 2001 From: Nikolay Pianikov Date: Fri, 8 Mar 2024 13:02:15 +0300 Subject: [PATCH] Publish Blazor example --- .github/workflows/main.yml | 41 +++++++++++++++++++++-------- .gitignore | 1 + .run/Publish Blazor example.run.xml | 20 ++++++++++++++ build/Program.cs | 28 +++++++++++--------- build/PublishBlazorTarget.cs | 31 ++++++++++++++++++++++ 5 files changed, 98 insertions(+), 23 deletions(-) create mode 100644 .run/Publish Blazor example.run.xml create mode 100644 build/PublishBlazorTarget.cs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dce44f287..4dd1bfdac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,19 +1,38 @@ name: Pure.DI check -on: [push] +on: [ push ] jobs: build: runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.0.x' - - name: Build and check - run: dotnet run --project ./build -- check + steps: + - uses: actions/checkout@v4 + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + #- name: Build and check + #run: dotnet run --project ./build -- check + + - name: Publish Blazor example + run: dotnet run --project ./build -- publish + + - name: Change base-tag in index.html from / to BlazorGitHubPagesDemo + run: sed -i 's///g' wwwroot/index.html + + - name: copy index.html to 404.html + run: cp wwwroot/index.html wwwroot/404.html + + - name: Add .nojekyll file + run: touch wwwroot/.nojekyll + + - name: Commit wwwroot to GitHub Pages + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: wwwroot diff --git a/.gitignore b/.gitignore index b6ba230ca..b7028c6a3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ benchmarks/data/results/*.md _ReSharper.Caches/ .idea .logs +wwwroot diff --git a/.run/Publish Blazor example.run.xml b/.run/Publish Blazor example.run.xml new file mode 100644 index 000000000..a10e319e5 --- /dev/null +++ b/.run/Publish Blazor example.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/build/Program.cs b/build/Program.cs index e37959403..45dc9e32c 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -2,20 +2,24 @@ DI.Setup(nameof(Composition)) .Root("RootTarget") + .DefaultLifetime(Lifetime.PerBlock) - .Bind().To() - .Bind().To() + + .Bind().To() + .Bind().To() .Bind().To(_ => GetService()) - .Bind().To(_ => GetService()) + .Bind().To(_ => GetService()) + // Targets - .Bind>(typeof(GeneratorTarget)).To() - .Bind>>(typeof(LibrariesTarget)).To() - .Bind>>(typeof(CompatibilityCheckTarget)).To() - .Bind>>(typeof(PackTarget)).To() - .Bind(typeof(ReadmeTarget)).To() - .Bind>(typeof(BenchmarksTarget)).To() - .Bind(typeof(DeployTarget)).To() - .Bind(typeof(TemplateTarget)).To() - .Bind(typeof(UpdateTarget)).To(); + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To(); return await new Composition().RootTarget.RunAsync(CancellationToken.None); \ No newline at end of file diff --git a/build/PublishBlazorTarget.cs b/build/PublishBlazorTarget.cs new file mode 100644 index 000000000..ca7cf0344 --- /dev/null +++ b/build/PublishBlazorTarget.cs @@ -0,0 +1,31 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable HeapView.DelegateAllocation +// ReSharper disable HeapView.ClosureAllocation +// ReSharper disable ClassNeverInstantiated.Global +// ReSharper disable ReturnTypeCanBeEnumerable.Local +// ReSharper disable InvertIf + +namespace Build; + +internal class PublishBlazorTarget( + Commands commands) + : IInitializable, ITarget +{ + public Task InitializeAsync() => commands.Register( + this, + "Publish balazor web sssembly example", + "publish", + "pb"); + + [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] + public async Task RunAsync(CancellationToken cancellationToken) + { + var result = await new DotNetPublish() + .WithProject(Path.Combine("samples", "BlazorWebAssemblyApp", "BlazorWebAssemblyApp.csproj")) + .WithConfiguration("Release") + .WithOutput("wwwroot") + .RunAsync(cancellationToken: cancellationToken); + + return result ?? 1; + } +} \ No newline at end of file