forked from bitrise-steplib/steps-google-play-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
699 lines (569 loc) · 20.1 KB
/
main.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
package main
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"unicode/utf8"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"golang.org/x/oauth2/jwt"
"google.golang.org/api/androidpublisher/v2"
"google.golang.org/api/googleapi"
"github.com/bitrise-io/go-utils/command"
"github.com/bitrise-io/go-utils/errorutil"
"github.com/bitrise-io/go-utils/fileutil"
"github.com/bitrise-io/go-utils/log"
"github.com/bitrise-io/go-utils/pathutil"
"github.com/bitrise-tools/go-steputils/input"
)
const (
alphaTrackName = "alpha"
betaTrackName = "beta"
rolloutTrackName = "rollout"
productionTrackName = "production"
)
// ConfigsModel ...
type ConfigsModel struct {
JSONKeyPath string
PackageName string
ApkPath string
ExpansionfilePath string
Track string
UserFraction string
WhatsnewsDir string
MappingFile string
UntrackBlockingVersions string
}
func packageNameForApk(apkPath string) string {
fmt.Printf("Getting package name for %s\n", apkPath)
apptPath := "/opt/android-sdk-linux/build-tools/28.0.3/aapt"
_, err := exec.LookPath(apptPath)
if err != nil {
log.Errorf("Unable to find aapt")
}
cmd := exec.Command(apptPath, "dump", "badging", apkPath)
stdoutStderr, err := cmd.CombinedOutput()
s := string(stdoutStderr)
packageNameRegex := regexp.MustCompile(`package: name='(.*?)'`)
packageName := packageNameRegex.FindAllStringSubmatch(s, -1)[0][1]
fmt.Println("package name:", packageName)
return packageName
}
func createConfigsModelFromEnvs() ConfigsModel {
return ConfigsModel{
JSONKeyPath: os.Getenv("service_account_json_key_path"),
PackageName: os.Getenv("package_name"),
ApkPath: os.Getenv("apk_path"),
ExpansionfilePath: os.Getenv("expansionfile_path"),
Track: os.Getenv("track"),
UserFraction: os.Getenv("user_fraction"),
WhatsnewsDir: os.Getenv("whatsnews_dir"),
MappingFile: os.Getenv("mapping_file"),
UntrackBlockingVersions: os.Getenv("untrack_blocking_versions"),
}
}
func secureInput(str string) string {
if str == "" {
return ""
}
secureStr := func(s string, show int) string {
runeCount := utf8.RuneCountInString(s)
if runeCount < 6 || show == 0 {
return strings.Repeat("*", 3)
}
if show*4 > runeCount {
show = 1
}
sec := fmt.Sprintf("%s%s%s", s[0:show], strings.Repeat("*", 3), s[len(s)-show:len(s)])
return sec
}
prefix := ""
cont := str
sec := secureStr(cont, 0)
if strings.HasPrefix(str, "file://") {
prefix = "file://"
cont = strings.TrimPrefix(str, prefix)
sec = secureStr(cont, 3)
} else if strings.HasPrefix(str, "http://www.") {
prefix = "http://www."
cont = strings.TrimPrefix(str, prefix)
sec = secureStr(cont, 3)
} else if strings.HasPrefix(str, "https://www.") {
prefix = "https://www."
cont = strings.TrimPrefix(str, prefix)
sec = secureStr(cont, 3)
} else if strings.HasPrefix(str, "http://") {
prefix = "http://"
cont = strings.TrimPrefix(str, prefix)
sec = secureStr(cont, 3)
} else if strings.HasPrefix(str, "https://") {
prefix = "https://"
cont = strings.TrimPrefix(str, prefix)
sec = secureStr(cont, 3)
}
return prefix + sec
}
func (configs ConfigsModel) print() {
log.Infof("Configs:")
log.Printf("- JSONKeyPath: %s", secureInput(configs.JSONKeyPath))
log.Printf("- PackageName: %s", configs.PackageName)
log.Printf("- ApkPath: %s", configs.ApkPath)
log.Printf("- ExpansionfilePath: %s", configs.ExpansionfilePath)
log.Printf("- Track: %s", configs.Track)
log.Printf("- UserFraction: %s", configs.UserFraction)
log.Printf("- WhatsnewsDir: %s", configs.WhatsnewsDir)
log.Printf("- MappingFile: %s", configs.MappingFile)
log.Printf("- UntrackBlockingVersions: %s", configs.UntrackBlockingVersions)
}
func (configs ConfigsModel) validate() error {
// required
if err := input.ValidateIfNotEmpty(configs.JSONKeyPath); err != nil {
return errors.New("issue with input JSONKeyPath: " + err.Error())
} else if strings.HasPrefix(configs.JSONKeyPath, "file://") {
pth := strings.TrimPrefix(configs.JSONKeyPath, "file://")
if exist, err := pathutil.IsPathExists(pth); err != nil {
return fmt.Errorf("Failed to check if JSONKeyPath exist at: %s, error: %s", pth, err)
} else if !exist {
return errors.New("JSONKeyPath not exist at: " + pth)
}
}
if err := input.ValidateIfNotEmpty(configs.PackageName); err != nil {
return errors.New("issue with input PackageName: " + err.Error())
}
if err := input.ValidateIfNotEmpty(configs.ApkPath); err != nil {
return errors.New("issue with input ApkPath: " + err.Error())
}
apkPaths := strings.Split(configs.ApkPath, "|")
for _, apkPath := range apkPaths {
if exist, err := pathutil.IsPathExists(apkPath); err != nil {
return fmt.Errorf("Failed to check if APK exist at: %s, error: %s", apkPath, err)
} else if !exist {
return errors.New("APK not exist at: " + apkPath)
}
}
if err := input.ValidateIfNotEmpty(configs.Track); err != nil {
return errors.New("Issue with input Track: " + err.Error())
}
if configs.Track == rolloutTrackName {
if configs.UserFraction == "" {
return errors.New("No UserFraction parameter specified")
}
}
if configs.WhatsnewsDir != "" {
if exist, err := pathutil.IsPathExists(configs.WhatsnewsDir); err != nil {
return fmt.Errorf("Failed to check if WhatsnewsDir exist at: %s, error: %s", configs.WhatsnewsDir, err)
} else if !exist {
return errors.New("WhatsnewsDir not exist at: " + configs.WhatsnewsDir)
}
}
if configs.MappingFile != "" {
if exist, err := pathutil.IsPathExists(configs.MappingFile); err != nil {
return fmt.Errorf("Failed to check if MappingFile exist at: %s, error: %s", configs.MappingFile, err)
} else if !exist {
return errors.New("MappingFile not exist at: " + configs.MappingFile)
}
}
if err := input.ValidateWithOptions(configs.UntrackBlockingVersions, "true", "false"); err != nil {
return errors.New("issue with input UntrackBlockingVersions: " + err.Error())
}
return nil
}
func downloadFile(downloadURL, targetPath string) error {
outFile, err := os.Create(targetPath)
if err != nil {
return fmt.Errorf("failed to create (%s), error: %s", targetPath, err)
}
defer func() {
if err := outFile.Close(); err != nil {
log.Warnf("Failed to close (%s)", targetPath)
}
}()
resp, err := http.Get(downloadURL)
if err != nil {
return fmt.Errorf("failed to download from (%s), error: %s", downloadURL, err)
}
defer func() {
if err := resp.Body.Close(); err != nil {
log.Warnf("failed to close (%s) body", downloadURL)
}
}()
_, err = io.Copy(outFile, resp.Body)
if err != nil {
return fmt.Errorf("failed to download from (%s), error: %s", downloadURL, err)
}
return nil
}
func jwtConfigFromJSONKeyFile(pth string) (*jwt.Config, error) {
jsonKeyBytes, err := fileutil.ReadBytesFromFile(pth)
if err != nil {
return nil, err
}
config, err := google.JWTConfigFromJSON(jsonKeyBytes, androidpublisher.AndroidpublisherScope)
if err != nil {
return nil, err
}
return config, nil
}
func jwtConfigFromP12KeyFile(pth, email string) (*jwt.Config, error) {
cmd := command.New("openssl", "pkcs12", "-in", pth, "-passin", "pass:notasecret", "-nodes")
var outBuffer bytes.Buffer
outWriter := bufio.NewWriter(&outBuffer)
cmd.SetStdout(outWriter)
var errBuffer bytes.Buffer
errWriter := bufio.NewWriter(&errBuffer)
cmd.SetStderr(errWriter)
if err := cmd.Run(); err != nil {
if !errorutil.IsExitStatusError(err) {
return nil, err
}
return nil, errors.New(string(errBuffer.Bytes()))
}
return &jwt.Config{
Email: email,
PrivateKey: outBuffer.Bytes(),
TokenURL: google.JWTTokenURL,
Scopes: []string{androidpublisher.AndroidpublisherScope},
}, nil
}
func readLocalisedRecentChanges(recentChangesDir string) (map[string]string, error) {
recentChangesMap := map[string]string{}
pattern := filepath.Join(recentChangesDir, "whatsnew-*-*")
recentChangesPaths, err := filepath.Glob(pattern)
if err != nil {
return map[string]string{}, err
}
pattern = `whatsnew-(?P<local>.*-.*)`
re := regexp.MustCompile(pattern)
for _, recentChangesPath := range recentChangesPaths {
matches := re.FindStringSubmatch(recentChangesPath)
if len(matches) == 2 {
lanugage := matches[1]
content, err := fileutil.ReadStringFromFile(recentChangesPath)
if err != nil {
return map[string]string{}, err
}
recentChangesMap[lanugage] = content
}
}
return recentChangesMap, nil
}
func failf(format string, v ...interface{}) {
log.Errorf(format, v...)
os.Exit(1)
}
func prepareKeyPath(keyPath string) (string, bool, error) {
url, err := url.Parse(keyPath)
if err != nil {
return "", false, fmt.Errorf("failed to parse url (%s), error: %s", keyPath, err)
}
return strings.TrimPrefix(keyPath, "file://"), (url.Scheme == "http" || url.Scheme == "https"), nil
}
func main() {
configs := createConfigsModelFromEnvs()
fmt.Println()
configs.print()
if err := configs.validate(); err != nil {
failf("Issue with input: %s", err)
}
//
// Create client
fmt.Println()
log.Infof("Authenticating")
jwtConfig := new(jwt.Config)
jsonKeyPth, isRemote, err := prepareKeyPath(configs.JSONKeyPath)
if err != nil {
failf("Failed to prepare key path (%s), error: %s", configs.JSONKeyPath, err)
}
if isRemote {
tmpDir, err := pathutil.NormalizedOSTempDirPath("__google-play-deploy__")
if err != nil {
failf("Failed to create tmp dir, error: %s", err)
}
jsonKeySource := jsonKeyPth
jsonKeyPth = filepath.Join(tmpDir, "key.json")
if err := downloadFile(jsonKeySource, jsonKeyPth); err != nil {
failf("Failed to download json key file, error: %s", err)
}
}
authConfig, err := jwtConfigFromJSONKeyFile(jsonKeyPth)
if err != nil {
failf("Failed to create auth config from json key file, error: %s", err)
}
jwtConfig = authConfig
client := jwtConfig.Client(oauth2.NoContext)
service, err := androidpublisher.New(client)
if err != nil {
failf("Failed to create publisher service, error: %s", err)
}
log.Donef("Authenticated client created")
//
// Upload APKs
fmt.Println()
log.Infof("Upload apks or app bundle")
versionCodes := []int64{}
apkPaths := strings.Split(configs.ApkPath, "|")
// "main:/file/path/1.obb|patch:/file/path/2.obb"
expansionfileUpload := strings.TrimSpace(configs.ExpansionfilePath) != ""
expansionfilePaths := strings.Split(configs.ExpansionfilePath, "|")
// ------ //
if expansionfileUpload && (len(apkPaths) != len(expansionfilePaths)) {
failf("Mismatching number of APKs(%d) and Expansionfiles(%d)", len(apkPaths), len(expansionfilePaths))
}
for i, apkPath := range apkPaths {
versionCode := int64(0)
packageName := packageNameForApk(apkPath)
apkFile, err := os.Open(apkPath)
if err != nil {
failf("Failed to read apk (%s), error: %s", apkPath, err)
}
fmt.Println()
log.Infof("Preparing to upload %s, with package name: %s ", apkPath, packageName)
//
// Create insert edit
fmt.Println()
log.Infof("Create new edit")
editsService := androidpublisher.NewEditsService(service)
editsInsertCall := editsService.Insert(packageName, nil)
appEdit, err := editsInsertCall.Do()
if err != nil {
failf("Failed to perform edit insert call, error: %s", err)
}
log.Printf(" editID: %s", appEdit.Id)
// ---
//
// List track infos
fmt.Println()
log.Infof("List track infos")
tracksService := androidpublisher.NewEditsTracksService(service)
tracksListCall := tracksService.List(packageName, appEdit.Id)
listResponse, err := tracksListCall.Do()
if err != nil {
failf("Failed to list tracks, error: %s", err)
}
for _, track := range listResponse.Tracks {
log.Printf(" %s versionCodes: %v", track.Track, track.VersionCodes)
}
if strings.HasSuffix(apkPath, "aab") {
editsBundlesService := androidpublisher.NewEditsBundlesService(service)
editsBundlesUploadCall := editsBundlesService.Upload(packageName, appEdit.Id)
editsBundlesUploadCall.Media(apkFile, googleapi.ContentType("application/octet-stream"))
bundle, err := editsBundlesUploadCall.Do()
if err != nil {
failf("Failed to upload app bundle, error: %s", err)
}
log.Printf(" uploaded app bundle version: %d", bundle.VersionCode)
versionCodes = append(versionCodes, bundle.VersionCode)
versionCode = bundle.VersionCode
} else {
editsApksService := androidpublisher.NewEditsApksService(service)
editsApksUploadCall := editsApksService.Upload(packageName, appEdit.Id)
editsApksUploadCall.Media(apkFile, googleapi.ContentType("application/vnd.android.package-archive"))
apk, err := editsApksUploadCall.Do()
if err != nil {
failf("Failed to upload apk, error: %s", err)
}
log.Printf(" uploaded apk version: %d", apk.VersionCode)
versionCodes = append(versionCodes, apk.VersionCode)
versionCode = apk.VersionCode
if expansionfileUpload {
// "main:/file/path/1.obb"
cleanExpfilePath := strings.TrimSpace(expansionfilePaths[i])
if !strings.HasPrefix(cleanExpfilePath, "main:") && !strings.HasPrefix(cleanExpfilePath, "patch:") {
failf("Invalid expansion file config: %s", expansionfilePaths[i])
}
// [0]: "main" [1]:"/file/path/1.obb"
expansionfilePathSplit := strings.Split(cleanExpfilePath, ":")
// "main"
expfileType := strings.TrimSpace(expansionfilePathSplit[0])
// "/file/path/1.obb"
expfilePth := strings.TrimSpace(strings.Join(expansionfilePathSplit[1:], ""))
expansionFile, err := os.Open(expfilePth)
if err != nil {
failf("Failed to read expansion file (%s), error: %s", expansionFile, err)
}
editsExpansionfilesService := androidpublisher.NewEditsExpansionfilesService(service)
editsExpansionfilesCall := editsExpansionfilesService.Upload(packageName, appEdit.Id, versionCode, expfileType)
editsExpansionfilesCall.Media(expansionFile, googleapi.ContentType("application/vnd.android.package-archive"))
if _, err := editsExpansionfilesCall.Do(); err != nil {
failf("Failed to upload expansion file, error: %s", err)
}
}
}
// Upload mapping.txt
if configs.MappingFile != "" && versionCode != 0 {
mappingFile, err := os.Open(configs.MappingFile)
if err != nil {
failf("Failed to read mapping file (%s), error: %s", configs.MappingFile, err)
}
editsDeobfuscationfilesService := androidpublisher.NewEditsDeobfuscationfilesService(service)
editsDeobfuscationfilesUloadCall := editsDeobfuscationfilesService.Upload(packageName, appEdit.Id, versionCode, "proguard")
editsDeobfuscationfilesUloadCall.Media(mappingFile, googleapi.ContentType("application/octet-stream"))
if _, err = editsDeobfuscationfilesUloadCall.Do(); err != nil {
failf("Failed to upload mapping file, error: %s", err)
}
log.Printf(" uploaded mapping file for apk version: %d", versionCode)
if i < len(apkPaths)-1 {
fmt.Println()
}
}
// Update track
fmt.Println()
log.Infof("Update track")
editsTracksService := androidpublisher.NewEditsTracksService(service)
newTrack := androidpublisher.Track{
Track: configs.Track,
VersionCodes: versionCodes,
}
if configs.Track == rolloutTrackName {
userFraction, err := strconv.ParseFloat(configs.UserFraction, 64)
if err != nil {
failf("Failed to parse user fraction, error: %s", err)
}
newTrack.UserFraction = userFraction
}
editsTracksUpdateCall := editsTracksService.Update(packageName, appEdit.Id, configs.Track, &newTrack)
track, err := editsTracksUpdateCall.Do()
if err != nil {
failf("Failed to update track, error: %s", err)
}
log.Printf(" updated track: %s", track.Track)
log.Printf(" assigned apk versions: %v", track.VersionCodes)
// ---
//
// Deactivate blocking apks
untrackApks := (configs.UntrackBlockingVersions == "true")
if untrackApks && configs.Track == alphaTrackName {
fmt.Println()
log.Warnf("UntrackBlockingVersions is set, but selected track is: alpha, nothing to deactivate")
untrackApks = false
}
anyTrackUpdated := false
if untrackApks {
fmt.Println()
log.Infof("Deactivating blocking apk versions")
// List all tracks
tracksService := androidpublisher.NewEditsTracksService(service)
// Collect tracks to update
tracksListCall := tracksService.List(packageName, appEdit.Id)
listResponse, err := tracksListCall.Do()
if err != nil {
failf("Failed to list tracks, error: %s", err)
}
tracks := listResponse.Tracks
possibleTrackNamesToUpdate := []string{}
switch configs.Track {
case betaTrackName:
possibleTrackNamesToUpdate = []string{alphaTrackName}
case rolloutTrackName, productionTrackName:
possibleTrackNamesToUpdate = []string{alphaTrackName, betaTrackName}
}
trackNamesToUpdate := []string{}
for _, track := range tracks {
for _, trackNameToUpdate := range possibleTrackNamesToUpdate {
if trackNameToUpdate == track.Track {
trackNamesToUpdate = append(trackNamesToUpdate, trackNameToUpdate)
}
}
}
log.Printf(" possible tracks to update: %v", trackNamesToUpdate)
for _, trackName := range trackNamesToUpdate {
tracksGetCall := tracksService.Get(packageName, appEdit.Id, trackName)
track, err := tracksGetCall.Do()
if err != nil {
failf("Failed to get track (%s), error: %s", trackName, err)
}
log.Printf(" checking apk versions on track: %s", track.Track)
log.Infof(" versionCodes: %v", track.VersionCodes)
var cleanTrack bool
if len(track.VersionCodes) != len(versionCodes) {
log.Warnf("Mismatching apk count, removing (%v) versions from track: %s", track.VersionCodes, track.Track)
cleanTrack = true
} else {
sort.Slice(track.VersionCodes, func(a, b int) bool { return track.VersionCodes[a] < track.VersionCodes[b] })
sort.Slice(versionCodes, func(a, b int) bool { return versionCodes[a] < versionCodes[b] })
for i := 0; i < len(versionCodes); i++ {
if track.VersionCodes[i] < versionCodes[i] {
log.Warnf("Shadowing APK found, removing (%v) versions from track: %s", track.VersionCodes, track.Track)
cleanTrack = true
break
}
}
}
if cleanTrack {
anyTrackUpdated = true
track.VersionCodes = []int64{}
track.NullFields = []string{"VersionCodes"}
track.ForceSendFields = []string{"VersionCodes"}
tracksUpdateCall := tracksService.Patch(packageName, appEdit.Id, trackName, track)
if _, err := tracksUpdateCall.Do(); err != nil && err != io.EOF {
failf("Failed to update track (%s), error: %s", trackName, err)
}
}
}
if anyTrackUpdated {
log.Donef("Desired versions deactivated")
} else {
log.Donef("No blocking apk version found")
}
}
// ---
//
// Update listing
if configs.WhatsnewsDir != "" {
fmt.Println()
log.Infof("Update listing")
recentChangesMap, err := readLocalisedRecentChanges(configs.WhatsnewsDir)
if err != nil {
failf("Failed to read whatsnews, error: %s", err)
}
editsApklistingsService := androidpublisher.NewEditsApklistingsService(service)
for _, versionCode := range versionCodes {
log.Printf(" updating recent changes for version: %d", versionCode)
for language, recentChanges := range recentChangesMap {
newApkListing := androidpublisher.ApkListing{
Language: language,
RecentChanges: recentChanges,
}
editsApkListingsCall := editsApklistingsService.Update(packageName, appEdit.Id, versionCode, language, &newApkListing)
apkListing, err := editsApkListingsCall.Do()
if err != nil {
failf("Failed to update listing, error: %s", err)
}
log.Printf(" - language: %s", apkListing.Language)
}
}
}
// ---
//
// Validate edit
fmt.Println()
log.Infof("Validating edit")
editsValidateCall := editsService.Validate(packageName, appEdit.Id)
if _, err := editsValidateCall.Do(); err != nil {
failf("Failed to validate edit, error: %s", err)
}
log.Donef("Edit is valid")
// ---
//
// Commit edit
fmt.Println()
log.Infof("Committing edit")
editsCommitCall := editsService.Commit(packageName, appEdit.Id)
if _, err := editsCommitCall.Do(); err != nil {
failf("Failed to commit edit, error: %s", err)
}
log.Donef("Edit committed")
// ---
}
}