mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Create checksum files
This commit is contained in:
parent
6fb8ca8494
commit
a21eeefdca
3 changed files with 48 additions and 3 deletions
|
@ -23,8 +23,12 @@ after_build:
|
|||
artifacts:
|
||||
- path: ShareX-*-setup.exe
|
||||
name: Setup
|
||||
- path: ShareX-*-setup.exe.sha256
|
||||
name: Setup-Checksum
|
||||
- path: ShareX-*-portable.zip
|
||||
name: Portable
|
||||
- path: ShareX-*-portable.zip.sha256
|
||||
name: Portable-Checksum
|
||||
- path: ShareX-Steam
|
||||
name: Steam
|
||||
- path: ShareX.appx
|
||||
|
@ -36,7 +40,7 @@ deploy:
|
|||
description: "[Changelog](https://getsharex.com/changelog)"
|
||||
auth_token:
|
||||
secure: bbUkNvyu1jnKkuZGlM1ois3MkmpCMlm3Lv68L9V5AYepHt1SG4ZQ15ZoKfjOFg9R
|
||||
artifact: Setup,Portable
|
||||
artifact: Setup,Setup-Checksum,Portable,Portable-Checksum
|
||||
draft: false
|
||||
prerelease: true
|
||||
on:
|
||||
|
|
|
@ -1644,5 +1644,35 @@ public static Icon GetProgressIcon(int percentage, Color color)
|
|||
return Icon.FromHandle(bmp.GetHicon());
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetChecksum(string filePath)
|
||||
{
|
||||
using (SHA256Managed hashAlgorithm = new SHA256Managed())
|
||||
{
|
||||
return GetChecksum(filePath, hashAlgorithm);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetChecksum(string filePath, HashAlgorithm hashAlgorithm)
|
||||
{
|
||||
using (FileStream fs = File.OpenRead(filePath))
|
||||
{
|
||||
byte[] hash = hashAlgorithm.ComputeHash(fs);
|
||||
return BitConverter.ToString(hash).Replace("-", "");
|
||||
}
|
||||
}
|
||||
|
||||
public static string CreateChecksumFile(string filePath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
|
||||
{
|
||||
string checksum = GetChecksum(filePath);
|
||||
string outputFilePath = filePath + ".sha256";
|
||||
File.WriteAllText(outputFilePath, checksum);
|
||||
return outputFilePath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,8 +47,9 @@ private enum SetupJobs
|
|||
CreateWindowsStoreDebugFolder = 1 << 7,
|
||||
CompileAppx = 1 << 8,
|
||||
DownloadFFmpeg = 1 << 9,
|
||||
CreateChecksumFile = 1 << 10,
|
||||
|
||||
Stable = CreateSetup | CreatePortable | OpenOutputDirectory,
|
||||
Stable = CreateSetup | CreatePortable | CreateChecksumFile | OpenOutputDirectory,
|
||||
Setup = CreateSetup | OpenOutputDirectory,
|
||||
Portable = CreatePortable | OpenOutputDirectory,
|
||||
Steam = CreateSteamFolder | OpenOutputDirectory,
|
||||
|
@ -56,7 +57,7 @@ private enum SetupJobs
|
|||
WindowsStoreDebug = CreateWindowsStoreDebugFolder,
|
||||
PortableApps = CreatePortableAppsFolder | OpenOutputDirectory,
|
||||
Beta = CreateSetup | UploadOutputFile,
|
||||
AppVeyorRelease = CreateSetup | CreatePortable,
|
||||
AppVeyorRelease = CreateSetup | CreatePortable | CreateChecksumFile,
|
||||
AppVeyorSteam = CreateSteamFolder,
|
||||
AppVeyorWindowsStore = CreateWindowsStoreFolder | CompileAppx,
|
||||
AppVeyorSteamRelease = AppVeyorSteam | DownloadFFmpeg,
|
||||
|
@ -198,6 +199,16 @@ private static void Main(string[] args)
|
|||
CreateFolder(ReleaseDir, PortableAppsOutputDir, SetupJobs.CreatePortableAppsFolder);
|
||||
}
|
||||
|
||||
if (Job.HasFlag(SetupJobs.CreateChecksumFile))
|
||||
{
|
||||
Console.WriteLine("Creating checksum files.");
|
||||
|
||||
foreach (string file in Directory.GetFiles(OutputDir))
|
||||
{
|
||||
Helpers.CreateChecksumFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (AppVeyor)
|
||||
{
|
||||
Helpers.CopyAll(OutputDir, ParentDir);
|
||||
|
|
Loading…
Reference in a new issue