-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
192 lines (136 loc) · 4.69 KB
/
Rakefile
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
require 'rake'
require_relative 'common'
require_relative 'git'
require_relative 'dropbox_deploy'
require_relative 'credentials'
require_relative 'dropbox_deploy_credentials'
include Common
task :use_https do
$git_repo = 'https://github.com/ArduboyGameDevelopers/PixelSpaceOdyssey.git'
end
task :use_ssh do
$git_repo = '[email protected]:ArduboyGameDevelopers/PixelSpaceOdyssey.git'
end
task :init do
$git_branch = 'develop'
$project_name = 'PixelSpaceOdyssey'
$project_config = 'Release'
$dir_builder = File.expand_path '.'
$dir_tools = resolve_path "#{$dir_builder}/tools"
$dir_project = "#{$dir_repo}/#{$project_name}"
$dir_out = "#{$dir_builder}/out"
$dir_out_builds = "#{$dir_out}/builds"
$dir_repo = "#{$dir_out}/repo"
$dir_emu = "#{$dir_repo}/Emulator"
$dir_emu_build = "#{$dir_emu}/build"
$file_emu_project = "#{$dir_emu}/Emulator.pro"
end
task :clean => :init do
FileUtils.rm_rf $dir_emu_build
FileUtils.rm_rf $dir_out
end
task :clone_repo => :clean do
fail_script_if $git_repo.nil?, 'Git repo is not specified'
Git.clone $git_repo, $git_branch, $dir_repo
def extract_project_version(dir_project)
file_plist = resolve_path "#{dir_project}/Version.h"
source = File.read file_plist
source =~ /#define\s+PROJECT_VERSION\s+"(\d+\.\d+\.\d+)"/
not_nil $1
end
$project_version = extract_project_version $dir_emu
end
desc 'Build the app'
task :build => [:use_https, :clone_repo] do
puts "Project version: #{$project_version}"
# create directory
dir_build = "#{$dir_emu_build}/#{$project_config}"
make_dir dir_build, :overwrite => true
# build make project
Dir.chdir dir_build do
exec_shell %(qmake "#{$file_emu_project}" -r -spec win32-g++ "CONFIG+=#{$project_config.downcase}), "Can't run qmake"
end
# run make project
file_makefile = "Makefile.#{$project_config}"
Dir.chdir dir_build do
exec_shell %(mingw32-make -f "#{file_makefile}"), "Can't run make"
end
# deploy windows
file_app = resolve_path "#{dir_build}/#{$project_config.downcase}/Emulator.exe"
dir_deploy = "#{$dir_out}/deploy"
make_dir dir_deploy, :overwrite => true
FileUtils.cp file_app, "#{dir_deploy}/"
Dir.chdir dir_deploy do
cmd = ''
cmd << 'windeployqt'
cmd << " --#{$project_config.downcase}"
cmd << ' --no-translations'
cmd << ' --no-quick-import'
cmd << ' --no-system-d3d-compiler'
cmd << ' --no-angle'
cmd << ' Emulator.exe'
exec_shell cmd, "Can't deploy windows"
trash_files = %w(iconengines imageformats opengl32sw.dll Qt5Svg.dll)
trash_files.each do |file|
if File.directory? file
FileUtils.rm_rf file
else
FileUtils.rm file
end
end
end
# copy tiles
FileUtils.cp_r "#{$dir_emu}/Tiles", "#{dir_deploy}/"
# zip delivery
make_dir $dir_out_builds, :overwrite => true
file_build = "#{$dir_out_builds}/#{$project_name}-#{$project_version}.zip"
zip_dir dir_deploy, file_build
end
desc 'Deploys the app'
task :deploy => :build do
file_build = resolve_path Dir["#{$dir_out_builds}/#{$project_name}-*.zip"].first
dropbox = DropboxDeploy.new $dropbox_access_token
dropbox.deploy file_build
end
desc 'Create Github release'
task :create_github_release => [:use_ssh, :clone_repo] do
# Merge changes to master
Git.git_merge $dir_repo, $git_branch, 'master'
# Create release
github_create_release $dir_repo, $project_version
end
def github_create_release(dir_repo, version)
fail_script_unless_file_exists dir_repo
github_release_bin = resolve_path "#{$dir_tools}/github/github-release"
Dir.chdir dir_repo do
name = "Pixel Space Odyssey v#{version}"
tag = version
repo_name = git_get_repo_name '.'
fail_script_unless repo_name, "Unable to extract repo name: #{dir_repo}"
# delete old release
cmd = %("#{github_release_bin}" delete)
cmd << %( -s #{$github_access_token})
cmd << %( -u #{$github_owner})
cmd << %( -r #{repo_name})
cmd << %( -t "#{tag}")
exec_shell cmd, "Can't remove old release", :dont_fail_on_error => true
# create a release
release_notes = get_release_notes dir_repo, version
cmd = %("#{github_release_bin}" release)
cmd << %( -s #{$github_access_token})
cmd << %( -u #{$github_owner})
cmd << %( -r #{repo_name})
cmd << %( -t "#{tag}")
cmd << %( -n "#{name}")
cmd << %( -d "#{release_notes}")
exec_shell cmd, "Can't push release"
end
end
############################################################
def git_get_repo_name(dir_repo)
Dir.chdir dir_repo do
file_config = '.git/config'
config = File.read file_config
return extract_regex config, %r#url = git@github\.com:.*?/(.*?).git#
end
end