Skip to content

Commit

Permalink
Enterprise api key support (#31)
Browse files Browse the repository at this point in the history
* Update go-xcode

* Add api_key_enterprise_account step input
  • Loading branch information
godrei authored Nov 21, 2024
1 parent 04c4ff9 commit 761d6e2
Show file tree
Hide file tree
Showing 34 changed files with 383 additions and 495 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris
| `keychain_password` | Password for the provided Keychain. | required, sensitive | `$BITRISE_KEYCHAIN_PASSWORD` |
| `build_url` | URL of the current Bitrise build. | | `$BITRISE_BUILD_URL` |
| `build_api_token` | API token to access Bitrise resources during the current build. | sensitive | `$BITRISE_BUILD_API_TOKEN` |
| `api_key_path` | Local path or remote URL to the private key (p8 file) for App Store Connect API. This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise. The input value can be a file path (eg. `$TMPDIR/private_key.p8`) or an HTTPS URL. This input only takes effect if the other two connection override inputs are set too (`api_key_id`, `api_key_issuer_id`). | | |
| `api_key_id` | Private key ID used for App Store Connect authentication. This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise. This input only takes effect if the other two connection override inputs are set too (`api_key_path`, `api_key_issuer_id`). | | |
| `api_key_issuer_id` | Private key issuer ID used for App Store Connect authentication. This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise. This input only takes effect if the other two connection override inputs are set too (`api_key_path`, `api_key_id`). | | |
| `api_key_path` | Local path or remote URL to the private key (p8 file) for App Store Connect API. This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise. The input value can be a file path (eg. `$TMPDIR/private_key.p8`) or an HTTPS URL. This input only takes effect if the other two connection override inputs are set too (`api_key_id`, `api_key_issuer_id`). | | |
| `api_key_id` | Private key ID used for App Store Connect authentication. This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise. This input only takes effect if the other two connection override inputs are set too (`api_key_path`, `api_key_issuer_id`). | | |
| `api_key_issuer_id` | Private key issuer ID used for App Store Connect authentication. This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise. This input only takes effect if the other two connection override inputs are set too (`api_key_path`, `api_key_id`). | | |
| `api_key_enterprise_account` | Indicates if the account is an enterprise type. This overrides the Bitrise-managed API connection, only set this input if you know you have an enterprise account. | required | `no` |
| `verbose_log` | If this input is set, the Step will produce verbose level log messages. | required | `no` |
</details>

Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Config struct {
APIKeyPath stepconf.Secret `env:"api_key_path"`
APIKeyID string `env:"api_key_id"`
APIKeyIssuerID string `env:"api_key_issuer_id"`
APIKeyEnterpriseAccount bool `env:"api_key_enterprise_account,opt[yes,no]"`

VerboseLog bool `env:"verbose_log,opt[no,yes]"`
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/bitrise-io/go-utils v1.0.12
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23
github.com/bitrise-io/go-xcode v1.1.1
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.48
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.50
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23 h1:Dfh4nyZPuEtilBisidejqxBrkx9
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23/go.mod h1:3XUplo0dOWc3DqT2XA2SeHToDSg7+j1y1HTHibT2H68=
github.com/bitrise-io/go-xcode v1.1.1 h1:Krfa8iYZZWdLBuH7AXbufFZwL+Pys7etqvd8+Ehdwt8=
github.com/bitrise-io/go-xcode v1.1.1/go.mod h1:9OwsvrhZ4A2JxHVoEY7CPcABAKA+OE7FQqFfBfvbFuY=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.48 h1:nsd41UsIGZrPy94tlFxoDCfH2I19A9buPOA/cLgucjA=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.48/go.mod h1:KpxSPrRLgY0fscSajOyO/5h7MhapsqnSJr17oXEaPsg=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.50 h1:vh3miMo4lZb5fz8D1Tca0AerRv2hO3gZS4R5nEeSXKg=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.50/go.mod h1:KpxSPrRLgY0fscSajOyO/5h7MhapsqnSJr17oXEaPsg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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=
Expand Down
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/bitrise-io/go-utils/retry"
"github.com/bitrise-io/go-utils/v2/command"
"github.com/bitrise-io/go-utils/v2/env"
"github.com/bitrise-io/go-utils/v2/fileutil"
"github.com/bitrise-io/go-utils/v2/log"
"github.com/bitrise-io/go-xcode/certificateutil"
"github.com/bitrise-io/go-xcode/devportalservice"
"github.com/bitrise-io/go-xcode/utility"
"github.com/bitrise-io/go-xcode/v2/autocodesign"
"github.com/bitrise-io/go-xcode/v2/autocodesign/certdownloader"
Expand All @@ -22,6 +22,7 @@ import (
"github.com/bitrise-io/go-xcode/v2/autocodesign/localcodesignasset"
"github.com/bitrise-io/go-xcode/v2/autocodesign/projectmanager"
"github.com/bitrise-io/go-xcode/v2/codesign"
"github.com/bitrise-io/go-xcode/v2/devportalservice"
"github.com/bitrise-io/go-xcode/xcodebuild"
)

Expand Down Expand Up @@ -117,9 +118,10 @@ func main() {
failf(err.Error())
}

fileManager := fileutil.NewFileManager()
var connection *devportalservice.AppleDeveloperConnection
if cfg.BuildURL != "" && cfg.BuildAPIToken != "" {
f := devportalclient.NewFactory(logger)
f := devportalclient.NewFactory(logger, fileManager)
connection, err = f.CreateBitriseConnection(cfg.BuildURL, cfg.BuildAPIToken)
if err != nil {
failf(err.Error())
Expand All @@ -131,9 +133,10 @@ func main() {
}

connectionInputs := codesign.ConnectionOverrideInputs{
APIKeyPath: cfg.APIKeyPath,
APIKeyID: cfg.APIKeyID,
APIKeyIssuerID: cfg.APIKeyIssuerID,
APIKeyPath: cfg.APIKeyPath,
APIKeyID: cfg.APIKeyID,
APIKeyIssuerID: cfg.APIKeyIssuerID,
APIKeyEnterpriseAccount: cfg.APIKeyEnterpriseAccount,
}
appleAuthCredentials, err := codesign.SelectConnectionCredentials(authType, connection, connectionInputs, logger)
if err != nil {
Expand All @@ -145,7 +148,7 @@ func main() {
failf(fmt.Sprintf("failed to initialize keychain: %s", err))
}

devPortalClientFactory := devportalclient.NewFactory(logger)
devPortalClientFactory := devportalclient.NewFactory(logger, fileManager)
certDownloader := certdownloader.NewDownloader(codesignConfig.CertificatesAndPassphrases, retry.NewHTTPClient().StandardClient())
assetWriter := codesignasset.NewWriter(*keychain)
localCodesignAssetManager := localcodesignasset.NewManager(localcodesignasset.NewProvisioningProfileProvider(), localcodesignasset.NewProvisioningProfileConverter())
Expand Down
23 changes: 13 additions & 10 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,10 @@ inputs:
summary: Local path or remote URL to the private key (p8 file). This overrides the Bitrise-managed API connection.
description: |-
Local path or remote URL to the private key (p8 file) for App Store Connect API.
This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection
on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise.
The input value can be a file path (eg. `$TMPDIR/private_key.p8`) or an HTTPS URL.
This input only takes effect if the other two connection override inputs are set too (`api_key_id`, `api_key_issuer_id`).
is_required: false
- api_key_id:
opts:
Expand All @@ -240,12 +236,9 @@ inputs:
summary: Private key ID used for App Store Connect authentication. This overrides the Bitrise-managed API connection.
description: |-
Private key ID used for App Store Connect authentication.
This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection
on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise.
This input only takes effect if the other two connection override inputs are set too (`api_key_path`, `api_key_issuer_id`).
is_required: false
- api_key_issuer_id:
opts:
Expand All @@ -254,12 +247,22 @@ inputs:
summary: Private key issuer ID used for App Store Connect authentication. This overrides the Bitrise-managed API connection.
description: |-
Private key issuer ID used for App Store Connect authentication.
This overrides the Bitrise-managed API connection, only set this input if you want to control the API connection
on a step-level. Most of the time it's easier to set up the connection on the App Settings page on Bitrise.
This input only takes effect if the other two connection override inputs are set too (`api_key_path`, `api_key_id`).
is_required: false
- api_key_enterprise_account: "no"
opts:
category: App Store Connect connection override
title: App Store Connect API enterprise account
summary: Indicates if the account is an enterprise type. This overrides the Bitrise-managed API connection.
description: |-
Indicates if the account is an enterprise type.
This overrides the Bitrise-managed API connection, only set this input if you know you have an enterprise account.
value_options:
- "yes"
- "no"
is_required: true

# Debugging

Expand Down
105 changes: 105 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/v2/fileutil/fileutil.go

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

Loading

0 comments on commit 761d6e2

Please sign in to comment.