Skip to content

Commit

Permalink
Step 167 apple dev conn (#65)
Browse files Browse the repository at this point in the history
* Wire in new devportalservice.

* Go vendor update.

* Expose FASTLANE_SESSION only for the fastlane command.

* Update apple developer connection related logs.

* Update devportalservice package.

* Wire in latest devportalservice.

* Update vendor.
  • Loading branch information
godrei authored Jan 12, 2021
1 parent 52fbec2 commit 55549c4
Show file tree
Hide file tree
Showing 18 changed files with 452 additions and 299 deletions.
15 changes: 5 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ require (
github.com/bitrise-io/bitrise-init v0.0.0-20190813135927-7ff42ba329cb
github.com/bitrise-io/envman v0.0.0-20190813133714-27a300a1ed43 // indirect
github.com/bitrise-io/go-steputils v0.0.0-20190806143347-f540824d77df
github.com/bitrise-io/go-utils v0.0.0-20191108114511-5067a2a682f2
github.com/bitrise-io/go-xcode v0.0.0-20190718082554-07ccf582b6b1 // indirect
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27 // indirect
github.com/bitrise-io/go-utils v0.0.0-20201211082830-859032e9adf0
github.com/bitrise-io/stepman v0.0.0-20190813144014-10564a4888a6 // indirect
github.com/bitrise-io/xcode-project v0.0.0-20190829132102-743450f7d0f0 // indirect
github.com/bitrise-steplib/bitrise-step-android-unit-test v0.0.0-20190902203028-ff8e682d8645
github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver v0.0.0-20190815132021-09bfb54640c4
github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver v0.0.0-20210111151319-1426de4b985f
github.com/google/go-cmp v0.5.4 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/pkg/errors v0.8.1 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect
golang.org/x/text v0.3.2 // indirect
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)
57 changes: 29 additions & 28 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,57 @@ github.com/bitrise-io/envman v0.0.0-20190813133714-27a300a1ed43 h1:BRhP0pS7NPK4i
github.com/bitrise-io/envman v0.0.0-20190813133714-27a300a1ed43/go.mod h1:m8pTp1o3Sw9uzDxb1WRm5IBRnMau2iOvPMSnRCAhQNI=
github.com/bitrise-io/go-steputils v0.0.0-20190806143347-f540824d77df h1:UaDw6nAsI2jlGjNqhdMUbk0xhJJ+iQZ1buEXHRKrtU8=
github.com/bitrise-io/go-steputils v0.0.0-20190806143347-f540824d77df/go.mod h1:GXgBV3Frd3qcnsg+NryQTyx1CHjZHr/2w7Bx4WAcB4o=
github.com/bitrise-io/go-utils v0.0.0-20190814105345-ad86bf775472 h1:jM4pIBkBUOucinQ2IdlfbpIZxJqgS/k1TZZrENFej8A=
github.com/bitrise-io/go-utils v0.0.0-20190814105345-ad86bf775472/go.mod h1:Pp48eQd8BSNEzWWTBxdFUd/ufS5b5Bgkmt9D5NedjWg=
github.com/bitrise-io/go-utils v0.0.0-20191108114511-5067a2a682f2 h1:8tMyx5oOXSeVEG5VCxfLmwcqYEApVHKn/y6vU7an1Z8=
github.com/bitrise-io/go-utils v0.0.0-20191108114511-5067a2a682f2/go.mod h1:Pp48eQd8BSNEzWWTBxdFUd/ufS5b5Bgkmt9D5NedjWg=
github.com/bitrise-io/go-xcode v0.0.0-20190718082554-07ccf582b6b1 h1:Om1A4iSAyR4G8sEi1VYRfJrEHbmskSpeSeK0+uAVqqc=
github.com/bitrise-io/go-xcode v0.0.0-20190718082554-07ccf582b6b1/go.mod h1:EFvdJln2CESNPSz2+ChAGOtfHNN/l56csk1nuRnz8nI=
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27 h1:NuGIfwKcZvdR1RT4sQ32kE8h35w9XQjQrrCJPJqS4ek=
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27/go.mod h1:G0M1sK06a1l0KAg4rQei7q5dDKC/JrZoaXFqak91osU=
github.com/bitrise-io/go-utils v0.0.0-20201211082830-859032e9adf0 h1:HR5o2gHKo0rAMfKogclAg4KOnEX8XniC7A3JFuEAXjY=
github.com/bitrise-io/go-utils v0.0.0-20201211082830-859032e9adf0/go.mod h1:tTEsKvbz1LbzuN/KpVFHXnLtcAPdEgIdM41s0lL407s=
github.com/bitrise-io/stepman v0.0.0-20190813144014-10564a4888a6 h1:/GnB2kEaO/6KSMfGpmntvohfacADpWFcf8iCPLsZqh4=
github.com/bitrise-io/stepman v0.0.0-20190813144014-10564a4888a6/go.mod h1:hGCjd8leP411yt5QkQi+VBNWGxIZ4H02LNIVeKBeMUk=
github.com/bitrise-io/xcode-project v0.0.0-20190829132102-743450f7d0f0 h1:Ft6zMZVUwyzJPyqgDMROm6tHaLyWabs27jr8psYHKyU=
github.com/bitrise-io/xcode-project v0.0.0-20190829132102-743450f7d0f0/go.mod h1:L7ue7ix2GIAf0pQovKmWub7l956nsHU68kk5fU4KczQ=
github.com/bitrise-steplib/bitrise-step-android-unit-test v0.0.0-20190830131210-9d5c1d4e8630 h1:cT8ax87pLOCCE+OaEhT2VXQiMFc1V44xfjENA/jF6r0=
github.com/bitrise-steplib/bitrise-step-android-unit-test v0.0.0-20190830131210-9d5c1d4e8630/go.mod h1:0yqqJw+MqwsfHKq4pL90IoSYskLF91oDCyyZYnIehWA=
github.com/bitrise-steplib/bitrise-step-android-unit-test v0.0.0-20190902203028-ff8e682d8645 h1:9molXzIAxnKStwV78lt7MSgUQwxIWl4+r9/oYTQA7no=
github.com/bitrise-steplib/bitrise-step-android-unit-test v0.0.0-20190902203028-ff8e682d8645/go.mod h1:0yqqJw+MqwsfHKq4pL90IoSYskLF91oDCyyZYnIehWA=
github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver v0.0.0-20190815132021-09bfb54640c4 h1:rzEqvBYa+WJ44mAsiD4DAW4zX6vLjdwAg3nvJSqkJc4=
github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver v0.0.0-20190815132021-09bfb54640c4/go.mod h1:mm5WIhfyTnf89pNO+4ylSsUAbEh8JGSpV3F7V0XWB4U=
github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver v0.0.0-20210111151319-1426de4b985f h1:50OrOc2xqKRXBsC3lfryzm75/QHhltDR2HAIWtHjvJk=
github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver v0.0.0-20210111151319-1426de4b985f/go.mod h1:mm5WIhfyTnf89pNO+4ylSsUAbEh8JGSpV3F7V0XWB4U=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200220224806-8a925fa4c0df/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
46 changes: 30 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/bitrise-io/go-steputils/cache"
"github.com/bitrise-io/go-steputils/stepconf"
"github.com/bitrise-io/go-steputils/tools"
"github.com/bitrise-io/go-utils/command"
"github.com/bitrise-io/go-utils/command/gems"
"github.com/bitrise-io/go-utils/command/rubycommand"
Expand Down Expand Up @@ -73,11 +72,11 @@ func handleSessionDataError(err error) {
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/")
log.Debugf("Read more: https://devcenter.bitrise.io/getting-started/configuring-bitrise-steps-that-require-apple-developer-account-data/")
} 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/")
log.Warnf("Read more: https://devcenter.bitrise.io/getting-started/configuring-bitrise-steps-that-require-apple-developer-account-data/")
}
}

