aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs97
1 files changed, 11 insertions, 86 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs
index 1a289ff50..526d4465a 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs
@@ -10,7 +10,6 @@ using System.Threading.Tasks;
using Tango.AdvancedInstaller;
using Tango.Core;
using Tango.Core.Helpers;
-using Tango.Git;
using Tango.PMR.FirmwareUpgrade;
using Tango.PPC.Common.Web;
using Tango.SQLExaminer;
@@ -60,11 +59,14 @@ namespace Tango.PPC.Common.Publish
/// Gets the latest version.
/// </summary>
/// <returns></returns>
- public async Task<LatestVersionResponse> GetRemoteVersion(String machineVersionGuid)
+ public async Task<String> GetRemoteVersion(String machineVersionGuid)
{
_client.Environment = Options.Environment;
- var response = await _client.GetLatestVersion(new LatestVersionRequest() { MachineVersionGuid = machineVersionGuid });
- return response;
+ var response = await _client.GetLatestVersion(new LatestVersionRequest()
+ {
+ MachineVersionGuid = machineVersionGuid,
+ });
+ return response.Version;
}
/// <summary>
@@ -161,12 +163,8 @@ namespace Tango.PPC.Common.Publish
OnPublishProgress(0, 100, $"Fetching remote version from {Options.Environment.ToAddress()}...");
- var r = GetRemoteVersion(Options.MachineVersionGuid).Result;
- String remote_version = r.Version;
- String remote_firmware_version = r.FirmwareVersion;
-
+ String remote_version = GetRemoteVersion(Options.MachineVersionGuid).Result;
String local_version = GetLocalVersion();
- String local_firmware_version = GetLocalFirmwareVersion(Options.TfpPath);
OnPublishProgress(0, 100, $"Remote version: {remote_version}");
OnPublishProgress(0, 100, $"Local version: {local_version}");
@@ -176,11 +174,6 @@ namespace Tango.PPC.Common.Publish
throw new InvalidOperationException($"The local version '{local_version}' is not greater than the remote version '{remote_version}'.");
}
- if (Version.Parse(local_firmware_version) < Version.Parse(remote_firmware_version))
- {
- throw new InvalidOperationException($"The local firmware version '{local_firmware_version}' is not greater than the remote version '{remote_firmware_version}'.");
- }
-
OnPublishProgress(0, 100, $"Requesting version upload...");
var response = _client.UploadVersion(new UploadVersionRequest()
@@ -192,7 +185,6 @@ namespace Tango.PPC.Common.Publish
FirmwareVersion = GetVersionInfoFromTFP(Options.TfpPath).FileDescriptors.SingleOrDefault(x => x.Destination == VersionFileDestination.Mcu).Version,
}).Result;
- CreateTupPackage(tempFile).Wait();
if (!String.IsNullOrWhiteSpace(Options.InstallerProject))
{
@@ -218,6 +210,8 @@ namespace Tango.PPC.Common.Publish
}
}
+ CreateTupPackage(tempFile).Wait();
+
OnPublishProgress(0, 100, $"Starting version upload...");
using (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress, tempFile))
@@ -240,7 +234,7 @@ namespace Tango.PPC.Common.Publish
Token = response.Token,
}).Wait();
- remote_version = GetRemoteVersion(Options.MachineVersionGuid).Result.Version;
+ remote_version = GetRemoteVersion(Options.MachineVersionGuid).Result;
local_version = GetLocalVersion();
OnPublishProgress(0, 0, $"Remote version: {remote_version}");
@@ -251,55 +245,6 @@ namespace Tango.PPC.Common.Publish
throw new InvalidOperationException("The remote version does not seems to have been updated.");
}
- if (Options.CreateTag)
- {
- String repoPath = Path.GetFullPath("../../../../../");
- String tagVersion = System.Version.Parse(GetLocalVersion()).ToString(3);
- String tagName = $"PPC_v{tagVersion}";
-
- using (GitRepositoryManager git = new GitRepositoryManager(repoPath, Options.Email, Options.PersonalAccessToken))
- {
- OnPublishProgress(0, 100, "Checking repository changes...");
- int changes = git.GetChanges().Count;
- if (changes > 0)
- {
- if (Options.AutoCommitAndPush)
- {
- OnPublishProgress(0, 100, "Committing repository changes...");
- git.Commit(tagName);
- }
- else
- {
- throw new InvalidOperationException($"There are {changes} uncommitted changes on the repository. Please commit and push all changes before creating the Tag");
- }
- }
-
- OnPublishProgress(0, 100, "Checking outgoing commits...");
- int commits = git.GetOutgoingCommits().Count;
- if (commits > 0)
- {
- if (Options.AutoCommitAndPush)
- {
- OnPublishProgress(0, 100, "Pushing repository changes...");
- git.Sync();
- }
- else
- {
- throw new InvalidOperationException($"There are {commits} outgoing commits on the repository. Please push all commits before creating the Tag");
- }
- }
-
- git.Progress += (x, e) =>
- {
- OnPublishProgress(e.Progress.Value, e.Progress.Maximum, $"Pushing Tag '{tagName}'...");
- };
-
- OnPublishProgress(0, 100, $"Creating Tag '{tagName}'...");
-
- git.CreatePushTag(tagName, Options.Comments, "Roy Ben Shabat");
- }
- }
-
OnPublishProgress(0, 0, "Version published successfully.");
}
catch (Exception ex)
@@ -344,21 +289,13 @@ namespace Tango.PPC.Common.Publish
using (ZipFile zip = new ZipFile())
{
- zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
-
- if (Options.BuildConfig != "Debug")
- {
- zip.AddFile(Options.TfpPath, "/").FileName = "firmware_package.tfp";
- }
+ zip.AddFile(Options.TfpPath, "/").FileName = "firmware_package.tfp";
PublishInfo versionInfo = new PublishInfo();
versionInfo.ApplicationVersion = GetLocalVersion();
versionInfo.Comments = Options.Comments;
versionInfo.Firmware = GetVersionInfoFromTFP(Options.TfpPath);
- //Validate the package.
- versionInfo.Firmware.Validate();
-
var versionInfoFile = TemporaryManager.CreateImaginaryFile();
File.WriteAllText(versionInfoFile, versionInfo.ToJson());
zip.AddFile(versionInfoFile, "/").FileName = "version.json";
@@ -425,8 +362,6 @@ namespace Tango.PPC.Common.Publish
var cuf = zip.AddFile(update_config_file, update_dir);
cuf.FileName = update_dir + "\\config.xml";
- zip.AddDirectory(folder + "\\" + "Packages", "/Packages");
-
foreach (var file in Directory.GetFiles(folder, "*.*", SearchOption.TopDirectoryOnly))
{
zip.AddFile(file, "/");
@@ -469,16 +404,6 @@ namespace Tango.PPC.Common.Publish
}
/// <summary>
- /// Gets the MCU version from the specified TFP file.
- /// </summary>
- /// <param name="tfpFile">The TFP file.</param>
- /// <returns></returns>
- public String GetLocalFirmwareVersion(String tfpFile)
- {
- return GetVersionInfoFromTFP(tfpFile).GetMcuVersion().ToString();
- }
-
- /// <summary>
/// Raises the publish progress event.
/// </summary>
/// <param name="progress">The progress.</param>