Skip to content

Commit

Permalink
Tool 954 dev portal data (#51)
Browse files Browse the repository at this point in the history
* print getDeveloperPortalData status code

* introduce and handle NetworkError

* do not recreate an error if performRequest fails

* log fix

* log fixes

* pr dixes

* removed go dependency
  • Loading branch information
godrei authored Jul 26, 2019
1 parent f446b7b commit 4fcb9f5
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 36 deletions.
10 changes: 5 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 27 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"net/http"
"os"
"path/filepath"
"strings"
Expand All @@ -25,6 +26,7 @@ type Config struct {
WorkDir string `env:"work_dir,dir"`
Lane string `env:"lane,required"`
UpdateFastlane bool `env:"update_fastlane,opt[true,false]"`
VerboseLog bool `env:"verbose_log,opt[yes,no]"`

GemHome string `env:"GEM_HOME"`
}
Expand Down Expand Up @@ -58,13 +60,31 @@ func fastlaneDebugInfo(workDir string, useBundler bool, bundlerVersion gems.Vers
return outBuffer.String(), nil
}

func handleSessionDataError(err error) {
if err == nil {
return
}

if networkErr, ok := err.(devportalservice.NetworkError); ok && networkErr.Status == http.StatusNotFound {
log.Debugf("")
log.Debugf("Connected Apple Developer Portal Account not found")
log.Debugf("Most likely because there is no Apple Developer Portal Account connected to the build, or the build is running locally.")
log.Debugf("Read more: https://devcenter.bitrise.io/getting-started/connecting-apple-dev-account/")
} else {
fmt.Println()
log.Errorf("Failed to activate Bitrise Apple Developer Portal connection: %s", err)
log.Warnf("Read more: https://devcenter.bitrise.io/getting-started/connecting-apple-dev-account/")
}
}

func main() {
var config Config
if err := stepconf.Parse(&config); err != nil {
failf("Issue with input: %s", err)
}

stepconf.Print(config)
log.SetEnableDebugLog(config.VerboseLog)
fmt.Println()

if strings.TrimSpace(config.GemHome) != "" {
Expand Down Expand Up @@ -102,16 +122,13 @@ func main() {

//
// Fastlane session
fmt.Println()
log.Infof("Ensure cookies for Apple Developer Portal")

fs, errors := devportalservice.SessionData()
if errors != nil {
log.Warnf("Failed to activate the Bitrise Apple Developer Portal connection: %s\nRead more: https://devcenter.bitrise.io/getting-started/connecting-apple-dev-account/ \nerrors:")
for _, err := range errors {
log.Errorf("%s\n", err)
}
fs, err := devportalservice.SessionData()
if err != nil {
handleSessionDataError(err)
} else {
fmt.Println()
log.Infof("Connected Apple Developer Portal Account found, exposing FASTLANE_SESSION env var")

if err := tools.ExportEnvironmentWithEnvman("FASTLANE_SESSION", fs); err != nil {
failf("Failed to export FASTLANE_SESSION, error: %s", err)
}
Expand Down Expand Up @@ -147,7 +164,6 @@ func main() {

// Install desired Fastlane version
if useBundler {
fmt.Println()
log.Infof("Install bundler")

// install bundler with `gem install bundler [-v version]`
Expand Down Expand Up @@ -205,7 +221,7 @@ func main() {
}

fmt.Println()
log.Infof("Fastlane version:")
log.Infof("Fastlane version")

versionCmd := []string{"fastlane", "--version"}
if useBundler {
Expand Down
14 changes: 8 additions & 6 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ source_code_url: https://github.com/bitrise-io/steps-fastlane
support_url: https://github.com/bitrise-io/steps-fastlane/issues
type_tags:
- utility
deps:
brew:
- name: go
apt_get:
- name: golang
bin_name: go
toolkit:
go:
package_name: github.com/bitrise-io/steps-fastlane
Expand Down Expand Up @@ -52,3 +46,11 @@ inputs:
value_options:
- "true"
- "false"
- verbose_log: "no"
opts:
title: "Enable verbose logging?"
description: Enable verbose logging?
is_required: true
value_options:
- "yes"
- "no"
5 changes: 5 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/pathutil/pathutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4fcb9f5

Please sign in to comment.