Skip to content

Commit 64c1e71

Browse files
committed
Merge pull request #748 from github/package_script_fix
Improve package script
2 parents eb25edb + 6f53c2a commit 64c1e71

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

script/package

+33-8
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,26 @@ module OS
2020
end
2121
end
2222

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+
2335
def windows?
2436
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
2537
end
2638

39+
def windows_64?
40+
windows? && /x64/ =~ RUBY_PLATFORM
41+
end
42+
2743
def darwin?
2844
(/darwin/ =~ RUBY_PLATFORM) != nil
2945
end
@@ -48,9 +64,11 @@ class Packer
4864
end
4965

5066
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
5472
build_hub!
5573
cp_assets
5674
tar_gzip
@@ -112,13 +130,20 @@ class Packer
112130
end
113131

114132
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)
118143
end
119144

120145
def cp_assets
121-
path = root_path("target", "*#{OS.type}*")
146+
path = root_path("target", "*#{OS.friendly_name}*")
122147
glob_dir(path).each do |dir|
123148
puts "Copying assets to #{dir}"
124149
["README.md", "LICENSE", "etc/"].each do |f|
@@ -128,7 +153,7 @@ class Packer
128153
end
129154

130155
def tar_gzip
131-
path = root_path("target", "*#{OS.type}*")
156+
path = root_path("target", "*#{OS.friendly_name}*")
132157
glob_dir(path).each do |dir|
133158
puts "Archiving #{dir}"
134159
Dir.chdir(root_path("target")) do

script/version.bat

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
bash script\version %*

0 commit comments

Comments
 (0)