Skip to content

Commit

Permalink
Merge pull request #137 from Code52/hello-squirrel
Browse files Browse the repository at this point in the history
Move from ClickOnce to Squirrel.Windows
  • Loading branch information
shiftkey authored May 15, 2017
2 parents fef48d6 + 4172ffe commit c4d9773
Show file tree
Hide file tree
Showing 45 changed files with 533 additions and 5,306 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ deploy-to-ec2*
*.orig
Thumbs.db
src/Carnac.sln.ide/

# Cake - Uncomment if you are using it
tools/**
!tools/packages.config
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ You can install the latest version of Carnac via [Chocolatey](https://chocolatey
cinst carnac
```

Alternatively, you can grab the latest zip file from [here](https://github.com/Code52/carnac/releases/latest) and unpack it.
Alternatively, you can grab the latest zip file from [here](https://github.com/Code52/carnac/releases/latest), unpack it and run `Setup.exe`.

**Note:** Carnac requires .NET 4.5.2 to work - you can install that from [here](https://www.microsoft.com/en-au/download/details.aspx?id=42643) if you don't have it already.

### Updating

We use `Squirrel.Windows` to update your `carnac` application.

The application will check for updates in the background, if a new version has been released, it will automatically install the new version and once you restart `carnac` you will be up-to-date.

### Usage

** Enabling silent mode **
Expand Down
19 changes: 15 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.0.0.{build}
version: 2.1.{build}
configuration: Release
skip_branch_with_pr: true
skip_tags: true
Expand All @@ -11,16 +11,20 @@ assembly_info:
environment:
Version: $(APPVEYOR_BUILD_VERSION)
GithubRepo: $(APPVEYOR_REPO_NAME)
GithubAuthToken:
secure: tvr7i0kJpT3SAdYG037M6zU1g6FYXHAUUaseqBTUzasqsUo6mumdcW+huf5/351p
build_script:
- build.cmd Release
- cmd: PowerShell -Version 2.0 .\build.ps1 -Configuration Release -Experimental -ScriptArgs '--packageversion="%APPVEYOR_BUILD_VERSION%" --authtoken="%GithubAuthToken%"'
test:
assemblies:
- '**\Carnac.Tests.dll'
artifacts:
- path: deploy\*.nupkg
- path: deploy\Chocolatey\*.nupkg
name: ChocoPackage
- path: deploy\*.zip
- path: deploy\GitHub\*.zip
name: ZipPackage
- path: deploy\Squirrel\Releases\*
name: SquirrelPackage
deploy:
- provider: GitHub
auth_token:
Expand All @@ -29,6 +33,13 @@ deploy:
draft: false
on:
branch: master
- provider: GitHub
auth_token:
secure: tvr7i0kJpT3SAdYG037M6zU1g6FYXHAUUaseqBTUzasqsUo6mumdcW+huf5/351p
artifact: SquirrelPackage
draft: false
on:
branch: master
- provider: NuGet
server: https://chocolatey.org/
api_key:
Expand Down
161 changes: 161 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#tool "nuget:?package=xunit.runners&version=1.9.2";
#tool "nuget:?package=Squirrel.Windows";

#addin Cake.FileHelpers
#addin Cake.Squirrel

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Debug");
var version = Argument("packageversion", "1.0.0");
var githubRepo = Argument("githubrepo", "Code52/carnac");
var githubAuthToken = Argument("authtoken", "");

var githubRepoUrl = $"https://github.com/{githubRepo}";
var solutionFile = "./src/Carnac.sln";
var buildDir = Directory("./src/Carnac/bin") + Directory(configuration);
var toolsDir = Directory("./tools");
var deployDir = Directory("./deploy");
var zipFileHash = "";

var squirrelDeployDir = deployDir + Directory("Squirrel");
var squirrelReleaseDir = squirrelDeployDir + Directory("Releases");

Task("Clean")
.Does(() =>
{
Func<IFileSystemInfo, bool> excludeSquirrelDir =
fileSystemInfo => !(fileSystemInfo.Path.FullPath.IndexOf("Squirrel", StringComparison.OrdinalIgnoreCase) >= 0);
CleanDirectory(buildDir);
CleanDirectory(deployDir, excludeSquirrelDir);
});

Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(solutionFile);
});

Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
MSBuild(solutionFile, settings =>
settings.SetConfiguration(configuration));
});

Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
XUnit($"./src/Carnac.Tests/bin/{configuration}/*.Tests.dll");
});

Task("Package-Squirrel")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
var syncReleasesDir = toolsDir + Directory("squirrel.windows/tools");
EnsureDirectoryExists(deployDir);
EnsureDirectoryExists(squirrelDeployDir);
// Create nuget package
var appFiles = GetFiles(buildDir.Path + "/**/*.*").Select(f => f.FullPath);
var deltaCompressionFiles = GetFiles($"{(toolsDir + Directory("DeltaCompressionDotNet/lib/net45")).Path}/*.dll").Select(f => f.FullPath);
var monoCecilFiles = GetFiles($"{(toolsDir + Directory("Mono.Cecil/lib/net45")).Path}/*.dll").Select(f => f.FullPath);
var splatFiles = GetFiles($"{(toolsDir + Directory("Splat/lib/Net45")).Path}/*.dll").Select(f => f.FullPath);
var iCSharpCodeFiles = GetFiles($"{(toolsDir + Directory("squirrel.windows/lib/Net45")).Path}/ICSharpCode.SharpZipLib.*").Select(f => f.FullPath);
var squirrelFiles = GetFiles($"{(toolsDir + Directory("squirrel.windows/lib/Net45")).Path}/*Squirrel.dll").Select(f => f.FullPath);
var releaseFiles = new HashSet<string>(
appFiles
.Concat(deltaCompressionFiles)
.Concat(monoCecilFiles)
.Concat(splatFiles)
.Concat(iCSharpCodeFiles)
.Concat(squirrelFiles)
);
releaseFiles.RemoveWhere(f => f.Contains(".vshost.") || f.EndsWith(".pdb"));
var nuGetPackSettings = new NuGetPackSettings
{
Version = version,
Files = releaseFiles.Select(f => new NuSpecContent { Source = f, Target = "lib/net45" + (f.Contains("Keymaps") ? "/Keymaps" : "") }).ToList(),
BasePath = buildDir,
OutputDirectory = squirrelDeployDir,
NoPackageAnalysis = true
};
NuGetPack("./src/Carnac/Carnac.nuspec", nuGetPackSettings);
// Sync latest release to build new package
var squirrelSyncReleasesExe = syncReleasesDir + File("SyncReleases.exe");
StartProcess(squirrelSyncReleasesExe, new ProcessSettings { Arguments = $"--url {githubRepoUrl} --releaseDir {squirrelReleaseDir.Path}{(!string.IsNullOrEmpty(githubAuthToken) ? " --token " + githubAuthToken : "")}" });
// Create new squirrel package
Squirrel(
squirrelDeployDir + File($"carnac.{version}.nupkg"),
new SquirrelSettings
{
ReleaseDirectory = squirrelReleaseDir,
NoMsi = true,
Icon = "./src/Carnac/icon.ico",
SetupIcon = "./src/Carnac/icon.ico",
ShortCutLocations = "StartMenu",
Silent = true
}
);
});

