forked from artemnovichkov/StencilSwiftKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
executable file
·92 lines (74 loc) · 2.77 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
#!/usr/bin/rake
require 'English'
unless defined?(Bundler)
puts 'Please use bundle exec to run the rake command'
exit 1
end
## [ Constants ] ##############################################################
WORKSPACE = 'StencilSwiftKit'.freeze
SCHEME_NAME = 'Tests'.freeze
CONFIGURATION = 'Debug'.freeze
POD_NAME = 'StencilSwiftKit'.freeze
MIN_XCODE_VERSION = 10.0
## [ Generate SPM files ] #####################################################
namespace :spm do
desc 'Generate the tests manifest for SPM'
task :generate_test_manifests do |task|
File.delete("Tests/#{WORKSPACE}Tests/XCTestManifests.swift")
Utils.run('swift test --generate-linuxmain', task, xcrun: true)
end
end
## [ Release a new version ] ##################################################
namespace :release do
desc 'Create a new release on CocoaPods'
task :new => [:check_versions, 'xcode:test', :cocoapods]
desc 'Check if all versions from the podspecs and CHANGELOG match'
task :check_versions do
results = []
# Check if bundler is installed first, as we'll need it for the cocoapods task (and we prefer to fail early)
`which bundler`
results << Utils.table_result(
$CHILD_STATUS.success?,
'Bundler installed',
'Please install bundler using `gem install bundler` and run `bundle install` first.'
)
# Extract version from podspec
podspec_version = Utils.podspec_version(POD_NAME)
Utils.table_info("#{POD_NAME}.podspec", podspec_version)
# Check if version in Podfile.lock matches
podfile_lock_version = Utils.podfile_lock_version(POD_NAME)
results << Utils.table_result(
podfile_lock_version == podspec_version,
'Podfile.lock',
'Please run pod install'
)
# Check if entry present in CHANGELOG
changelog_entry = system(%(grep -q '^## #{Regexp.quote(podspec_version)}$' CHANGELOG.md))
results << Utils.table_result(
changelog_entry,
'CHANGELOG, Entry added',
"Please add an entry for #{podspec_version} in CHANGELOG.md"
)
changelog_has_stable = system("grep -qi '^## Stable Branch' CHANGELOG.md")
results << Utils.table_result(
!changelog_has_stable,
'CHANGELOG, No stable',
'Please remove section for stable branch in CHANGELOG'
)
tag_set = !`git ls-remote --tags . refs/tags/#{podspec_version}`.empty?
results << Utils.table_result(
tag_set,
'Tag pushed',
'Please create a tag and push it'
)
exit 1 unless results.all?
print "Release version #{podspec_version} [Y/n]? "
exit 2 unless STDIN.gets.chomp == 'Y'
end
desc "pod trunk push #{POD_NAME} to CocoaPods"
task :cocoapods do
Utils.print_header 'Pushing pod to CocoaPods Trunk'
sh "bundle exec pod trunk push #{POD_NAME}.podspec"
end
end
task :default => 'xcode:test'