-
Notifications
You must be signed in to change notification settings - Fork 160
/
release.go
64 lines (58 loc) · 1.65 KB
/
release.go
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
package finalize
import (
"github.com/blang/semver"
)
type Versions interface {
HasGem(string) (bool, error)
GemMajorVersion(string) (int, error)
HasGemVersion(string, ...string) (bool, error)
}
func (f *Finalizer) GenerateReleaseYaml() (map[string]map[string]string, error) {
hasThin, err := f.Versions.HasGem("thin")
if err != nil {
return nil, err
}
hasRails4, err := f.Versions.HasGemVersion("rails", ">=4.0.0-beta")
if err != nil {
return nil, err
}
hasRails3, err := f.Versions.HasGemVersion("rails", ">=3.0.0")
if err != nil {
return nil, err
}
hasRails2, err := f.Versions.HasGemVersion("rails", ">=2.0.0")
if err != nil {
return nil, err
}
hasRack, err := f.Versions.HasGem("rack")
if err != nil {
return nil, err
}
processTypes := map[string]string{}
switch {
case hasRails4:
processTypes["web"] = "bin/rails server -b 0.0.0.0 -p $PORT -e $RAILS_ENV"
case hasRails3 && hasThin:
processTypes["web"] = "bundle exec thin start -R config.ru -e $RAILS_ENV -p $PORT"
case hasRails3:
processTypes["web"] = "bundle exec rails server -p $PORT"
case hasRails2 && hasThin:
processTypes["web"] = "bundle exec thin start -e $RAILS_ENV -p $PORT"
case hasRails2:
processTypes["web"] = "bundle exec ruby script/server -p $PORT"
case hasRack && hasThin:
processTypes["web"] = "bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT"
case hasRack:
processTypes["web"] = "bundle exec rackup config.ru -p $PORT"
}
return map[string]map[string]string{
"default_process_types": processTypes,
}, nil
}
func mustParse(s string) semver.Version {
semver, err := semver.ParseTolerant(s)
if err != nil {
panic(err)
}
return semver
}