Permalink
Browse files

(issue #36) release script will now update AssemblyInfo version number

  • Loading branch information...
1 parent 233c90e commit 9f7e492e2625a6faca2b317a2064ed752c9f691e @gbirchmeier gbirchmeier committed Jan 30, 2012
Showing with 52 additions and 5 deletions.
  1. +9 −5 package_release.bat
  2. +43 −0 scripts/update_assembly_version.rb
View
@@ -16,19 +16,23 @@ echo ==QuickFIX/N Package release script==
echo tag version: %TAG_VERSION%
echo
+rem Update the assembly version
+ruby scripts\update_assembly_version.rb %TAG_VERSION% QuickFIX.NET\Properties\AssemblyInfo.cs
+echo * AssemblyInfo updated for new version number.
rem Update downloads page - NOTE this must be done first
ruby scripts\update_download_page.rb web/views/download.md %TAG_VERSION%
if %errorlevel% neq 0 echo "There was an error uploading the downloads page" && exit /b %errorlevel%
echo * Downloads page updated.
-rem commit the downloads page, so it will be part of the tag
-call git add web/views/download.md
-call git commit -m "Download page for version %TAG_VERSION%"
-echo * Downloads page committed.
+rem commit the downloads page and version file, so it will be part of the tag
+call git add web\views\download.md
+call git add QuickFIX.NET\Properties\AssemblyInfo.cs
+call git commit -m "Download page / version number for version %TAG_VERSION%"
+echo * Downloads page / version number committed.
rem create the tag
-call git tag -a %TAG_VERSION% -m "Created a tag for version %TAG_VERSION%"
+call git tag -a %TAG_VERSION% -m "Release version %TAG_VERSION%"
echo * Created tag.
rem Get requested version
@@ -0,0 +1,43 @@
+
+
+def print_usage_and_die
+ puts "Usage: ruby update_assembly_version.rb version assembly_filepath"
+ puts "Parameters:"
+ puts " version: Where version is a string \"n.n.n\" (e.g. 2.0.143)"
+ puts " assembly_filepath: Path to a VisualStudio AssemblyInfo.cs file"
+ exit(1)
+end
+
+def is_correct_pattern? ver
+ return ver.match(/^[\d]+[.][\d]+[.][\d]+$/)
+end
+
+if ARGV[0].nil? or ARGV[1].nil?
+ print_usage_and_die
+end
+
+
+
+vers = ARGV[0]
+assemblypath = ARGV[1]
+
+if not is_correct_pattern? vers
+ puts "Invalid version string."
+ print_usage_and_die
+end
+
+if not (File.exists?(assemblypath) and File.writable?(assemblypath))
+ puts "Can't open file \"#{assemblypath}\" for writing."
+ puts "(Current path: #{Dir.pwd})"
+ print_usage_and_die
+end
+
+contents = IO.read(assemblypath)
+contents.sub!(/AssemblyVersion\([^\)]*\)/, "AssemblyVersion(\"#{vers}.0\")")
+contents.sub!(/AssemblyFileVersion\([^\)]*\)/, "AssemblyFileVersion(\"#{vers}.0\")")
+
+File.open(assemblypath,"w") {|f|
+ f.write(contents)
+}
+
+

0 comments on commit 9f7e492

Please sign in to comment.