From a85f2f18edcf1e6e592c42e560a539a28f39dc81 Mon Sep 17 00:00:00 2001 From: PocketMiner82 Date: Tue, 9 Apr 2024 15:07:20 +0200 Subject: [PATCH] feat: add update to beta button --- .releaserc | 2 +- pseudocodeIde/PseudocodeIDEForm.Designer.cs | 30 ++++++++++++++------- pseudocodeIde/PseudocodeIDEForm.cs | 15 +++++++---- pseudocodeIdeUpdater/Program.cs | 21 +++++++++++++-- 4 files changed, 50 insertions(+), 18 deletions(-) diff --git a/.releaserc b/.releaserc index 19403ad..a45df7b 100644 --- a/.releaserc +++ b/.releaserc @@ -52,7 +52,7 @@ "pseudocodeIde/pseudocodeIde.csproj" ], "from": ".*", - "to": "${nextRelease.version.split('-')[0]}", + "to": "${nextRelease.version.replace('-dev', '')}", "countMatches": true } ] diff --git a/pseudocodeIde/PseudocodeIDEForm.Designer.cs b/pseudocodeIde/PseudocodeIDEForm.Designer.cs index b412e42..58a74a3 100644 --- a/pseudocodeIde/PseudocodeIDEForm.Designer.cs +++ b/pseudocodeIde/PseudocodeIDEForm.Designer.cs @@ -52,7 +52,8 @@ private void InitializeComponent() this.helpMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.updatePseudocodeIDEMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.updateMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.updateBetaMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.codeTextBox = new ScintillaNET.Scintilla(); this.autoCompleteMenu = new AutocompleteMenuNS.AutocompleteMenu(); this.menuStrip.SuspendLayout(); @@ -239,7 +240,8 @@ private void InitializeComponent() this.helpMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.showHelpMenuItem, this.toolStripSeparator3, - this.updatePseudocodeIDEMenuItem}); + this.updateMenuItem, + this.updateBetaMenuItem}); this.helpMenuItem.Name = "helpMenuItem"; this.helpMenuItem.Size = new System.Drawing.Size(64, 29); this.helpMenuItem.Text = "Hilfe"; @@ -248,21 +250,28 @@ private void InitializeComponent() // this.showHelpMenuItem.Name = "showHelpMenuItem"; this.showHelpMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F1; - this.showHelpMenuItem.Size = new System.Drawing.Size(346, 34); + this.showHelpMenuItem.Size = new System.Drawing.Size(415, 34); this.showHelpMenuItem.Text = "Hilfe anzeigen"; this.showHelpMenuItem.Click += new System.EventHandler(this.showHelpMenuItem_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(343, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(412, 6); // - // updatePseudocodeIDEMenuItem + // updateMenuItem // - this.updatePseudocodeIDEMenuItem.Name = "updatePseudocodeIDEMenuItem"; - this.updatePseudocodeIDEMenuItem.Size = new System.Drawing.Size(346, 34); - this.updatePseudocodeIDEMenuItem.Text = "Pseudocode IDE aktualisieren"; - this.updatePseudocodeIDEMenuItem.Click += new System.EventHandler(this.updatePseudocodeIDEMenuItem_Click); + this.updateMenuItem.Name = "updateMenuItem"; + this.updateMenuItem.Size = new System.Drawing.Size(415, 34); + this.updateMenuItem.Text = "Pseudocode IDE aktualisieren"; + this.updateMenuItem.Click += new System.EventHandler(this.updateMenuItem_Click); + // + // updateBetaMenuItem + // + this.updateBetaMenuItem.Name = "updateBetaMenuItem"; + this.updateBetaMenuItem.Size = new System.Drawing.Size(415, 34); + this.updateBetaMenuItem.Text = "Pseudocode IDE auf Beta aktualisieren"; + this.updateBetaMenuItem.Click += new System.EventHandler(this.updateBetaMenuItem_Click); // // codeTextBox // @@ -352,11 +361,12 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem openOutputFormMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripMenuItem updatePseudocodeIDEMenuItem; + private System.Windows.Forms.ToolStripMenuItem updateMenuItem; private ScintillaNET.Scintilla codeTextBox; private System.Windows.Forms.ToolStripMenuItem goToMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private AutocompleteMenuNS.AutocompleteMenu autoCompleteMenu; + private System.Windows.Forms.ToolStripMenuItem updateBetaMenuItem; } } diff --git a/pseudocodeIde/PseudocodeIDEForm.cs b/pseudocodeIde/PseudocodeIDEForm.cs index 26819cd..34b4000 100644 --- a/pseudocodeIde/PseudocodeIDEForm.cs +++ b/pseudocodeIde/PseudocodeIDEForm.cs @@ -124,7 +124,7 @@ private void PseudocodeIDEForm_Load(object sender, EventArgs e) FileSystem.CopyDirectory(Path.Combine(currentDir, "updater"), tempExeDir, true); // show remind later - this.checkForUpdate(true); + this.checkForUpdate(true, false); // set font this.configureCodeTextBox(); @@ -801,13 +801,13 @@ private void showHelpMenuItem_Click(object sender, EventArgs e) // (AUTO) UPDATE // --------------------------------------------- - private void updatePseudocodeIDEMenuItem_Click(object sender, EventArgs e) + private void updateMenuItem_Click(object sender, EventArgs e) { // dont show remind later - this.checkForUpdate(false); + this.checkForUpdate(false, false); } - private void checkForUpdate(bool firstRun) + private void checkForUpdate(bool firstRun, bool beta) { string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string tempExeDir = Path.Combine(Path.GetTempPath(), "pseudocode-ide\\updater"); @@ -818,10 +818,15 @@ private void checkForUpdate(bool firstRun) { compiler.StartInfo.FileName = tempExePath; compiler.StartInfo.WorkingDirectory = tempExeDir; - compiler.StartInfo.Arguments = $"\"{currentDir}\" \"{firstRun}\""; + compiler.StartInfo.Arguments = $"\"{currentDir}\" \"{firstRun}\" \"{beta}\""; compiler.StartInfo.UseShellExecute = true; compiler.Start(); } } + + private void updateBetaMenuItem_Click(object sender, EventArgs e) + { + this.checkForUpdate(false, true); + } } } diff --git a/pseudocodeIdeUpdater/Program.cs b/pseudocodeIdeUpdater/Program.cs index d9902ac..912c879 100644 --- a/pseudocodeIdeUpdater/Program.cs +++ b/pseudocodeIdeUpdater/Program.cs @@ -24,6 +24,7 @@ static void Main(string[] args) { string path = args[0]; bool firstRun = bool.Parse(args[1]); + bool beta = bool.Parse(args[2]); if (!firstRun) { @@ -41,9 +42,25 @@ static void Main(string[] args) AutoUpdater.ExecutablePath = "pseudocode-ide.exe"; Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; - AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}"); + + if (assemblyVersion.Revision > 0) + { + // beta release + AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}.{assemblyVersion.Revision}"); + } + else if (assemblyVersion.Revision > 0 && !beta) + { + // hack to allow to go back to stable release, as the last version tag (pre release count) will be missing + // without this hack, the AutoUpdater would think that the new release is a lower version than this + AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major - 1}.{assemblyVersion.Minor}.{assemblyVersion.Build}"); + } + else + { + // stable release + AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}"); + } - AutoUpdater.Start("https://raw.githubusercontent.com/PocketMiner82/pseudocode-ide/main/AutoUpdater.xml"); + AutoUpdater.Start($"https://raw.githubusercontent.com/PocketMiner82/pseudocode-ide/{(beta ? "dev" : "main")}/AutoUpdater.xml"); } catch