Skip to content

Commit

Permalink
Convert release script to Powershell
Browse files Browse the repository at this point in the history
Also, generate documentation with Sandcastle Help File Builder.
  • Loading branch information
oschwald committed Sep 16, 2016
1 parent 732eb8c commit 21136e2
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 122 deletions.
2 changes: 1 addition & 1 deletion MaxMind.MinFraud/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"version": "0.7.1",
"name": "MaxMind.MinFraud",
"description": "API for MaxMind minFraud Score and Insights web services",
Expand Down
105 changes: 105 additions & 0 deletions dev-bin/release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
$ErrorActionPreference = 'Stop'
$DebugPreference = 'Continue'

$projectJsonFile=(Get-Item "MaxMind.MinFraud/project.json").FullName
$matches = (Get-Content -Encoding UTF8 releasenotes.md) ` |
Select-String '(\d+\.\d+\.\d+(?:-\w+)?) \((\d{4}-\d{2}-\d{2})\)' `

$version = $matches.Matches.Groups[1].Value
$date = $matches.Matches.Groups[2].Value

if((Get-Date -format 'yyyy-MM-dd') -ne $date ) {
Write-Error "$date is not today!"
exit 1
}

$tag = "v$version"

if (& git status --porcelain) {
Write-Error '. is not clean'
}

# Not using Powershell's built-in JSON support as that
# reformats the file.
(Get-Content -Encoding UTF8 $projectJsonFile) `
-replace '(?<=version"\s*:\s*")[^"]+', $version ` |
Out-File -Encoding UTF8 $projectJsonFile


& git diff

if ((Read-Host -Prompt 'Continue? (y/n)') -ne 'y') {
Write-Error 'Aborting'
}

if (-Not(& git status --porcelain)) {
& git add $projectJsonFile
& git commit -m "Prepare for $version"
}

Push-Location MaxMind.MinFraud

& dotnet restore
& dotnet build -c Release
& dotnet pack -c Release

Pop-Location

Push-Location MaxMind.MinFraud.UnitTest

& dotnet restore
& dotnet test -c Release

Pop-Location

if ((Read-Host -Prompt 'Continue given tests? (y/n)') -ne 'y') {
Write-Error 'Aborting'
}

if (Test-Path .gh-pages ) {
Write-Debug "Updating .gh-pages"
Push-Location .gh-pages
& git pull
} else {
Write-Debug "Checking out gh-pages in .gh-pages"
& git clone -b gh-pages git@github.com:maxmind/minfraud-api-dotnet.git .gh-pages
Push-Location .gh-pages
}

if (& git status --porcelain) {
Write-Error '.gh-pages is not clean'
}
Pop-Location

$page = '.gh-pages\index.md'

@"
---
layout: default
title: MaxMind minFraud Score and Insights .NET API
language: dotnet
version: $tag
---
"@ | Out-File -Encoding UTF8 -Append $page

Get-Content -Encoding UTF8 'README.md' | Out-File -Encoding UTF8 -Append $page

& MSBuild.exe .\minfraud.shfbproj /p:OutputPath=.gh-pages\doc\$tag

Push-Location .gh-pages

& git add doc/
& git commit -m "Updated for $tag" -a

if ((Read-Host -Prompt 'Should push? (y/n)') -ne 'y') {
Write-Error 'Aborting'
}

& git push

Pop-Location
& git tag "$tag"
& git push
& git push --tags

& nuget push "MaxMind.MinFraud/bin/Release/MaxMind.MinFraud.$version.nupkg"
121 changes: 0 additions & 121 deletions dev-bin/release.sh

This file was deleted.

80 changes: 80 additions & 0 deletions minfraud.shfbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- The configuration and platform will be used to determine which assemblies to include from solution and
project documentation sources -->
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5c4e3997-080a-4de1-a850-ea1e14543cb5}</ProjectGuid>
<SHFBSchemaVersion>2015.6.5.0</SHFBSchemaVersion>
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual Studio adds them anyway -->
<AssemblyName>Documentation</AssemblyName>
<RootNamespace>Documentation</RootNamespace>
<Name>Documentation</Name>
<!-- SHFB properties -->
<FrameworkVersion>.NET Framework 4.5</FrameworkVersion>
<OutputPath>Help\</OutputPath>
<HtmlHelpName>Documentation</HtmlHelpName>
<Language>en-US</Language>
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
<HelpFileFormat>Website</HelpFileFormat>
<IndentHtml>False</IndentHtml>
<KeepLogFile>True</KeepLogFile>
<DisableCodeBlockComponent>False</DisableCodeBlockComponent>
<CleanIntermediates>True</CleanIntermediates>
<DocumentationSources>
<DocumentationSource sourceFile="MaxMind.MinFraud\bin\Release\net45\MaxMind.MinFraud.xml" />
<DocumentationSource sourceFile="MaxMind.MinFraud\bin\Release\net45\MaxMind.MinFraud.dll" />
<DocumentationSource sourceFile="..\GeoIP2-dotnet\GeoIP2\bin\Release\net45\MaxMind.GeoIP2.dll" />
<DocumentationSource sourceFile="..\GeoIP2-dotnet\GeoIP2\bin\Release\net45\MaxMind.GeoIP2.xml" />
<DocumentationSource sourceFile="..\MaxMind-DB-Reader-dotnet\MaxMind.Db\bin\Release\net45\MaxMind.Db.dll" />
<DocumentationSource sourceFile="..\MaxMind-DB-Reader-dotnet\MaxMind.Db\bin\Release\net45\MaxMind.Db.xml" /></DocumentationSources>
<HelpFileVersion>1.0.0.0</HelpFileVersion>
<MaximumGroupParts>2</MaximumGroupParts>
<NamespaceGrouping>True</NamespaceGrouping>
<SyntaxFilters>Standard</SyntaxFilters>
<SdkLinkTarget>Blank</SdkLinkTarget>
<RootNamespaceContainer>True</RootNamespaceContainer>
<PresentationStyle>VS2013</PresentationStyle>
<Preliminary>False</Preliminary>
<NamingMethod>MemberName</NamingMethod>
<HelpTitle>MaxMind.MinFraud Library</HelpTitle>
<ContentPlacement>AboveNamespaces</ContentPlacement>
</PropertyGroup>
<!-- There are no properties for these groups. AnyCPU needs to appear in order for Visual Studio to perform
the build. The others are optional common platform types that may appear. -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
</PropertyGroup>
<!-- Import the SHFB build targets -->
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
<!-- The pre-build and post-build event properties must appear *after* the targets file import in order to be
evaluated correctly. -->
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="MaxMind.MinFraud\MaxMind.MinFraud.xproj">
<Name>MaxMind.MinFraud</Name>
<Project>7208D9C8-F862-4675-80E5-77A2F8901B96</Project>
</ProjectReference>
</ItemGroup>
</Project>

0 comments on commit 21136e2

Please sign in to comment.