Skip to content

Commit

Permalink
Merge pull request #107 from yatima1460/createreleaseci
Browse files Browse the repository at this point in the history
Update build.yml
  • Loading branch information
yatima1460 authored May 15, 2024
2 parents 24dcf56 + 29283cf commit ba5ff40
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 16 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,28 @@ jobs:
with:
dotnet-version: 8.0.x

- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2

- name: Build win-x64
run: dotnet publish WinForms\WinForms.csproj /p:Configuration=Release /p:Platform=x64 /p:SelfContained=true /p:PublishSingleFile=true /p:PublishReadyToRun=true /p:TargetFramework=net8.0-windows /p:RuntimeIdentifier=win-x64 /p:PublishDir=publish
run: Build_win-x64.bat
shell: cmd

- name: Upload win-x64
uses: actions/upload-artifact@v4
with:
name: Drill_win-x64
path: WinForms\publish
path: bin\Drill_win-x64.exe
if-no-files-found: error


- name: Create a Release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: bin\Drill_win-x64.exe


#- name: Build MAUI
# run: dotnet publish --maxCpuCount -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None .\Drill\Drill.csproj

Expand Down
28 changes: 28 additions & 0 deletions Build_win-x64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off

dotnet clean -maxCpuCount WinForms\WinForms.csproj
if %ERRORLEVEL% neq 0 (
echo Cleaning failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

dotnet publish -maxCpuCount WinForms\WinForms.csproj /p:DebugType=None /p:DebugSymbols=False /p:Configuration=Release /p:Platform=x64 /p:EnableCompressionInSingleFile=true /p:CopyOutputSymbolsToPublishDirectory=false /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=false /p:SelfContained=true /p:PublishSingleFile=true /p:PublishReadyToRun=true /p:TargetFramework=net8.0-windows /p:RuntimeIdentifier=win-x64 /p:PublishDir=%CD%\bin
if %ERRORLEVEL% neq 0 (
echo Publishing failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

move bin\Drill.exe bin\Drill_win-x64.exe
if %ERRORLEVEL% neq 0 (
echo Moving file failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

dir bin\Drill_win-x64.exe
if %ERRORLEVEL% neq 0 (
echo Directory listing failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

echo Script completed successfully.
exit /b 0
4 changes: 3 additions & 1 deletion Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>



<ItemGroup>
<None Remove="words_alpha.txt" />
<EmbeddedResource Include="words_alpha.txt" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 12 additions & 9 deletions Core/Heuristics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@ internal static class Heuristics

static Heuristics()
{
string? path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (path == null)
var assembly = Assembly.GetExecutingAssembly();
var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(name => name.EndsWith("words_alpha.txt"));

if (resourceName == null)
{
Console.WriteLine("Executing assembly path is null???");
Console.WriteLine("Can't find words dictionary in embedded resources");
dict = [];
return;
}
var DictPath = Path.Combine(path, "words_alpha.txt");
if (!File.Exists(DictPath))

using var stream = assembly.GetManifestResourceStream(resourceName);
if (stream != null)
{
Console.WriteLine("Can't find words dictionary");
dict = [];
return;
using var reader = new StreamReader(stream);
dict = reader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToImmutableHashSet<string>();
}
dict = [.. File.ReadAllLines(DictPath)];

dict = [];
}


Expand Down

0 comments on commit ba5ff40

Please sign in to comment.