Expand Down Expand Up @@ -130,22 +129,31 @@ func main() {

//
// Fastlane session
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")
fastlaneSession := ""
buildURL, buildAPIToken := os.Getenv("BITRISE_BUILD_URL"), os.Getenv("BITRISE_BUILD_API_TOKEN")
if buildURL != "" && buildAPIToken != "" {
var provider devportalservice.AppleDeveloperConnectionProvider
provider = devportalservice.NewBitriseClient(http.DefaultClient)

if err := tools.ExportEnvironmentWithEnvman("FASTLANE_SESSION", fs); err != nil {
failf("Failed to export FASTLANE_SESSION, error: %s", err)
conn, err := provider.GetAppleDeveloperConnection(buildURL, buildAPIToken)
if err != nil {
handleSessionDataError(err)
}

if err := os.Setenv("FASTLANE_SESSION", fs); err != nil {
failf("Failed to set FASTLANE_SESSION env, error: %s", err)
}
if conn != nil && conn.AppleID != "" {
fmt.Println()
log.Infof("Connected session-based Apple Developer Portal Account found")

log.Donef("Session exported")
if expiry := conn.Expiry(); expiry != nil && conn.Expired() {
log.Warnf("Connection expired on %s", expiry.String())
} else if session, err := conn.FastlaneLoginSession(); err != nil {
handleSessionDataError(err)
} else {
fastlaneSession = session
}
}
} else {
log.Warnf("Step is not running on bitrise.io: BITRISE_BUILD_URL and BITRISE_BUILD_API_TOKEN envs are not set")
}

// Split lane option
Expand Down Expand Up @@ -209,7 +217,7 @@ func main() {
} else if config.UpdateFastlane {
log.Infof("Update system installed Fastlane")

cmds, err := rubycommand.GemInstall("fastlane", "")
cmds, err := rubycommand.GemInstall("fastlane", "", false)
if err != nil {
failf("Failed to create command model, error: %s", err)
}
Expand Down Expand Up @@ -267,8 +275,14 @@ func main() {
failf("Failed to create command model, error: %s", err)
}

envs := []string{}
if fastlaneSession != "" {
envs = append(envs, "FASTLANE_SESSION="+fastlaneSession)
}

cmd.SetStdout(os.Stdout).SetStderr(os.Stderr)
cmd.SetDir(workDir)
cmd.AppendEnvs(envs...)

buildlogPth := ""

Expand Down
19 changes: 4 additions & 15 deletions vendor/github.com/bitrise-io/go-utils/command/command.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.

36 changes: 0 additions & 36 deletions vendor/github.com/bitrise-io/go-utils/errorutil/errorutil.go

This file was deleted.

10 changes: 10 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/fileutil/fileutil.go

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

14 changes: 14 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/sliceutil/sliceutil.go

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

Loading

0 comments on commit 55549c4

Please sign in to comment.