Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lane to fetch/update dev certificates #16

Merged
merged 9 commits into from
Jul 5, 2024
25 changes: 19 additions & 6 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ USER_ENV_FILE_PATH = File.join(Dir.home, '.a8c-apps', ENV_FILE_NAME)
import 'lib/helpers.rb'

before_all do
setup_ci if runner.current_platform == :ios
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, we are only using iOS at the moment.

But given the app is built with React Native, this will save us a warning/error if we'll ever run with platform :android


Dotenv.load(USER_ENV_FILE_PATH)
end

Expand Down Expand Up @@ -98,20 +100,31 @@ platform :ios do
end

desc 'Sets up code signing'
lane :set_up_code_signing do |options|
require_env_vars!(*ASC_API_KEY_ENV_VARS, *MATCH_ENV_VARS)
lane :set_up_code_signing_app_store do |readonly: true|
_set_up_code_signing(type: 'appstore', readonly: readonly)
end

lane :set_up_code_signing_deveploment do |readonly: true|
_set_up_code_signing(type: 'development', readonly: readonly)
end

def _set_up_code_signing(type:, readonly: true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the underscore meant to signify that this method shouldn't be called directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... 🤔 My original intention was do distinguish the name of the method from the name of the lane, but there is no set_up_code_signing lane so this approach is redundant.

Prefixing names with underscore is a convention in some environments to mark the prefixed thing as private, e.g. https://stackoverflow.com/a/15072306/809944

But your question made me wonder whether my assumption that a lane and a method with the same name cannot coexist is correct. Turns out it isn't. I created a set_up_code_signing lane to verify it, see 2bfad90, which is also handy to regenerate all certs and profiles if need be.

Clearly the Fastlane DSL parser can distinguish between lanes and methods 😅

Furthermore, I added this to Fastfile

+
+lane :test_lane do
+  puts 'hi'
+  test_lane
+end
+
+def test_lane
+  puts 'hello'
+end

And I got this output

[20:49:06]: ------------------------------
[20:49:06]: --- Step: default_platform ---
[20:49:06]: ------------------------------
[20:49:06]: Driving the lane 'test_lane' 🚀
[20:49:06]: hi
[20:49:06]: hello
[20:49:06]: fastlane.tools finished successfully 🎉

Finally, it looks like Fastlane will give precedence to methods when running into a name clash

lane :other do
  test_lane # which will it call? the method or the lane?
end
[20:52:18]: ------------------------------
[20:52:18]: --- Step: default_platform ---
[20:52:18]: ------------------------------
[20:52:18]: Driving the lane 'other' 🚀
[20:52:18]: hello
[20:52:18]: fastlane.tools finished successfully 🎉

require_env_vars!(*MATCH_ENV_VARS)

setup_ci
unless readonly
require_env_vars!(*ASC_API_KEY_ENV_VARS)
api_key = app_store_connect_api_key
end

shared_options = {
type: 'appstore',
type: type,
app_identifier: BUNDLE_IDENTIFIER,
team_id: 'PZYM8XX95Q',
storage_mode: 's3',
s3_region: 'us-east-2',
s3_bucket: 'a8c-fastlane-match',
readonly: options.fetch(:readonly, true),
api_key: app_store_connect_api_key
readonly: readonly,
api_key: api_key
}

sync_code_signing(
Expand Down
Loading