Skip to content

Commit

Permalink
New build/relwase script
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymholt committed Nov 13, 2017
1 parent ca5776f commit 01d1841
Show file tree
Hide file tree
Showing 27 changed files with 293 additions and 108 deletions.
15 changes: 15 additions & 0 deletions DbUp.Support.SqlServer.Scripting.userprefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Properties StartupConfiguration="{80136911-3220-460B-867D-E1C94E241248}|Default">
<MonoDevelop.Ide.Workbench ActiveDocument="DbUp.Support.SqlServer.Scripting.Console/packages.config">
<Files>
<File FileName="DbUp.Support.SqlServer.Scripting.Console/packages.config" Line="1" Column="1" />
<File FileName="DbUp.Support.SqlServer.Scripting/packages.config" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
<MonoDevelop.Ide.ItemProperties.DbUp.Support.SqlServer.Scripting.Console PreferredExecutionTarget="MonoDevelop.Default" />
<MultiItemStartupConfigurations />
</Properties>
4 changes: 0 additions & 4 deletions build/Gemfile

This file was deleted.

26 changes: 0 additions & 26 deletions build/Gemfile.lock

This file was deleted.

20 changes: 0 additions & 20 deletions build/README.md

This file was deleted.

50 changes: 0 additions & 50 deletions build/Rakefile

This file was deleted.

1 change: 0 additions & 1 deletion build/exclude.txt

This file was deleted.

Binary file removed build/nuget.exe
Binary file not shown.
7 changes: 0 additions & 7 deletions build/version.txt

This file was deleted.

11 changes: 11 additions & 0 deletions dbup-sqlserver-scripting.1.6.0/[Content_Types].xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
<Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
<Default Extension="nuspec" ContentType="application/octet" />
<Default Extension="dll" ContentType="application/octet" />
<Default Extension="config" ContentType="application/octet" />
<Default Extension="pdb" ContentType="application/octet" />
<Default Extension="psm1" ContentType="application/octet" />
<Default Extension="ps1" ContentType="application/octet" />
</Types>
5 changes: 5 additions & 0 deletions dbup-sqlserver-scripting.1.6.0/_rels/.rels
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Type="http://schemas.microsoft.com/packaging/2010/07/manifest" Target="/dbup-sqlserver-scripting.nuspec" Id="R20044d36f4da47b1" />
<Relationship Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="/package/services/metadata/core-properties/4dfc29f526184beca2892bca839033de.psmdcp" Id="Rd5971da503d64057" />
</Relationships>
23 changes: 23 additions & 0 deletions dbup-sqlserver-scripting.1.6.0/dbup-sqlserver-scripting.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>dbup-sqlserver-scripting</id>
<version>1.6.0</version>
<title>DbUp SQL Server Object Scripting</title>
<authors>Brady Holt</authors>
<owners>Brady Holt</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://raw.github.com/bradyholt/dbup-sqlserver-scripting/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/bradyholt/dbup-sqlserver-scripting</projectUrl>
<iconUrl>https://raw.github.com/DbUp/DbUp/master/src/Information/dbup-icon.png</iconUrl>
<description>Extends DbUp to provide SQL Server object definition scripting when running migrations from Visual Studio. When a database object changes during a migration, its definition will be saved in the project.</description>
<releaseNotes>v1.6.0 - Update library versions</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>dbup database migrations sqlserver scripting definitions scripts console</tags>
<dependencies>
<dependency id="dbup" version="3.2.1" />
<dependency id="dbup-consolescripts" version="1.0.9" />
<dependency id="Unofficial.Microsoft.SQLServer.SMO.2014" version="12.0.2000.8" />
</dependencies>
</metadata>
</package>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Diagnostics.STrace" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.100.0.0" newVersion="14.100.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<coreProperties xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.openxmlformats.org/package/2006/metadata/core-properties">
<dc:creator>Brady Holt</dc:creator>
<dc:description>Extends DbUp to provide SQL Server object definition scripting when running migrations from Visual Studio. When a database object changes during a migration, its definition will be saved in the project.</dc:description>
<dc:identifier>dbup-sqlserver-scripting</dc:identifier>
<version>1.6.0</version>
<keywords>dbup database migrations sqlserver scripting definitions scripts console</keywords>
<lastModifiedBy>NuGet, Version=4.3.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35;Unix 16.7.0.0;.NET Framework 4.5</lastModifiedBy>
</coreProperties>
File renamed without changes.
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/local/bin/jbash

/* Releases dbup-sqlserver-scripting
This includes: building in release mode, packaging, and publishing on
NuGet, creating a GitHub release, uploading .nupkg to GitHub release.
Example:
release.sh 2.0.0 "Fixed DOW bug causing exception" */

// Halt on an error
set("-e");

// cd to root dir
cd(`${__dirname}/../`);

if (args.length != 2) {
echo(`
Usage: release.sh version "Release notes..."
Example:
release.js 2.0.0 "Fixed bug causing exception"`);
exit(1);
}

if ($(`git status --porcelain`)) {
echo(`All changes must be committed first.`);
exit(1);
}

let projectId = "dbup-sqlserver-scripting";
let projectName = "DbUp.Support.SqlServer.Scripting";
let version = args[0];
let notes = args[1];
let preRelease = version.indexOf("-") > -1; // If version contains a '-' character (i.e. 2.0.0-alpha-1) we will consider this a pre-release
let projectCopyright = `Copyright ${(new Date).getFullYear()}`;
let ghRepo = "bradyholt/dbup-sqlserver-scripting";
let buildDirectory = "tmp";

