[skip ci] Newly add certain architecture releases and enable compression.

This commit is contained in:
BruceChen 2023-02-02 15:36:02 +08:00
parent 3735cab9dd
commit 4f608687ee
3 changed files with 199 additions and 64 deletions

View file

@ -9,12 +9,12 @@ on:
env:
PROJECT: "MinecraftClient"
target-version: "net7.0"
compile-flags: "--self-contained=true -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None"
compile-flags: "--self-contained=true -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -p:DebugType=None"
jobs:
Build:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'SKIP_BUILD') }}
if: ${{ !contains(github.event.head_commit.message, 'skip ci') }}
timeout-minutes: 15
steps:
@ -48,11 +48,15 @@ jobs:
- name: Setup Output Paths
run: |
echo win-x64-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/win-x64/publish/ >> $GITHUB_ENV
echo win-x86-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/win-x86/publish/ >> $GITHUB_ENV
echo linux-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/linux-x64/publish/ >> $GITHUB_ENV
echo osx-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/osx-x64/publish/ >> $GITHUB_ENV
echo win-x64-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/win-x64/publish/ >> $GITHUB_ENV
echo win-arm32-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/win-arm/publish/ >> $GITHUB_ENV
echo win-arm64-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/win-arm64/publish/ >> $GITHUB_ENV
echo linux-x64-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/linux-x64/publish/ >> $GITHUB_ENV
echo linux-arm32-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/linux-arm/publish/ >> $GITHUB_ENV
echo linux-arm64-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/linux-arm64/publish/ >> $GITHUB_ENV
echo osx-x64-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/osx-x64/publish/ >> $GITHUB_ENV
echo osx-arm64-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/osx-arm64/publish/ >> $GITHUB_ENV
- name: Setup .NET SDK
uses: actions/setup-dotnet@v2.1.0
@ -68,15 +72,9 @@ jobs:
run: |
COMMIT=$(echo ${{ github.sha }} | cut -c 1-7)
echo '' >> ${{ env.project-path }}/Properties/AssemblyInfo.cs
echo build-version-info=${{ steps.date-version.outputs.time }}-${{ github.run_number }} >> $GITHUB_ENV
echo "[assembly: AssemblyConfiguration(\"GitHub build ${{ github.run_number }}, built on ${{ steps.date-version.outputs.time }} from commit $COMMIT\")]" >> ${{ env.project-path }}/Properties/AssemblyInfo.cs
- name: Build for Windows x64
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r win-x64 ${{ env.compile-flags }}
- name: Zip Windows x64 Build
run: zip -qq -r windows-x64.zip *
working-directory: ${{ env.win-x64-out-path }}
- name: Build for Windows x86
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r win-x86 ${{ env.compile-flags }}
@ -84,26 +82,45 @@ jobs:
run: zip -qq -r windows-x86.zip *
working-directory: ${{ env.win-x86-out-path }}
- name: Build for Linux
- name: Build for Windows x64
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r win-x64 ${{ env.compile-flags }}
- name: Zip Windows x64 Build
run: zip -qq -r windows-x64.zip *
working-directory: ${{ env.win-x64-out-path }}
- name: Build for Windows ARM32
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r win-arm ${{ env.compile-flags }}
- name: Build for Windows ARM64
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r win-arm64 ${{ env.compile-flags }}
- name: Build for Linux X64
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r linux-x64 ${{ env.compile-flags }}
- name: Zip Linux Build
- name: Zip Linux X64 Build
run: zip -qq -r linux.zip *
working-directory: ${{ env.linux-out-path }}
working-directory: ${{ env.linux-x64-out-path }}
- name: Build for ARM64 Linux
- name: Build for Linux ARM32
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r linux-arm ${{ env.compile-flags }}
- name: Build for Linux ARM64
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r linux-arm64 ${{ env.compile-flags }}
- name: Zip ARM64 Linux Build
run: zip -qq -r linux-arm64.zip *
working-directory: ${{ env.linux-arm64-out-path }}
- name: Build for OSX
- name: Build for OSX X64
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r osx-x64 ${{ env.compile-flags }}
- name: Zip OSX Build
run: zip -qq -r osx.zip *
working-directory: ${{ env.osx-out-path }}
working-directory: ${{ env.osx-x64-out-path }}
- name: Build for OSX ARM64
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r osx-arm64 ${{ env.compile-flags }}
- name: Get Release DateTime
id: date-release
@ -112,7 +129,88 @@ jobs:
timeZone: 0
format: 'YYYYMMDD'
- name: Windows x64 Release
- name: Windows X86 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.win-x86-out-path }}${{ env.PROJECT }}.exe
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-Windows-X86.exe
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Windows X64 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.win-x64-out-path }}${{ env.PROJECT }}.exe
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-Windows-X64.exe
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Windows ARM32 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.win-arm32-out-path }}${{ env.PROJECT }}.exe
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-Windows-Arm32.exe
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Windows ARM64 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.win-arm64-out-path }}${{ env.PROJECT }}.exe
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-Windows-Arm64.exe
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Linux X64 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.linux-x64-out-path }}${{ env.PROJECT }}
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-Linux-X64
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Linux ARM32 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.linux-arm32-out-path }}${{ env.PROJECT }}
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-Linux-Arm32
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Linux ARM64 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.linux-arm64-out-path }}${{ env.PROJECT }}
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-Linux-Arm64
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: OSX X64 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.osx-x64-out-path }}${{ env.PROJECT }}
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-OSX-X64
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: OSX ARM64 Release
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.win-x64-out-path }}windows-x64.zip
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-OSX-Arm64
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Windows X64 Release (transition version)
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
@ -121,7 +219,7 @@ jobs:
assetName: ${{ env.PROJECT }}-windows-x64.zip
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Windows x86 Release
- name: Windows X86 Release (transition version)
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
@ -130,16 +228,16 @@ jobs:
assetName: ${{ env.PROJECT }}-windows-x86.zip
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Linux Release
- name: Linux X64 Release (transition version)
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.linux-out-path }}linux.zip
filePath: ${{ env.linux-x64-out-path }}linux.zip
assetName: ${{ env.PROJECT }}-linux.zip
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: Linux ARM64 Release
- name: Linux ARM64 Release (transition version)
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
@ -148,12 +246,12 @@ jobs:
assetName: ${{ env.PROJECT }}-linux-arm64.zip
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
- name: OSX Release
- name: OSX X64 Release (transition version)
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.osx-out-path }}osx.zip
filePath: ${{ env.osx-x64-out-path }}osx.zip
assetName: ${{ env.PROJECT }}-osx.zip
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}

