|
@@ -100,27 +100,76 @@ findVersion:
|
|
|
}
|
|
|
|
|
|
func publishTestflight(ctx context.Context) error {
|
|
|
+ tagVersion, err := build_shared.ReadTagVersion()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ tag := tagVersion.VersionString()
|
|
|
client := createClient()
|
|
|
- var buildsToPublish []asc.Build
|
|
|
- for _, platform := range []string{
|
|
|
- "IOS",
|
|
|
- "MAC_OS",
|
|
|
- "TV_OS",
|
|
|
+
|
|
|
+ buildIDsResponse, _, err := client.TestFlight.ListBuildIDsForBetaGroup(ctx, groupID, nil)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ buildIDS := common.Map(buildIDsResponse.Data, func(it asc.RelationshipData) string {
|
|
|
+ return it.ID
|
|
|
+ })
|
|
|
+ for _, platform := range []asc.Platform{
|
|
|
+ asc.PlatformIOS,
|
|
|
+ asc.PlatformMACOS,
|
|
|
+ asc.PlatformTVOS,
|
|
|
} {
|
|
|
+ log.Info(string(platform), " list builds")
|
|
|
builds, _, err := client.Builds.ListBuilds(ctx, &asc.ListBuildsQuery{
|
|
|
FilterApp: []string{appID},
|
|
|
- FilterPreReleaseVersionPlatform: []string{platform},
|
|
|
+ FilterPreReleaseVersionPlatform: []string{string(platform)},
|
|
|
})
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- buildsToPublish = append(buildsToPublish, builds.Data[0])
|
|
|
- }
|
|
|
- _, err := client.TestFlight.AddBuildsToBetaGroup(ctx, groupID, common.Map(buildsToPublish, func(it asc.Build) string {
|
|
|
- return it.ID
|
|
|
- }))
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
+ log.Info(string(platform), " ", tag, " list localizations")
|
|
|
+ localizations, _, err := client.TestFlight.ListBetaBuildLocalizationsForBuild(ctx, builds.Data[0].ID, nil)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ localization := common.Find(localizations.Data, func(it asc.BetaBuildLocalization) bool {
|
|
|
+ return *it.Attributes.Locale == "en-US"
|
|
|
+ })
|
|
|
+ if localization.ID == "" {
|
|
|
+ log.Fatal(string(platform), " ", tag, " no en-US localization found")
|
|
|
+ }
|
|
|
+ if localization.Attributes == nil || localization.Attributes.WhatsNew == nil || *localization.Attributes.WhatsNew == "" {
|
|
|
+ log.Info(string(platform), " ", tag, " update localization")
|
|
|
+ _, _, err = client.TestFlight.UpdateBetaBuildLocalization(ctx, localization.ID, common.Ptr(
|
|
|
+ F.ToString("sing-box ", tag),
|
|
|
+ ))
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !common.Contains(buildIDS, builds.Data[0].ID) {
|
|
|
+ log.Info(string(platform), " ", tag, " publish")
|
|
|
+ _, err = client.TestFlight.AddBuildsToBetaGroup(ctx, groupID, []string{builds.Data[0].ID})
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Info(string(platform), " ", tag, " list submissions")
|
|
|
+ betaSubmissions, _, err := client.TestFlight.ListBetaAppReviewSubmissions(ctx, &asc.ListBetaAppReviewSubmissionsQuery{
|
|
|
+ FilterBuild: []string{builds.Data[0].ID},
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if len(betaSubmissions.Data) == 0 {
|
|
|
+ log.Info(string(platform), " ", tag, " create submission")
|
|
|
+ _, _, err = client.TestFlight.CreateBetaAppReviewSubmission(ctx, builds.Data[0].ID)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return nil
|
|
|
}
|