Skip to content

Commit

Permalink
feat: add update to beta button
Browse files Browse the repository at this point in the history
  • Loading branch information
PocketMiner82 committed Apr 9, 2024
1 parent 671e0a3 commit a85f2f1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"pseudocodeIde/pseudocodeIde.csproj"
],
"from": "<version>.*</version>",
"to": "<version>${nextRelease.version.split('-')[0]}</version>",
"to": "<version>${nextRelease.version.replace('-dev', '')}</version>",
"countMatches": true
}
]
Expand Down
30 changes: 20 additions & 10 deletions pseudocodeIde/PseudocodeIDEForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions pseudocodeIde/PseudocodeIDEForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Expand All @@ -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);
}
}
}
21 changes: 19 additions & 2 deletions pseudocodeIdeUpdater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down

0 comments on commit a85f2f1

Please sign in to comment.