azdeploy 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be5422007de61780aa459e834d63cf996d6fda32
4
- data.tar.gz: 601aa46de58bb4eb17158a2e8224630061388fcc
3
+ metadata.gz: 38e00e6d7d29447196dbc0a629fd5f836376a849
4
+ data.tar.gz: f4e001f2b23e8802e8a8cf72de019b0f8ac459dc
5
5
  SHA512:
6
- metadata.gz: e23c42da14ece36254964e73d03b413ca3807f8bb19e245df3883c2526406142a40a028606c48526444f14158b86fa86a919d7c21b349476470af4d6a1f0a794
7
- data.tar.gz: ea6b688efcc233f74c08bf09e901fcd6ea9ca94b975d79220221fa9d7b737a6126ab9871d8b91c905d91348326b0e4256448e814031e464b9bdb805bce4831b9
6
+ metadata.gz: 328e1222c72b0ec4263e974c7d3237f349753cfd4e8c8a64acb8f236fb06054400679cdecf652fec41786b303f45a5c253e66ca92041039c746484df8473f5d9
7
+ data.tar.gz: 8c9b83d8bb900c016a267168964bfabb671950a5c2025ad0204de5dd1eb8d232987fdb88645d6fe34d72fa8b4ae9867269b65cba14b5e493f902bddc3269c760
data/azdeploy.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'azdeploy'
3
- s.version = '1.0.0'
3
+ s.version = '1.0.1'
4
4
  s.date = '2015-02-04'
5
5
  s.summary = 'Setup and scripting support for .Net project builds'
6
6
  s.description = 'Azure Deployment Gem. Provides easy setup and deployment scripting support for .Net project builds'
data/lib/azdeploy.rb CHANGED
@@ -4,11 +4,11 @@ require_relative 'build.rb'
4
4
 
5
5
  # installation
6
6
  installers = [
7
- 'Ruby', 'Devkit', 'Doxygen', 'Gems'
7
+ 'ruby', 'devkit', 'doxygen', 'gems'
8
8
  ]
9
9
 
10
10
  installers.each { |method|
11
- exit if !send("check#{method}")
11
+ exit if !send("check_#{method}")
12
12
  }
13
13
 
14
14
  require 'rubygems'
data/lib/build.rb CHANGED
@@ -1,3 +1,5 @@
1
+ $versionMap = {}
2
+
1
3
  def copy_output_files(fromDir, filePattern, outDir)
2
4
  FileUtils.mkdir_p outDir unless exists?(outDir)
