@@ -20,10 +20,26 @@ module OS
20
20
end
21
21
end
22
22
23
+ def friendly_name
24
+ if darwin?
25
+ "mac"
26
+ elsif linux?
27
+ "linux"
28
+ elsif windows?
29
+ "windows"
30
+ else
31
+ raise "Unknown OS type #{ RUBY_PLATFORM } "
32
+ end
33
+ end
34
+
23
35
def windows?
24
36
( /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM ) != nil
25
37
end
26
38
39
+ def windows_64?
40
+ windows? && /x64/ =~ RUBY_PLATFORM
41
+ end
42
+
27
43
def darwin?
28
44
( /darwin/ =~ RUBY_PLATFORM ) != nil
29
45
end
@@ -48,9 +64,11 @@ class Packer
48
64
end
49
65
50
66
def pack!
51
- install_gox!
52
- build_toolchain!
53
- run_tests!
67
+ unless ENV [ "SKIP_TOOLCHAIN" ]
68
+ install_gox!
69
+ build_toolchain!
70
+ end
71
+ run_tests! unless OS . windows? || ENV [ "SKIP_TEST" ] # cukes don't run on Windows
54
72
build_hub!
55
73
cp_assets
56
74
tar_gzip
@@ -112,13 +130,20 @@ class Packer
112
130
end
113
131
114
132
def build_hub!
115
- puts "Building for #{ OS . type } "
116
- release_version = `./script/version`
117
- exec! ( "gox -os=#{ OS . type } -output=./target/{{.Dir}}_#{ version } _{{.OS}}_{{.Arch}}/{{.Dir}} -ldflags '-X github.com/github/hub/commands.Version #{ release_version } '" )
133
+ puts "Building for #{ OS . friendly_name } "
134
+ release_version = `script/version` . strip
135
+ output = root_path ( "target" , "{{.Dir}}_#{ version } _#{ OS . friendly_name } _{{.Arch}}" , "{{.Dir}}" )
136
+ # gox doesn't build for 64 bit and 32 bit on 64 bit Windows
137
+ # specifying osarch for Windows
138
+ # see https://github.com/mitchellh/gox/issues/19#issuecomment-68117016
139
+ osarch = OS . windows? ? "windows/#{ OS . windows_64? ? "amd64" : "386" } " : ""
140
+ cmd = "gox -os=#{ OS . type } -output=#{ output } -ldflags \" -X github.com/github/hub/commands.Version #{ release_version } \" "
141
+ cmd += " -osarch=#{ osarch } " unless osarch . empty?
142
+ exec! ( cmd )
118
143
end
119
144
120
145
def cp_assets
121
- path = root_path ( "target" , "*#{ OS . type } *" )
146
+ path = root_path ( "target" , "*#{ OS . friendly_name } *" )
122
147
glob_dir ( path ) . each do |dir |
123
148
puts "Copying assets to #{ dir } "
124
149
[ "README.md" , "LICENSE" , "etc/" ] . each do |f |
@@ -128,7 +153,7 @@ class Packer
128
153
end
129
154
130
155
def tar_gzip
131
- path = root_path ( "target" , "*#{ OS . type } *" )
156
+ path = root_path ( "target" , "*#{ OS . friendly_name } *" )
132
157
glob_dir ( path ) . each do |dir |
133
158
puts "Archiving #{ dir } "
134
159
Dir . chdir ( root_path ( "target" ) ) do
0 commit comments