-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
386215b
commit 3f491cd
Showing
5 changed files
with
105 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
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: Commit wwwroot to GitHub Pages | ||
uses: JamesIves/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: gh-pages | ||
FOLDER: samples/BlazorWebAssemblyApp/bin/root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ benchmarks/data/results/*.md | |
_ReSharper.Caches/ | ||
.idea | ||
.logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Publish Blazor example" type="DotNetProject" factoryName=".NET Project"> | ||
<option name="EXE_PATH" value="$PROJECT_DIR$/build/bin/roslyn4.3/Debug/net8.0/build.exe" /> | ||
<option name="PROGRAM_PARAMETERS" value="publish" /> | ||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> | ||
<option name="PASS_PARENT_ENVS" value="1" /> | ||
<option name="USE_EXTERNAL_CONSOLE" value="0" /> | ||
<option name="USE_MONO" value="0" /> | ||
<option name="RUNTIME_ARGUMENTS" value="" /> | ||
<option name="PROJECT_PATH" value="$PROJECT_DIR$/build/build.csproj" /> | ||
<option name="PROJECT_EXE_PATH_TRACKING" value="1" /> | ||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" /> | ||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="0" /> | ||
<option name="PROJECT_KIND" value="DotNetCore" /> | ||
<option name="PROJECT_TFM" value="net8.0" /> | ||
<method v="2"> | ||
<option name="Build" /> | ||
</method> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// 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<int> | ||
{ | ||
public Task InitializeAsync() => commands.Register( | ||
this, | ||
"Publish balazor web sssembly example", | ||
"publish", | ||
"pb"); | ||
|
||
[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] | ||
public async Task<int> RunAsync(CancellationToken cancellationToken) | ||
{ | ||
var projectPath = Path.Combine("samples", "BlazorWebAssemblyApp"); | ||
var rootPath = Path.Combine("bin", "root"); | ||
var result = await new DotNetPublish() | ||
.WithWorkingDirectory(projectPath) | ||
.WithConfiguration("Release") | ||
.WithOutput(rootPath) | ||
.RunAsync(cancellationToken: cancellationToken); | ||
|
||
var wwwrootPath = Path.Combine(projectPath, rootPath, "wwwroot"); | ||
|
||
// Change the base-tag in index.html from '/' to 'BlazorWebAssemblyApp' to match GitHub Pages repository subdirectory | ||
var indexFile = Path.Combine(wwwrootPath, "index.html"); | ||
var indexContent = await File.ReadAllTextAsync(indexFile, cancellationToken); | ||
indexContent = indexContent.Replace("""<base href="/" />""", """<base href="/Pure.DI/" />"""); | ||
await File.WriteAllTextAsync(indexFile, indexContent, cancellationToken); | ||
|
||
// Copy index.html to 404.html to serve the same file when a file is not found | ||
File.Copy(indexFile, Path.Combine(wwwrootPath, "404.html")); | ||
|
||
// Add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore) | ||
await File.AppendAllTextAsync(Path.Combine(wwwrootPath, ".nojekyll"), "", cancellationToken); | ||
|
||
return result ?? 1; | ||
} | ||
} |