forked from brettchalupa/godot_skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport
executable file
·82 lines (69 loc) · 2.25 KB
/
export
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'inifile', '~> 3.0'
end
name = File.read("project.godot").split("\n")
.find { |l| l.include?("config/name") }
.split("=").last.gsub("\"", "")
name_kebab = name.downcase.gsub(" ", "-").gsub(":", "")
exports = {}
exports_cfg = IniFile.load("export_presets.cfg")
exports_cfg.each_section do |section|
next if !section.include?("preset") || section.include?(".options")
sect = exports_cfg[section]
exports[sect["name"]] = {
"platform" => sect["platform"],
"export_path" => sect["export_path"].gsub("game", name_kebab),
}
end
exports.each do |k, v|
puts("Building export: #{k}")
if system("godot --headless --export-release \"#{k}\" #{v['export_path']}", exception: true)
puts("Success! Exported to: #{v['export_path']}")
# compress exports that aren't
if File.extname(v['export_path']) != ".zip"
if v['platform'].downcase == "web"
file = "exports/#{name_kebab}-web.zip"
system("zip #{file} -j #{v['export_path'].gsub('index.html', '*')}", exception: true)
v['export_path'] = file
else
file = v['export_path'].gsub(File.extname(v['export_path']), '.zip')
system("zip #{file} -j #{v['export_path']}", exception: true)
v['export_path'] = file
end
end
else
puts("Failed to build: #{$?}")
end
end
export_cfg = IniFile.load("export.cfg")
itch_cfg = export_cfg["itch"]
if itch_cfg
if system("butler -V")
puts("itch.io butler installed, pushing builds")
exports.each do |k, v|
file = v['export_path'].strip
user = itch_cfg['user']
game = itch_cfg['game']
channel = v['platform'].downcase.gsub(" ", "-").gsub("/", "-")
if channel == "web"
channel = "html"
end
butler_cmd = "butler push #{file} #{user}/#{game}:#{channel}"
if ver = export_cfg['metadata']['version']
butler_cmd += " --userversion #{ver}"
end
if File.exist?(file)
puts("Pushing export to itch.io: #{k}, #{file}")
if !system(butler_cmd, exception: true)
puts("Failed to push to itch.io: #{$?}")
end
end
end
else
abort("itch.io butler not installed")
end
end
puts("Export builds complete!")