-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for API key (App Store Connect API), from Bitrise Developer Connection and Step inputs. For Apple ID, now also passing the username/password/app-specific password in addition to the session (FASTLANE_SESSION) as they seem to be required by Fastlane. Any authentication-related environment that is already set will be overridden, to prevent this set *Bitrise Apple Developer Connection* (`connection`) input to `off` and leave authentication-related inputs empty. This includes DELIVER_USERNAME, DELIVER_PASSWORD, FASTLANE_SESSION, FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD, DELIVER_API_KEY_PATH and PRECHECK_INCLUDE_IN_APP_PURCHASES.
- Loading branch information
Showing
18 changed files
with
1,032 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.bitrise* | ||
_tmp | ||
.idea | ||
steps-fastlane | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,67 @@ | ||
format_version: 7 | ||
format_version: "11" | ||
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||
|
||
workflows: | ||
# ---------------------------------------------------------------- | ||
# --- workflow to test this step | ||
ci: | ||
before_run: | ||
- audit-this-step | ||
- go-tests | ||
after_run: | ||
- test | ||
|
||
go-tests: | ||
steps: | ||
- go-list: {} | ||
- golint: {} | ||
- errcheck: {} | ||
- go-test: {} | ||
|
||
test: | ||
before_run: | ||
- auth-all | ||
- cache | ||
|
||
auth-all: | ||
before_run: | ||
- auth-test-api-key-connection | ||
- auth-test-apple-id-connection | ||
- auth-test-apple-id-connection-globally-set-app-specific-password | ||
- auth-test-api-key-input | ||
|
||
cache: | ||
envs: | ||
- SAMPLE_APP_URL: "https://github.com/bitrise-io/sample-apps-flutter-veggieseasons.git" | ||
- BRANCH: master | ||
before-run: | ||
- audit-this-step | ||
steps: | ||
- go-list: | ||
- golint: | ||
- errcheck: | ||
- go-test: | ||
- script: | ||
inputs: | ||
- content: rm -rf ./_tmp | ||
- change-workdir: | ||
title: Switch working dir to test/_tmp dir | ||
run_if: true | ||
run_if: "true" | ||
inputs: | ||
- path: ./_tmp | ||
- is_create_path: true | ||
- script: | ||
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone: | ||
inputs: | ||
- content: |- | ||
set -ex | ||
git clone $SAMPLE_APP_URL -b $BRANCH . | ||
- repository_url: $SAMPLE_APP_URL | ||
- branch: $BRANCH | ||
- clone_into_dir: "." | ||
- path::./: | ||
title: Test if Fastlane receives session-based Apple Developer connection | ||
title: Smoke test to check if Fastlane receives session-based Apple Developer connection | ||
inputs: | ||
- lane: test_fastlane_session | ||
- work_dir: ./ | ||
- verbose_log: "yes" | ||
- certificate-and-profile-installer: | ||
- connection: apple_id | ||
- certificate-and-profile-installer: {} | ||
- path::./: | ||
title: Test building a Flutter project | ||
inputs: | ||
- lane: build | ||
- work_dir: ./ | ||
- verbose_log: "yes" | ||
- connection: "off" | ||
- script: | ||
inputs: | ||
- content: |- | ||
|
@@ -56,51 +76,103 @@ workflows: | |
exit 1 | ||
fi | ||
fastlane-session-test: | ||
auth-test-apple-id-connection: | ||
before_run: | ||
- _auth_prepare | ||
steps: | ||
- path::./: | ||
inputs: | ||
- lane: release | ||
- work_dir: ./ | ||
- verbose_log: "yes" | ||
- connection: apple_id | ||
- app_password: $FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD | ||
|
||
auth-test-apple-id-connection-globally-set-app-specific-password: | ||
before_run: | ||
- _auth_prepare | ||
steps: | ||
- path::./: | ||
inputs: | ||
- lane: release | ||
- work_dir: ./ | ||
- verbose_log: "yes" | ||
- connection: apple_id | ||
- app_password: "" | ||
|
||
auth-test-api-key-connection: | ||
before_run: | ||
- _auth_prepare | ||
steps: | ||
- path::./: | ||
inputs: | ||
- lane: release | ||
- work_dir: ./ | ||
- verbose_log: "yes" | ||
- connection: api_key | ||
|
||
auth-test-api-key-input: | ||
before_run: | ||
- _auth_prepare | ||
steps: | ||
- path::./: | ||
inputs: | ||
- lane: release | ||
- work_dir: ./ | ||
- verbose_log: "yes" | ||
- connection: "off" | ||
- api_issuer: $AUTH_API_ISSUER | ||
- api_key_path: $BITRISEIO_AUTH_API_KEY_PATH_URL | ||
|
||
_auth_prepare: | ||
envs: | ||
- SAMPLE_APP_URL: "https://github.com/bitrise-samples/sample-apps-fastlane-test.git" | ||
- BITRISE_PROJECT_PATH: ./sample-apps-fastlane-test.xcodeproj | ||
- BITRISE_SCHEME: sample-apps-fastlane-test | ||
- BRANCH: master | ||
- INFO_PLIST_PATH: ./sample-apps-fastlane-test/Info.plist | ||
steps: | ||
- script: | ||
title: Clean saved Fastlane session cookie | ||
inputs: | ||
- content: rm -rf ~/.fastlane | ||
- script: | ||
inputs: | ||
- content: rm -rf ./_tmp | ||
- change-workdir: | ||
title: Switch working dir to test/_tmp dir | ||
run_if: true | ||
run_if: "true" | ||
inputs: | ||
- path: ./_tmp | ||
- is_create_path: true | ||
- script: | ||
inputs: | ||
- content: git clone $SAMPLE_APP_URL . | ||
- [email protected]: | ||
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone: | ||
inputs: | ||
- generate_profiles: 'yes' | ||
- distribution_type: app-store | ||
- path::./: | ||
inputs: | ||
- lane: release | ||
- work_dir: ./ | ||
- verbose_log: "yes" | ||
|
||
# ---------------------------------------------------------------- | ||
# --- Utility workflows | ||
vendor-update: | ||
title: Vendor update | ||
description: | | ||
Used for updating the vendored dependencies | ||
steps: | ||
- repository_url: $SAMPLE_APP_URL | ||
- branch: $BRANCH | ||
- clone_into_dir: "." | ||
- certificate-and-profile-installer: {} | ||
- script: | ||
title: Vendor update | ||
inputs: | ||
- content: |- | ||
#!/bin/bash | ||
set -ex | ||
go mod vendor | ||
#!/usr/bin/env bash | ||
CURRENT_BUILD_NUMBER=${BITRISE_BUILD_NUMBER} | ||
BITRISE_BUILD_NUMBER=$((($(gdate +%Y%m%d%H%M%S)-20000000000000)*10000)) | ||
if [[ -z "${BITRISE_BUILD_NUMBER}" ]]; then | ||
echo "error: failed to calculated build number" | ||
exit 1 | ||
fi | ||
if [[ -n "${CURRENT_BUILD_NUMBER}" ]]; then | ||
BITRISE_BUILD_NUMBER=$((${BITRISE_BUILD_NUMBER}+${CURRENT_BUILD_NUMBER})) | ||
fi | ||
envman add --key BITRISE_BUILD_NUMBER --value "${BITRISE_BUILD_NUMBER}" | ||
- set-xcode-build-number: | ||
title: Set Build Number | ||
run_if: "true" | ||
inputs: | ||
- build_version: $BITRISE_BUILD_NUMBER | ||
- plist_path: $INFO_PLIST_PATH | ||
- build_version_offset: $BITRISE_BUILD_VERSION_OFFSET | ||
|
||
|
||
# ---------------------------------------------------------------- | ||
# --- workflows to Share this step into a Step Library | ||
audit-this-step: | ||
title: Audit the step | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/bitrise-io/go-utils/pathutil" | ||
"github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver/appleauth" | ||
) | ||
|
||
// fastlaneAPIKey is used to serialize App Store Connect API Key into JSON for fastlane | ||
// see: https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file | ||
type fastlaneAPIKey struct { | ||
KeyID string `json:"key_id"` | ||
IssuerID string `json:"issuer_id"` | ||
PrivateKey string `json:"key"` | ||
} | ||
|
||
// FastlaneAuthParams converts Apple credentials to Fastlane env vars and arguments | ||
func FastlaneAuthParams(authConfig appleauth.Credentials) (map[string]string, error) { | ||
envs := make(map[string]string) | ||
if authConfig.AppleID != nil { | ||
// Set as environment variables | ||
if authConfig.AppleID.Username != "" { | ||
envs["FASTLANE_USER"] = authConfig.AppleID.Username | ||
envs["DELIVER_USERNAME"] = authConfig.AppleID.Username | ||
} | ||
if authConfig.AppleID.Password != "" { | ||
envs["FASTLANE_PASSWORD"] = authConfig.AppleID.Password | ||
envs["DELIVER_PASSWORD"] = authConfig.AppleID.Password | ||
} | ||
if authConfig.AppleID.Session != "" { | ||
envs["FASTLANE_SESSION"] = authConfig.AppleID.Session | ||
} | ||
if authConfig.AppleID.AppSpecificPassword != "" { | ||
envs["FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD"] = authConfig.AppleID.AppSpecificPassword | ||
} | ||
} | ||
|
||
if authConfig.APIKey != nil { | ||
fastlaneAPIKeyParams, err := json.Marshal(fastlaneAPIKey{ | ||
IssuerID: authConfig.APIKey.IssuerID, | ||
KeyID: authConfig.APIKey.KeyID, | ||
PrivateKey: authConfig.APIKey.PrivateKey, | ||
}) | ||
if err != nil { | ||
return envs, fmt.Errorf("failed to marshal Fastane API Key configuration: %v", err) | ||
} | ||
|
||
tmpDir, err := pathutil.NormalizedOSTempDirPath("apiKey") | ||
if err != nil { | ||
return envs, err | ||
} | ||
fastlaneAuthFile := filepath.Join(tmpDir, "api_key.json") | ||
if err := ioutil.WriteFile(fastlaneAuthFile, fastlaneAPIKeyParams, os.ModePerm); err != nil { | ||
return envs, err | ||
} | ||
|
||
envs["DELIVER_API_KEY_PATH"] = fastlaneAuthFile | ||
// deliver: "Precheck cannot check In-app purchases with the App Store Connect API Key (yet). Exclude In-app purchases from precheck" | ||
envs["PRECHECK_INCLUDE_IN_APP_PURCHASES"] = "false" | ||
} | ||
|
||
return envs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.