Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
appveyor deploy on tag, windows show on download completed, added opt…
Browse files Browse the repository at this point in the history
…ion for autoupdates
  • Loading branch information
teocomi committed Dec 2, 2018
1 parent 23d5325 commit c52fe59
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,5 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
Speckle.exe
SpeckleDynamo/
SpeckleRhino/
7 changes: 5 additions & 2 deletions SpeckleInstaller.iss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ VersionInfoVersion={#AppVersion}
Name: "english"; MessagesFile: "compiler:Default.isl"

[Components]
Name: updater; Description: SpeckleUpdater - v{#AppVersion}; Types: full custom; Flags: fixed
Name: updater; Description: Speckle Updater - v{#AppVersion}; Types: full custom; Flags: fixed
Name: dynamo; Description: Speckle for Dynamo 2.0 - v{#DynamoVersion}; Types: full
Name: gh; Description: Speckle for Rhino 6 & Grasshopper - v{#RhinoVersion}; Types: full
;Name: excel; Description: Speckle for Revit; Types: full
Expand All @@ -45,6 +45,9 @@ Name: gh; Description: Speckle for Rhino 6 & Grasshopper - v{#RhinoVersion}; Ty
Name: "full"; Description: "Full installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Tasks]
Name: updates; Description: "Check for updates at startup, make sure I always have the best Speckle!";

[Dirs]
Name: "{app}"; Permissions: everyone-full

Expand All @@ -69,7 +72,7 @@ Root: HKCU; Subkey: "SOFTWARE\McNeel\Rhinoceros\6.0\Plug-ins\512d9705-6f92-49ca-

[Icons]
Name: "{group}\Check for updates"; Filename: "{#SpeckleFolder}\{#UpdaterFilename}"
Name: "{userappdata}\Microsoft\Windows\Start Menu\Programs\Startup\Speckle"; Filename: "{#SpeckleFolder}\{#UpdaterFilename}"
Name: "{userappdata}\Microsoft\Windows\Start Menu\Programs\Startup\Speckle"; Filename: "{#SpeckleFolder}\{#UpdaterFilename}"; Tasks: updates
Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
;Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

Expand Down
29 changes: 24 additions & 5 deletions SpeckleUpdater/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
xmlns:local="clr-namespace:SpeckleUpdater"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Speckle updater"
Width="300"
Height="300"
Width="380"
Height="380"
Background="#007fff"
BorderThickness="0"
Icon="speckle.ico"
Expand All @@ -18,10 +18,29 @@
<Grid>
<StackPanel Orientation="Vertical">
<Image Width="300" Source="logo.png" />
<Label
<TextBlock
Name="UpdateMessage"
Width="160"
HorizontalAlignment="Center"
Content="Checking for updates..."
Foreground="White" />
Foreground="White"
Text="Speckle v1.0.0.0 is available! Do you want to install it now?"
TextAlignment="Center"
TextWrapping="Wrap" />

<Button
Margin="10,15,10,10"
Click="Yes_Click"
Content="YES!"
FontWeight="Bold"
Foreground="White"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
<Button
Margin="0,0,0,20"
Click="No_Click"
Content="No, I want an old Speckle"
Foreground="White"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />

</StackPanel>

</Grid>
Expand Down
48 changes: 28 additions & 20 deletions SpeckleUpdater/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
using static SpeckleUpdater.GitHub;

namespace SpeckleUpdater
{
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{

private string _path = "";

public MainWindow()
{
InitializeComponent();
this.Hide();
Expand All @@ -36,30 +39,22 @@ private async void CheckForUpdates()
return;
}

this.Show();

var folder = Path.Combine(Path.GetTempPath(), Globals.AppName);
var path = System.IO.Path.Combine(folder, Globals.InstallerName);
_path = Path.Combine(folder, Globals.InstallerName);

//don't download if already there
if(!File.Exists(path) || !IsSameVersion(release.tag_name))
if (!File.Exists(_path) || !AlreadyDownloaded(release.tag_name))
{
await Api.DownloadRelease(release.assets.First(x => x.name == Globals.InstallerName).browser_download_url, folder, path);
await Api.DownloadRelease(release.assets.First(x => x.name == Globals.InstallerName).browser_download_url, folder, _path);
}

if (!File.Exists(path))
//double check!
if (!File.Exists(_path))
{
this.Close();
return;
}

MessageBoxResult response = MessageBox.Show("Speckle " + release.tag_name + " is available!\nDo you want to install it now?", "Speckle Updater (~˘▾˘)~", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
if(response == MessageBoxResult.Yes)
{
//launch the installer
Process.Start(path);
}
this.Close();
this.Show();
UpdateMessage.Text = $"Speckle {release.tag_name} is available! Do you want to install it now?";
}

private bool UpdateAvailable(Release release)
Expand All @@ -80,15 +75,28 @@ private bool UpdateAvailable(Release release)
return true;
}

private bool IsSameVersion(string version)

private bool AlreadyDownloaded(string version)
{
var current = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
FileVersionInfo fileInfo = FileVersionInfo.GetVersionInfo(_path);
var v = Version.Parse(version.Replace("v", ""));
var current = Version.Parse(fileInfo.FileVersion);
if (current.CompareTo(v) == 0)
{
return true;
}
return false;
}

private void Yes_Click(object sender, RoutedEventArgs e)
{
Process.Start(_path);
this.Close();
}

private void No_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
6 changes: 2 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# General Configuration
version: 1.1.0.{build}
skip_branch_with_pr: true
skip_tags: true

# Environment Configuration
image: Visual Studio 2017
Expand Down Expand Up @@ -97,9 +96,8 @@ deploy:
artifact: Speckle.exe
draft: false
prerelease: true
on:
branch: master # release from master branch only
appveyor_repo_tag: false # deploy on tag push only
on: # release from master branch only
appveyor_repo_tag: true # deploy on tag push only

notifications:
- provider: Slack
Expand Down

0 comments on commit c52fe59

Please sign in to comment.