Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #9

Merged
merged 2 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ function Restore-Packages
& dotnet restore
}

function Update-AssemblyInfo($version)
{
$versionPattern = "[0-9]+(\.([0-9]+|\*)){3}"

foreach ($file in ls ./src/*/Properties/AssemblyInfo.cs)
{
(cat $file) | foreach {
% {$_ -replace $versionPattern, "$version.0" }
} | sc -Encoding "UTF8" $file
}
}

function Update-WixVersion($version)
{
$defPattern = "define Version = ""0\.0\.0"""
Expand All @@ -31,20 +19,16 @@ function Update-WixVersion($version)
} | sc -Encoding "UTF8" $product
}

function Execute-MSBuild
function Execute-MSBuild($version)
{
& msbuild ./piggy.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64
& msbuild ./piggy.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:VersionPrefix=$version
if($LASTEXITCODE -ne 0) { exit 2 }
}

function Execute-Tests
{
pushd ./test/Datalust.Piggy.Tests

& dotnet test -c Release
& dotnet test ./test/Datalust.Piggy.Tests/Datalust.Piggy.Tests.csproj -c Release /p:Configuration=Release /p:Platform=x64 /p:VersionPrefix=$version
if($LASTEXITCODE -ne 0) { exit 3 }

popd
}

function Create-ArtifactDir
Expand All @@ -56,39 +40,45 @@ function Publish-Gzips($version)
{
$rids = @("ubuntu.14.04-x64", "ubuntu.16.04-x64", "rhel.7-x64", "osx.10.12-x64")
foreach ($rid in $rids) {
& dotnet publish src/Datalust.Piggy/Datalust.Piggy.csproj -c Release -r $rid
if($LASTEXITCODE -ne 0) { exit 3 }
& dotnet publish src/Datalust.Piggy/Datalust.Piggy.csproj -c Release -r $rid /p:VersionPrefix=$version
if($LASTEXITCODE -ne 0) { exit 4 }

# Make sure the archive contains a reasonable root filename
mv ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/publish/ ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/piggy-$version-$rid/

& ./build/7-zip/7za.exe a -ttar piggy-$version-$rid.tar ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/piggy-$version-$rid/
if($LASTEXITCODE -ne 0) { exit 3 }
if($LASTEXITCODE -ne 0) { exit 5 }

# Back to the original directory name
mv ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/piggy-$version-$rid/ ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/publish/

& ./build/7-zip/7za.exe a -tgzip ./artifacts/piggy-$version-$rid.tar.gz piggy-$version-$rid.tar
if($LASTEXITCODE -ne 0) { exit 3 }
if($LASTEXITCODE -ne 0) { exit 6 }

rm piggy-$version-$rid.tar
}
}

function Publish-Msi($version)
{
& dotnet publish src/Datalust.Piggy/Datalust.Piggy.csproj -c Release -r win10-x64 /p:VersionPrefix=$version
if($LASTEXITCODE -ne 0) { exit 7 }

& msbuild ./setup/Datalust.Piggy.Setup/Datalust.Piggy.Setup.wixproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:Version=$version
if($LASTEXITCODE -ne 0) { exit 8 }

mv ./setup/Datalust.Piggy.Setup/bin/Release/piggy.msi ./artifacts/piggy-$version.msi
}

Push-Location $PSScriptRoot

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "0.0.0" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
Write-Output "Building version $version"

Clean-Output
Restore-Packages
Update-AssemblyInfo($version)
Update-WixVersion($version)
Execute-MSBuild
Execute-MSBuild($version)
Execute-Tests
Create-ArtifactDir
Publish-Gzips($version)
Expand Down
14 changes: 0 additions & 14 deletions piggy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,30 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8250E09A-7479-4322-A251-DABFD9F129B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8250E09A-7479-4322-A251-DABFD9F129B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8250E09A-7479-4322-A251-DABFD9F129B6}.Debug|x64.ActiveCfg = Debug|x64
{8250E09A-7479-4322-A251-DABFD9F129B6}.Debug|x64.Build.0 = Debug|x64
{8250E09A-7479-4322-A251-DABFD9F129B6}.Debug|x86.ActiveCfg = Debug|Any CPU
{8250E09A-7479-4322-A251-DABFD9F129B6}.Debug|x86.Build.0 = Debug|Any CPU
{8250E09A-7479-4322-A251-DABFD9F129B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8250E09A-7479-4322-A251-DABFD9F129B6}.Release|Any CPU.Build.0 = Release|Any CPU
{8250E09A-7479-4322-A251-DABFD9F129B6}.Release|x64.ActiveCfg = Release|x64
{8250E09A-7479-4322-A251-DABFD9F129B6}.Release|x64.Build.0 = Release|x64
{8250E09A-7479-4322-A251-DABFD9F129B6}.Release|x86.ActiveCfg = Release|Any CPU
{8250E09A-7479-4322-A251-DABFD9F129B6}.Release|x86.Build.0 = Release|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Debug|x64.ActiveCfg = Debug|x64
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Debug|x64.Build.0 = Debug|x64
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Debug|x86.ActiveCfg = Debug|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Debug|x86.Build.0 = Debug|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Release|Any CPU.Build.0 = Release|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Release|x64.ActiveCfg = Release|x64
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Release|x64.Build.0 = Release|x64
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Release|x86.ActiveCfg = Release|Any CPU
{E3291CB6-F4A9-4A01-9E65-B70E2A32B0D5}.Release|x86.Build.0 = Release|Any CPU
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|Any CPU.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x86.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|Any CPU.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|Any CPU.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x86.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 0 additions & 1 deletion setup/Datalust.Piggy.Setup/Datalust.Piggy.Setup.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<Error Text="The WiX Toolset v4 build tools must be installed to build this project. To download the WiX Toolset v4, see http://wixtoolset.org/releases/" />
</Target>
<Target Name="BeforeBuild">
<Exec Command="dotnet publish ..\..\src\Datalust.Piggy\Datalust.Piggy.csproj -c $(Configuration) -r win10-x64" />
<PropertyGroup>
<LinkerBaseInputPaths>..\..\src\Datalust.Piggy\bin\$(Configuration)\netcoreapp1.1\win10-x64\publish</LinkerBaseInputPaths>
<DefineConstants>BasePath=..\..\src\Datalust.Piggy\bin\$(Configuration)\netcoreapp1.1\win10-x64\publish</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion setup/Datalust.Piggy.Setup/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?ifndef Version?>
<?define Version = "0.0.0" ?>
<?define Version = "99.99.99" ?>
<?endif ?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
Expand Down
8 changes: 7 additions & 1 deletion src/Datalust.Piggy/Cli/Commands/VersionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ class VersionCommand : Command
{
protected override int Run()
{
var version = typeof(VersionCommand).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
var version = GetVersion();
Console.WriteLine(version);
return 0;
}

public static string GetVersion()
{
return typeof(VersionCommand).GetTypeInfo().Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
}
}
}
19 changes: 19 additions & 0 deletions test/Datalust.Piggy.Tests/Cli/Commands/VersionCommandTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Datalust.Piggy.Cli.Commands;
using Xunit;

namespace Datalust.Piggy.Tests.Cli.Commands
{
public class VersionCommandTests
{
#if !DEBUG
[Fact]
public void VersionIsSet()
{
var version = VersionCommand.GetVersion();
Assert.False(string.IsNullOrEmpty(version));
Assert.NotEqual("1.0.0", version);
Assert.NotEqual("0.0.0", version);
}
#endif
}
}
2 changes: 0 additions & 2 deletions test/Datalust.Piggy.Tests/Datalust.Piggy.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
Expand Down