Skip to content

Commit

Permalink
Enable uploading to tracks that not yet comtain an apk. (#72)
Browse files Browse the repository at this point in the history
* Enable uploading to tracks that not yet comtain an apk.

* Removing unused code.
  • Loading branch information
lpusok authored Jul 3, 2020
1 parent 74f4eff commit a2c3255
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 63 deletions.
19 changes: 5 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,6 @@ func uploadApplications(configs Configs, service *androidpublisher.Service, appE
func updateTracks(configs Configs, service *androidpublisher.Service, appEdit *androidpublisher.AppEdit, versionCodes []int64) error {
editsTracksService := androidpublisher.NewEditsTracksService(service)

allTracks, err := getAllTracks(configs.PackageName, service, appEdit)
if err != nil {
return fmt.Errorf("failed to list tracks, error: %s", err)
}

trackToUpdate, err := getTrack(configs.Track, allTracks)
if err != nil {
return err
}
log.Infof("%s track will be updated.", trackToUpdate.Track)

newRelease, err := createTrackRelease(configs.WhatsnewsDir, versionCodes, configs.UserFraction)
if err != nil {
return err
Expand All @@ -103,9 +92,11 @@ func updateTracks(configs Configs, service *androidpublisher.Service, appEdit *a
// inProgress preserves complete release even if not specified in releases array.
// In case only a completed release specified, it halts inProgress releases.

trackToUpdate.Releases = []*androidpublisher.TrackRelease{newRelease}

editsTracksUpdateCall := editsTracksService.Update(configs.PackageName, appEdit.Id, configs.Track, trackToUpdate)
log.Infof("%s track will be updated.", configs.Track)
editsTracksUpdateCall := editsTracksService.Update(configs.PackageName, appEdit.Id, configs.Track, &androidpublisher.Track{
Track: configs.Track,
Releases: []*androidpublisher.TrackRelease{newRelease},
})
track, err := editsTracksUpdateCall.Do()
if err != nil {
return fmt.Errorf("update call failed, error: %s", err)
Expand Down
22 changes: 0 additions & 22 deletions print.go

This file was deleted.

27 changes: 0 additions & 27 deletions publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,30 +214,3 @@ func releaseStatusFromConfig(userFraction float64) string {
}
return releaseStatusCompleted
}

// getTrack gets the given track from the list of tracks of a given app.
func getTrack(trackName string, allTracks []*androidpublisher.Track) (*androidpublisher.Track, error) {
for _, track := range allTracks {
if trackName == track.Track {
log.Debugf("Current track found, name '%s'", trackName)
return track, nil
}
}

return nil, fmt.Errorf("could not find track with name %s", trackName)
}

// getAllTracks lists all tracks for a given app.
func getAllTracks(packageName string, service *androidpublisher.Service, appEdit *androidpublisher.AppEdit) ([]*androidpublisher.Track, error) {
log.Infof("Listing tracks")
tracksService := androidpublisher.NewEditsTracksService(service)
tracksListCall := tracksService.List(packageName, appEdit.Id)
listResponse, err := tracksListCall.Do()
if err != nil {
return []*androidpublisher.Track{}, fmt.Errorf("failed to list tracks, error: %s", err)
}
for _, track := range listResponse.Tracks {
log.Infof(trackToString(track))
}
return listResponse.Tracks, nil
}

0 comments on commit a2c3255

Please sign in to comment.