@@ -21,6 +21,24 @@ struct SetUpCICDService {
21
21
}
22
22
}
23
23
}
24
+
25
+ enum GithubRunnerType {
26
+
27
+ case macOSLatest, selfHosted, later
28
+
29
+ init ? ( _ name: String ) {
30
+ switch name. lowercased ( ) {
31
+ case " m " , " macOS " :
32
+ self = . macOSLatest
33
+ case " s " , " self-hosted " :
34
+ self = . selfHosted
35
+ case " l " , " later " :
36
+ self = . later
37
+ default :
38
+ return nil
39
+ }
40
+ }
41
+ }
24
42
25
43
private let fileManager = FileManager . default
26
44
@@ -33,28 +51,27 @@ struct SetUpCICDService {
33
51
34
52
switch service {
35
53
case . github:
36
- var runnerType : String ?
54
+ var runnerType : GithubRunnerType ?
37
55
while runnerType == nil {
38
- print ( " Which workflow runner do you want to use? [(m)acos-latest/(s)elf-hosted]: " )
39
- runnerType = readLine ( ) ? . lowercased ( )
40
- if runnerType != " m " && runnerType != " s " {
41
- print ( " Invalid input. Please enter 'm' for macOS-latest or 's' for self-hosted. " )
42
- runnerType = nil
43
- }
56
+ print ( " Which workflow runner do you want to use? [(m)acos-latest/(s)elf-hosted/(l)ater]: " )
57
+ runnerType = GithubRunnerType ( readLine ( ) . string)
44
58
}
45
59
print ( " Setting template for Github Actions " )
46
60
fileManager. removeItems ( in: " bitrise.yml " )
47
61
fileManager. removeItems ( in: " codemagic.yaml " )
48
62
fileManager. removeItems ( in: " .github/workflows " )
49
63
fileManager. createDirectory ( path: " .github/workflows " )
50
- if runnerType == " s " {
51
- fileManager. moveFiles ( in: " .github/self_hosted_project_workflows " , to: " .github/workflows " )
64
+ switch runnerType {
65
+ case . macOSLatest:
66
+ fileManager. moveFiles ( in: " .github/project_workflows " , to: " .github/workflows " )
52
67
fileManager. removeItems ( in: " .github/project_workflows " )
53
68
fileManager. removeItems ( in: " .github/self_hosted_project_workflows " )
54
- } else {
55
- fileManager. moveFiles ( in: " .github/project_workflows " , to: " .github/workflows " )
69
+ case . selfHosted :
70
+ fileManager. moveFiles ( in: " .github/self_hosted_project_workflows " , to: " .github/workflows " )
56
71
fileManager. removeItems ( in: " .github/project_workflows " )
57
72
fileManager. removeItems ( in: " .github/self_hosted_project_workflows " )
73
+ case . later, . none:
74
+ print ( " You can manually setup the runner later. " )
58
75
}
59
76
case . bitrise:
60
77
print ( " Setting template for Bitrise " )
0 commit comments