View file

@ -2157,7 +2157,9 @@ namespace MinecraftClient
{
if (windowId != 0)
inventories.Remove(windowId);
return handler.SendCloseWindow(windowId);
bool result = handler.SendCloseWindow(windowId);
DispatchBotEvent(bot => bot.OnInventoryClose(windowId));
return result;
}
return false;
}

View file

@ -125,31 +125,45 @@ namespace MinecraftClient
try
{
string downloadUrl = $"{GithubReleaseUrl}/download/{latestVersion}/MinecraftClient-{OSInfo}.zip";
string downloadUrl = $"{GithubReleaseUrl}/download/{latestVersion}/";
string fileNameWithoutExtension = $"MinecraftClient-{latestVersion}-{OSInfo}";
string fileName = fileNameWithoutExtension + GetExecutableFileExtension();
downloadStartTime = DateTime.Now;
lastNotifyTime = DateTime.MinValue;
lastBytesTransferred = 0;
using HttpResponseMessage response = await httpClient.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
using Stream zipFileStream = await response.Content.ReadAsStreamAsync(cancellationToken);
if (!cancellationToken.IsCancellationRequested)
bool hasFile = true;
HttpResponseMessage response = await httpClient.GetAsync(downloadUrl + fileName, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
if (!response.IsSuccessStatusCode)
{
using ZipArchive zipArchive = new(zipFileStream, ZipArchiveMode.Read);
ConsoleIO.WriteLine(Translations.mcc_update_download_complete);
foreach (var archiveEntry in zipArchive.Entries)
fileName = fileNameWithoutExtension + ".zip";
response = await httpClient.GetAsync(downloadUrl + fileName, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
if (!response.IsSuccessStatusCode)
{
if (archiveEntry.Name.StartsWith("MinecraftClient"))
hasFile = false;
ConsoleIO.WriteLine($"{Translations.mcc_update_download_fail} File {fileNameWithoutExtension}{GetExecutableFileExtension()} not found.");
}
}
if (hasFile)
{
string fileName = $"MinecraftClient-{latestVersion}{Path.GetExtension(archiveEntry.Name)}";
archiveEntry.ExtractToFile(fileName, true);
using (FileStream fileStream = File.Create(fileName))
{
await response.Content.CopyToAsync(fileStream);
}
ConsoleIO.WriteLineFormatted("§e" + string.Format(Translations.mcc_update_save_as, fileName), true);
break;
}
}
zipArchive.Dispose();
if (!OperatingSystem.IsWindows())
File.SetUnixFileMode(fileName, UnixFileMode.UserRead
| UnixFileMode.UserWrite
| UnixFileMode.UserExecute
| UnixFileMode.GroupRead
| UnixFileMode.GroupExecute
| UnixFileMode.OtherRead
| UnixFileMode.OtherExecute);
}
zipFileStream.Dispose();
response.Dispose();
}
catch (TaskCanceledException) { }
@ -225,25 +239,46 @@ namespace MinecraftClient
private static string GetOSIdentifier()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
return "linux-arm64";
else if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
return "linux";
}
string OSPlatformName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
OSPlatformName = "Windows";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
OSPlatformName = "Linux";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
OSPlatformName = "OSX";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
OSPlatformName = "FreeBSD";
else
return string.Empty;
string architecture = RuntimeInformation.ProcessArchitecture switch
{
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
return "osx";
Architecture.X86 => "X86",
Architecture.X64 => "X64",
Architecture.Arm => "Arm32",
Architecture.Arm64 => "Arm64",
Architecture.Wasm => "Wasm",
Architecture.S390x => "S390x",
Architecture.LoongArch64 => "LoongArch64",
Architecture.Armv6 => "Armv6",
Architecture.Ppc64le => "Ppc64le",
_ => RuntimeInformation.ProcessArchitecture.ToString(),
};
return OSPlatformName + '-' + architecture;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
private static string GetExecutableFileExtension()
{
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
return "windows-x64";
else if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
return "windows-x86";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return ".exe";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
return string.Empty;
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return string.Empty;
else if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
return string.Empty;
else
return string.Empty;
}