// Restore NuGet pakcages and build in release mode
eval(`nuget restore`);
eval(`xbuild /property:Configuration=Release ${projectName}.sln`);

// Create NuGet package
eval(`mkdir -p ${buildDirectory}/pack/lib/net35`)
eval(`cp dbup-sqlserver-scripting.nuspec tmp/pack`)
eval(`cp -r tools dbup-sqlserver-scripting.nuspec ${buildDirectory}/pack/`)
eval(`cp -r ${projectName}/bin/Release/${projectName}.* ${buildDirectory}/pack/lib/net35`)
eval(`nuget pack ${buildDirectory}/pack/${projectId}.nuspec -Properties "version=${version};notes=v${version} - ${notes};copyright=${projectCopyright}" -OutputDirectory ${buildDirectory}`)
let nupkgFile = `${buildDirectory}/${projectId}.${version}.nupkg`;

// Push NuGet package
eval(`nuget push ${nupkgFile}`)

// Commit changes to project file
eval(`git commit -am "New release: ${version}"`);

// Create release tag
eval(`git tag -a ${version} -m "${notes}"`);
eval(`git push --follow-tags`);

// Create release on GitHub
let response = $(`curl -f -H "Authorization: token ${env.GITHUB_API_TOKEN}" \
-d '{"tag_name":"${version}", "name":"${version}","body":"${notes}","prerelease": ${preRelease}}' \
https://api.github.com/repos/${ghRepo}/releases`
);

let releaseId = JSON.parse(response).id;

// Get the release id and then upload the and upload the .nupkg
eval(`curl -H "Authorization: token ${env.GITHUB_API_TOKEN}" -H "Content-Type: application/octet-stream" \
--data-binary @"${nupkgFile}" \
https://uploads.github.com/repos/${ghRepo}/releases/${releaseId}/assets?name=${nupkgFile}`);

eval(`rm -r ${buildDirectory}`)

echo(`DONE! Released version ${version} to NuGet and GitHub.`);
23 changes: 23 additions & 0 deletions tmp/pack/dbup-sqlserver-scripting.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>dbup-sqlserver-scripting</id>
<version>$version$</version>
<title>DbUp SQL Server Object Scripting</title>
<authors>Brady Holt</authors>
<owners>Brady Holt</owners>
<licenseUrl>https://raw.github.com/bradyholt/dbup-sqlserver-scripting/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/bradyholt/dbup-sqlserver-scripting</projectUrl>
<iconUrl>https://raw.github.com/DbUp/DbUp/master/src/Information/dbup-icon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Extends DbUp to provide SQL Server object definition scripting when running migrations from Visual Studio. When a database object changes during a migration, its definition will be saved in the project.</description>
<releaseNotes>$notes$</releaseNotes>
<copyright>$copyright$</copyright>
<tags>dbup database migrations sqlserver scripting definitions scripts console</tags>
<dependencies>
<dependency id="dbup" version="3.2.1" />
<dependency id="dbup-consolescripts" version="1.0.9"/>
<dependency id="Unofficial.Microsoft.SQLServer.SMO.2014" version="12.0.2000.8" />
</dependencies>
</metadata>
</package>
Binary file not shown.
11 changes: 11 additions & 0 deletions tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Diagnostics.STrace" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.100.0.0" newVersion="14.100.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file not shown.
52 changes: 52 additions & 0 deletions tmp/pack/tools/dbup-sqlserver-scripting.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<# Package Manager Console scripts to support DbUp #>

function Start-DatabaseScript {
$project = Get-Project
Write-Host "Building..."
$dte.Solution.SolutionBuild.BuildProject("Debug", $project.FullName, $true)
$projectDirectory = Split-Path $project.FullName
$projectExe = $projectDirectory + "\bin\Debug\" + $project.Name + ".exe"
$args = " --scriptAllDefinitions"

& $projectExe $args
}


function New-InitialScript {

$project = get-project
$projectDirectory = Split-Path $project.FullName
#wrap in a job so type isn't locked
$job = Start-Job -ScriptBlock {
$basePath = $args[0]
$binDirectory = "$basePath\bin\debug"
try{
Add-Type -Path "$binDirectory\DbUp.dll"
Add-Type -Path "$binDirectory\DbUp.Support.SqlServer.Scripting.dll"
}
catch
{
Write-Host -foreground yellow "LoadException";
$Error | format-list -force
Write-Host -foreground red $Error[0].Exception.LoaderExceptions;
}

$scriptProvider = new-object DbUp.Support.SqlServer.Scripting.DefinitionScriptProvider -ArgumentList "$basePath\Definitions"
$scriptProvider.GetScriptContent()
} -ArgumentList $projectDirectory
Wait-Job $job

#create scripts folder if it doesn't exist
$scripts = $project.ProjectItems | ?{ $_.Name.Equals("Scripts") }
if($scripts -eq $null){
$project.ProjectItems.AddFolder("Scripts")
}
#Create the new script by calling the lib
$initialScriptPath = "$projectDirectory\Scripts\001-initial.sql"
Receive-Job $job | New-Item $initialScriptPath -Force -ErrorAction Ignore -ItemType file

#add to project
$addedItem = $project.ProjectItems.Item("Scripts").ProjectItems.AddFromFileCopy($initialScriptPath)
#update to embedded resource
$addedItem.Properties.Item("BuildAction").Value = 3
}
3 changes: 3 additions & 0 deletions tmp/pack/tools/init.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
param($installPath, $toolsPath, $package, $project)

Import-Module (Join-Path $toolsPath dbup-sqlserver-scripting.psm1)
Loading

0 comments on commit 01d1841

Please sign in to comment.