Task("Package-Zip")
.IsDependentOn("Package-Squirrel")
.Does(() =>
{
var gitHubDeployDir = deployDir + Directory("GitHub");
var zipFile = gitHubDeployDir + File($"carnac.{version}.zip");
EnsureDirectoryExists(deployDir);
EnsureDirectoryExists(gitHubDeployDir);
Zip(squirrelReleaseDir, zipFile);
zipFileHash = CalculateFileHash(zipFile, HashAlgorithm.SHA256).ToHex();
});

Task("Package-Choco")
.IsDependentOn("Package-Zip")
.Does(() =>
{
var chocoSourceDir = Directory("./src/Chocolatey");
var chocoToolsDir = chocoSourceDir + Directory("tools");
var chocoInstallFile = chocoToolsDir + File("chocolateyinstall.ps1");
var chocoSpecPath = chocoSourceDir + File("carnac.nuspec");
var chocoDeployDir = deployDir + Directory("Chocolatey");
EnsureDirectoryExists(deployDir);
EnsureDirectoryExists(chocoDeployDir);
var url = $"{githubRepoUrl}/releases/download/{version}";
ReplaceRegexInFiles(chocoInstallFile, @"\$url = '.+'", $"$url = '{url}/carnac.{version}.zip'");
ReplaceRegexInFiles(chocoInstallFile, @"\$zipFileHash = '.+'", $"$zipFileHash = '{zipFileHash}'");
ChocolateyPack(chocoSpecPath, new ChocolateyPackSettings
{
Version = version
});
MoveFiles("./*.nupkg", chocoDeployDir);
});

Task("Package")
.IsDependentOn("Package-Zip")
.IsDependentOn("Package-Squirrel")
.IsDependentOn("Package-Choco")
.Does(() =>
{
EnsureDirectoryExists(deployDir);
});

Task("Default")
.IsDependentOn("Package");

RunTarget(target);
8 changes: 0 additions & 8 deletions build.cmd

This file was deleted.

Loading

0 comments on commit c4d9773

Please sign in to comment.