3
5
  Dir.glob(File.join(fromDir, filePattern)){|file|
@@ -67,4 +69,64 @@ def cleantask(props)
67
69
  Dir.mkdir props[:output]
68
70
  Dir.mkdir props[:artifacts]
69
71
 
72
+ end
73
+
74
+ def restore_project_pkgs(proj)
75
+ msbuild :nuget_restore do |msb|
76
+ msb.use :net4
77
+ msb.targets :RestorePackages
78
+ msb.solution = proj
79
+ end
80
+ end
81
+
82
+ def clean_build(msb, solution)
83
+ msb.properties :Configuration => 'Release',
84
+ :Platform => 'Any CPU',
85
+ :VisualStudioVersion => '12.0'
86
+ msb.use :net4
87
+ msb.solution = solution
88
+ end
89
+
90
+ def versioning
91
+ ver = SemVer.find
92
+ revision = (ENV['BUILD_NUMBER'] || ver.patch).to_i
93
+ var = SemVer.new(ver.major, ver.minor, revision, ver.special)
94
+
95
+ commitData = commit_data()
96
+
97
+ # extensible number w/ git hash
98
+ ENV['BUILD_VERSION'] = $versionMap[:build_version] = ver.format('%M.%m.%p%s') + ".#{commitData[0]}"
99
+
100
+ # nuget (not full semver 2.0.0-rc.1 support) see http://nuget.codeplex.com/workitem/1796
101
+ ENV['NUGET_VERSION'] = $versionMap[:nuget_version] = ver.format('%M.%m.%p%s')
102
+
103
+ ENV['PLATFORM_VERSION'] = $versionMap[:platform_version] = Time.new.strftime('%y.%-m.%-d') + ".#{(ENV['BUILD_NUMBER'] || '0')}"
104
+
105
+ ENV['PLATFORM_BUILD_VERSION'] = $versionMap[:platform_build_version] = Time.new.strftime('%y.%-m.%-d') + ".#{commitData[0]}"
106
+
107
+ # purely M.m.p format
108
+ ENV['FORMAL_VERSION'] = $versionMap[:formal_version] = "#{ SemVer.new(ver.major, ver.minor, revision).format '%M.%m.%p'}"
109
+ puts "##teamcity[buildNumber '#{$versionMap[:platform_version]}']" # tell teamcity our decision
110
+ end
111
+
112
+ def set_framework_version(asm)
113
+ set_version asm, $versionMap[:formal_version], $versionMap[:formal_version], $versionMap[:build_version], 'Framework'
114
+ end
115
+
116
+ def set_solution_version(asm)
117
+ set_version asm, $versionMap[:platform_version], $versionMap[:platform_version], $versionMap[:platform_build_version], 'Solution'
118
+ end
119
+
120
+ def set_version(asm, version, file_version, assembly_version, output_file)
121
+ # Assembly file config
122
+ asm.product_name = PRODUCT
123
+ asm.description = PRODUCT_DESCRIPTION
124
+ asm.version = version
125
+ asm.file_version = file_version
126
+ asm.custom_attributes :AssemblyInformationalVersion => assembly_version,
127
+ :ComVisibleAttribute => false,
128
+ :CLSCompliantAttribute => true
129
+ asm.copyright = COPYRIGHT
130
+ asm.output_file = "src/#{output_file}Version.cs"
131
+ asm.namespaces 'System', 'System.Reflection', 'System.Runtime.InteropServices'
70
132
  end
data/lib/install.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'net/http'
2
2
 
3
- def downloadFile(sourcePath, filePath, localFileLocation)
3
+ def download_file(sourcePath, filePath, localFileLocation)
4
4
  Net::HTTP.start(sourcePath) do |http|
5
5
  resp = http.get(filePath)
6
6
  f = open(localFileLocation, 'wb')
@@ -22,7 +22,7 @@ def downloadFile(sourcePath, filePath, localFileLocation)
22
22
  return true
23
23
  end
24
24
 
25
- def installFile(cmd, versionedExeFile)
25
+ def install_file(cmd, versionedExeFile)
26
26
  begin
27
27
  installerOutput = `#{cmd}`
28
28
  puts installerOutput
@@ -38,7 +38,7 @@ def installFile(cmd, versionedExeFile)
38
38
  return true
39
39
  end
40
40
 
41
- def gemExists(name, version)
41
+ def gem_exists(name, version)
42
42
  begin
43
43
  gem name, version
44
44
  rescue Gem::LoadError
@@ -49,37 +49,50 @@ def gemExists(name, version)
49
49
  return true
50
50
  end
51
51
 
52
+ $version_map = {
53
+ '1.9.3-p551' => {
54
+ :devkit => 'DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe',
55
+ :gems => {
56
+ 'albacore' => '0.3.5',
57
+ 'semver2' => '3.3.3',
58
+ 'nokogiri' => '1.6.4.1',
59
+ 'zip' => '2.0.2',
60
+ 'azure' => '0.6.4'
61
+ },
62
+ },
63
+ '2.0.0-p481' => {
64
+ :devkit => 'DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe',
65
+ :gems => {
66
+ 'albacore' => '0.3.6',
67
+ 'semver2' => '3.3.3',
68
+ 'nokogiri' => '1.6.4.1',
69
+ 'azure' => '0.6.4'
70
+ }
71
+ }
72
+ }
73
+ $selected_version = {}
74
+
52
75
  # Ruby version check
53
- def checkRuby
76
+ def check_ruby
54
77
  puts 'Checking ruby version...'
55
78
  # check if expected ruby version exists. If not download and install ruby
56
79
  rubyVersion = "#{RUBY_VERSION}"
57
80
  localVersion = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
58
- expectedVersion = '2.0.0-p481'
59
- defaultInstallPath = 'Ruby200'
60
- if (!rubyVersion.nil? && localVersion != expectedVersion)
61
- puts "Uninstall incompatible version of ruby: #{localVersion} and install version: #{expectedVersion}"
81
+ expectedVersion1 = '1.9.3-p551'
82
+ expectedVersion2 = '2.0.0-p481'
83
+ if (!rubyVersion.nil? && localVersion != expectedVersion1 && localVersion != expectedVersion2)
84
+ puts "Uninstall incompatible version of ruby: #{localVersion} and install version: #{expectedVersion1} or #{expectedVersion2}. Then Restart rake. Goto http://rubyinstaller.org/downloads/"
62
85
  return false
63
86
  end
64
- if (rubyVersion.nil?)
65
- puts 'Expected ruby version #{expectedVersion} not found'
66
87
 
67
- sourcePath = 'dl.bintray.com'
68
- versionedExeFile = "rubyinstaller-#{expectedVersion}.exe"
69
- filePath = "/oneclick/rubyinstaller/#{versionedExeFile}?direct"
70
- return false if !downloadFile(sourcePath, filePath, versionedExeFile)
71
-
72
- puts 'Ruby installation in progress...'
73
- cmd = "#{versionedExeFile} /silent /tasks=\"assocfiles,modpath\""
74
- puts cmd
75
- return false if !installFile(cmd, versionedExeFile)
76
- end
88
+ $selected_version = $version_map[expectedVersion1] || $version_map[expectedVersion2]
77
89
  puts 'Ruby ok'
90
+
78
91
  return true
79
92
  end
80
93
 
81
94
  ### devkit version check
82
- def checkDevkit
95
+ def check_devkit
83
96
  # check if devkit exists
84
97
  puts 'Checking devkit version...'
85
98
  rubyPath = `where.exe ruby.exe`
@@ -91,14 +104,14 @@ def checkDevkit
91
104
  puts 'Downloading devkit...'
92
105
 
93
106
  sourcePath = 'cdn.rubyinstaller.org'
94
- versionedExeFile = 'DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe'
107
+ versionedExeFile = $selected_version[:devkit]
95
108
  filePath = "/archives/devkits/#{versionedExeFile}?direct"
96
- return false if !downloadFile(sourcePath, filePath, versionedExeFile)
109
+ return false if !download_file(sourcePath, filePath, versionedExeFile)
97
110
 
98
111
  puts 'Devkit installation in progress...'
99
112
  cmd = "#{versionedExeFile} -y -o\"#{rubyPath}\"" #no space after -o, gotcha
100
113
  puts cmd
101
- return false if !installFile(cmd, versionedExeFile)
114
+ return false if !install_file(cmd, versionedExeFile)
102
115
 
103
116
  puts 'Setting up devkit...'
104
117
  Dir.chdir "#{rubyPath}"
@@ -131,22 +144,16 @@ def checkDevkit
131
144
  end
132
145
 
133
146
  # doxygen check
134
- def checkDoxygen
147
+ def check_doxygen
135
148
  # download doxygen
136
149
  return true
137
150
  end
138
151
 
139
152
  # check and install required gems
140
- def checkGems
153
+ def check_gems
141
154
  puts 'Checking required gems...'
142
- gemlist = {
143
- 'albacore' => '0.3.6',
144
- 'semver' => '1.0.1',
145
- 'nokogiri' => '1.6.4.1',
146
- 'azure' => '0.6.4'
147
- }
148
- gemlist.each {|key, value|
149
- if !gemExists(key, "=#{value}")
155
+ $selected_version[:gems].each {|key, value|
156
+ if !gem_exists(key, "=#{value}")
150
157
  begin
151
158
  puts "Installing missing gem: #{key}"
152
159
  cmd = "gem install #{key} -v #{value}"
data/lib/transform.rb CHANGED
@@ -10,7 +10,7 @@ def get(key)
10
10
  result
11
11
  end
12
12
 
13
- def getAll
13
+ def get_all
14
14
  begin
15
15
  query = { :filter => "PartitionKey eq '#{@env}'" }
16
16
  result = @svc.query_entities(@table, query)
@@ -23,7 +23,7 @@ def getAll
23
23
  result
24
24
  end
25
25
 
26
- def getValue(key)
26
+ def get_value(key)
27
27
  value = ''
28
28
  @settings.each { |i|
29
29
  if i.properties['RowKey'] == key
@@ -35,7 +35,7 @@ def getValue(key)
35
35
  value
36
36
  end
37
37
 
38
- def transformAppSettings
38
+ def transform_appsettings
39
39
  # go to each file and replace value of matching appSettings key
40
40
  @configFiles.each{|file|
41
41
  doc = Nokogiri::XML(File.read(file))
@@ -55,22 +55,22 @@ def transformAppSettings
55
55
  }
56
56
  end
57
57
 
58
- def transformServiceModelConfig
58
+ def transform_servicemodelconfig
59
59
  @configFiles.each{|file|
60
60
  doc = Nokogiri::XML(File.read(file))
61
61
  doc.xpath('//system.serviceModel').each do |node|
62
62
  #puts node
63
63
  if file.end_with?('app.config') || file.end_with?('App.config')
64
- node.replace(getValue('system.ServiceModel.Client')) if !node.nil?
64
+ node.replace(get_value('system.ServiceModel.Client')) if !node.nil?
65
65
  elsif file.end_with?('Web.config')
66
- node.replace(getValue('system.ServiceModel.Service')) if !node.nil?
66
+ node.replace(get_value('system.ServiceModel.Service')) if !node.nil?
67
67
  end
68
68
  end
69
69
  File.write(file, doc.to_xml)
70
70
  }
71
71
  end
72
72
 
73
- def transformSystemWebCompilationAttribs
73
+ def transform_systemwebcompilationattribs
74
74
  @configFiles.each{|file|
75
75
  doc = Nokogiri::XML(File.read(file))
76
76
  node = doc.at_css "compilation"
@@ -84,7 +84,7 @@ def transformSystemWebCompilationAttribs
84
84
  }
85
85
  end
86
86
 
87
- def transformCsdef
87
+ def transform_csdef
88
88
  csdef = Dir.glob("**/*.csdef")
89
89
  csdef.each{ |file|
90
90
  doc = Nokogiri::XML(File.read(file))
@@ -96,19 +96,19 @@ def transformCsdef
96
96
  node['name'] = ENV['ServiceName'] if !node.nil?
97
97
 
98
98
  node = doc.at_css "Certificates"
99
- node.replace(getValue('Certificates_csdef')) if !node.nil?
99
+ node.replace(get_value('Certificates_csdef')) if !node.nil?
100
100
 
101
101
  node = doc.at_css "Endpoints"
102
- node.replace(getValue('Endpoints')) if !node.nil?
102
+ node.replace(get_value('Endpoints')) if !node.nil?
103
103
 
104
104
  node = doc.at_css "Bindings"
105
- node.replace(getValue('Bindings')) if !node.nil?
105
+ node.replace(get_value('Bindings')) if !node.nil?
106
106
 
107
107
  File.write(file, doc.to_xml)
108
108
  }
109
109
  end
110
110
 
111
- def transformCscfg
111
+ def transform_cscfg
112
112
  csdef = Dir.glob("**/*.cscfg")
113
113
  csdef.each{ |file|
114
114
  doc = Nokogiri::XML(File.read(file))
@@ -120,22 +120,22 @@ def transformCscfg
120
120
  node['name'] = ENV['ServiceName'] if !node.nil?
121
121
 
122
122
  node = doc.at_css "Certificates"
123
- node.replace(getValue('Certificates_cscfg')) if !node.nil?
123
+ node.replace(get_value('Certificates_cscfg')) if !node.nil?
124
124
 
125
125
  File.write(file, doc.to_xml)
126
126
  }
127
127
  end
128
128
 
129
- def transformDiagnosticsCfg
129
+ def transform_diagnosticscfg
130
130
  csdef = Dir.glob("**/*.wadcfgx")
131
131
  csdef.each{ |file|
132
132
  doc = Nokogiri::XML(File.read(file))
133
133
 
134
134
  node = doc.at_css "PrivateConfig/StorageAccount"
135
- node['name'] = getValue('StorageAccount')
136
- node['key'] = getValue('StorageAccountKey')
135
+ node['name'] = get_value('StorageAccount')
136
+ node['key'] = get_value('StorageAccountKey')
137
137
  node = doc.at_css "StorageAccount"
138
- node.content = getValue('StorageAccount')
138
+ node.content = get_value('StorageAccount')
139
139
 
140
140
  File.write(file, doc.to_xml)
141
141
  }
@@ -149,6 +149,13 @@ def transform
149
149
  puts 'Environment name required to transform. No configuration changes will be done...'
150
150
  return false
151
151
  end
152
+
153
+ @is_service = ENV['ServiceName'] || 'nosvc'
154
+ if @is_service == 'nosvc'
155
+ puts 'Target to transform is not a service...'
156
+ return false
157
+ end
158
+
152
159
  puts "Transforming config for environment: #{@env} ..."
153
160
 
154
161
  # azure table storage account where settings reside
@@ -160,39 +167,42 @@ def transform
160
167
  @svc = Azure::TableService.new
161
168
 
162
169
  # get all settings for environment
163
- @settings = getAll
164
-
165
- # get config templates
166
- puts "Obtaining templates..."
167
- csdefTemplate = getValue('ServiceDefinitionTemplate')
168
- File.write('ServiceDefinition.csdef', csdefTemplate)
169
- cscfgTemplate = getValue('ServiceConfigurationTemplate')
170
- File.write('ServiceConfiguration.cscfg', cscfgTemplate)
171
-
172
- # start updating config files
170
+ @settings = get_all
173
171
 
174
172
  # find all App.config and web.config files
175
173
  @configFiles = Dir.glob("**/app.config")
176
174
  @configFiles.concat(Dir.glob("**/web.config"))
177
- @configFiles.concat(Dir.glob("**/RuntimeWeb/*Web.dll.config"))
178
175
 
179
- puts "Replacing app settings..."
180
- transformAppSettings
176
+ # get config templates
177
+ if @is_service
181
178
 
182
- puts "Removing debug compilation attributes..."
183
- transformSystemWebCompilationAttribs
179
+ puts "Obtaining templates..."
180
+ csdefTemplate = get_value('ServiceDefinitionTemplate')
181
+ File.write('ServiceDefinition.csdef', csdefTemplate)
182
+ cscfgTemplate = get_value('ServiceConfigurationTemplate')
183
+ File.write('ServiceConfiguration.cscfg', cscfgTemplate)
184
+
185
+ @configFiles.concat(Dir.glob("**/RuntimeWeb/*Web.dll.config"))
186
+
187
+ puts "Transforming csdef..."
188
+ transform_csdef
189
+
190
+ puts "Transforming cscfg..."
191
+ transform_cscfg
184
192
 
185
- puts "Transforming csdef..."
186
- transformCsdef
193
+ puts "Transforming diagnostics cfg..."
194
+ transform_diagnosticscfg
187
195
 
188
- puts "Transforming cscfg..."
189
- transformCscfg
196
+ puts "Replacing service model settings..."
197
+ transform_servicemodelconfig
198
+
199
+ end
190
200
 
191
- puts "Transforming diagnostics cfg..."
192
- transformDiagnosticsCfg
201
+ puts "Replacing app settings..."
202
+ transform_appsettings
193
203
 
194
- puts "Replacing service model settings..."
195
- transformServiceModelConfig
204
+ puts "Removing debug compilation attributes..."
205
+ transform_systemwebcompilationattribs
196
206
 
197
207
  return true
198
208
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suresh Batta