diff --git a/Gemfile b/Gemfile index 84ac61aa..30e324a6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' gem 'slather' -gem 'nokogiri', '1.11.4' +gem 'nokogiri', '1.12.5' diff --git a/Gemfile.lock b/Gemfile.lock index c9b813c8..f99963dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,11 +15,11 @@ GEM concurrent-ruby (1.1.7) i18n (1.8.5) concurrent-ruby (~> 1.0) - mini_portile2 (2.5.1) + mini_portile2 (2.6.1) minitest (5.14.2) nanaimo (0.3.0) - nokogiri (1.11.4) - mini_portile2 (~> 2.5.0) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) racc (~> 1.4) racc (1.5.2) slather (2.5.0) @@ -43,7 +43,7 @@ PLATFORMS ruby DEPENDENCIES - nokogiri (= 1.11.4) + nokogiri (= 1.12.5) slather BUNDLED WITH diff --git a/Sources/Variants/main.swift b/Sources/Variants/main.swift index c5f59e24..811db93d 100644 --- a/Sources/Variants/main.swift +++ b/Sources/Variants/main.swift @@ -12,7 +12,7 @@ struct Variants: ParsableCommand { static var configuration = CommandConfiguration( commandName: "variants", abstract: "A command-line tool to setup deployment variants and working CI/CD setup", - version: "0.9.4", + version: "1.0.0", subcommands: [ Initializer.self, Setup.self, diff --git a/Templates/ios/_fastlane/fastlane/Appstore b/Templates/ios/_fastlane/fastlane/Appstore new file mode 100644 index 00000000..7f60aa97 --- /dev/null +++ b/Templates/ios/_fastlane/fastlane/Appstore @@ -0,0 +1,40 @@ +require File.expand_path('parameters/appstore_params.rb', __dir__) +require File.expand_path('parameters/project_params.rb', __dir__) + +USERNAME = APPSTORE_PARAMS[:APPSTORE_USERNAME] +APPLE_ID = APPSTORE_PARAMS[:APPSTORE_APPLE_ID] +XCCONFIG_PATH = PROJECT_PARAMS[:XCCONFIG_PATH] + +# --- Appstore + +# +# ATTENTION: +# +# Deploying directly to AppStore +# using `pilot`, `deliver` or their aliases require +# authentication to AppStoreConnect. +# +# In order to have this handled automatically in +# your CI machine, you'll need an Application Specific Password +# +# Find more about it and how to generate yours in: +# https://docs.fastlane.tools/best-practices/continuous-integration/#application-specific-passwords +# + +desc 'deploy app to AppStore' +private_lane :appstore_deploy do |options| + # Retrieve app identifier from config + app_identifier = get_xcconfig_value( + path: XCCONFIG_PATH, + name: 'V_BUNDLE_ID' + ) + + deliver( + submit_for_review: false, + automatic_release: false, + force: true, # Skip HTMl report verification + skip_metadata: true, + skip_screenshots: true, + skip_binary_upload: false + ) +end diff --git a/Templates/ios/_fastlane/fastlane/Deliverfile b/Templates/ios/_fastlane/fastlane/Deliverfile new file mode 100644 index 00000000..8812017c --- /dev/null +++ b/Templates/ios/_fastlane/fastlane/Deliverfile @@ -0,0 +1,54 @@ +require File.expand_path('parameters/match_params.rb', __dir__) + +CODE_SIGNING_IDENTITY = MATCH_PARAMS[:TEAMNAME] +TEAM_ID = MATCH_PARAMS[:TEAMID] +EXPORT_METHOD = MATCH_PARAMS[:EXPORTMETHOD] + +# This is the example Deliverfile +# +# You can remove those parts you don't need +# +# Everything next to a # is a comment and will be ignored + +######################################## +# App Metadata +######################################## + +apple_id '' + +# This folder has to include one folder for each language +# More information about automatic screenshot upload: +# https://github.com/KrauseFx/deliver#upload-screenshots-to-itunes-connect +screenshots_path "" + +app_icon "" + +title({ + "en-US" => "" +}) + +# This log has to include the changes made for the release. It has been commented out for the purpose of developer interest to choose either from repository or from fastlane. +# changelog({ +# "en-US" => "iPhone 6 (Plus) Support" +# }) + +description({ + 'en-US' => "" +}) + +copyright "" + +app_review_information({ + first_name: "", + last_name: "", + phone_number: "", + email_address: "", + demo_user: "", + demo_password: "", + notes: "" +}) + +primary_category "" +secondary_category "" + +ratings_config_path "" diff --git a/Templates/ios/_fastlane/fastlane/Deploy b/Templates/ios/_fastlane/fastlane/Deploy index a2f5ec7a..2b3f73b5 100644 --- a/Templates/ios/_fastlane/fastlane/Deploy +++ b/Templates/ios/_fastlane/fastlane/Deploy @@ -49,6 +49,8 @@ lane :deploy do |options| appcenter_deploy elsif destination == 'testflight' testflight_deploy + elsif destination == 'appstore' + appstore_deploy end diff --git a/Templates/ios/_fastlane/fastlane/Fastfile b/Templates/ios/_fastlane/fastlane/Fastfile index 83a5ce42..3e65f61b 100644 --- a/Templates/ios/_fastlane/fastlane/Fastfile +++ b/Templates/ios/_fastlane/fastlane/Fastfile @@ -20,6 +20,8 @@ import('Sonar') import('SwiftLint') import('Tests') import('TestFlight') +import('Appstore') +import('Deliverfile') # --- Before all, prepare diff --git a/action.yml b/action.yml index 997a38a2..a4f80e53 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,7 @@ inputs: platform: description: '"ios" or "android".' required: false + default: 'default' variant: description: 'Variant you would like to switch to.' required: true @@ -38,29 +39,31 @@ runs: make ci cd ${{ env.project_path }} - if [[ ${{ inputs.platform }} != '' ]]; then - if [[ ${{ inputs.verbose }} == true ]]; then + if [[ ${{ inputs.platform }} == default ]]; + then + if ${{ inputs.verbose }} + then variants switch \ --spec ${{ inputs.spec }} \ --variant ${{ inputs.variant }} \ - --platform ${{ inputs.platform }} \ --verbose else variants switch \ --spec ${{ inputs.spec }} \ - --variant ${{ inputs.variant }} \ - --platform ${{ inputs.platform }} + --variant ${{ inputs.variant }} fi - else - if [[ ${{ inputs.verbose }} == true ]]; then + if ${{ inputs.verbose }} + then variants switch \ --spec ${{ inputs.spec }} \ --variant ${{ inputs.variant }} \ + --platform ${{ inputs.platform }} \ --verbose else variants switch \ --spec ${{ inputs.spec }} \ - --variant ${{ inputs.variant }} + --variant ${{ inputs.variant }} \ + --platform ${{ inputs.platform }} fi fi diff --git a/docs/STORE_DESTINATION.md b/docs/STORE_DESTINATION.md index c9ca0720..e4426ced 100644 --- a/docs/STORE_DESTINATION.md +++ b/docs/STORE_DESTINATION.md @@ -47,9 +47,7 @@ Note that by not specifying or specifying an unsupported store will fallback to > > -AppStore is dependent on [Issue #81](https://github.com/Backbase/variants/issues/81) - -#### Example +#### Example for iOS Assume we have an iOS project, which production variant (default) should deploy to *Apple's AppStore*. A beta variant should be deployed to *Apple's TestFlight*. And an internal enterprise variant of this application (using an enterprise developer account) should be deployed to *AppCenter*. This could be achieved with the following: @@ -76,10 +74,32 @@ ios: ... ``` +#### Example for Android + +Assume we have an Android project, which production variant (default) should deploy to *Google's Playstore*. And an internal enterprise variant of this application (using an enterprise developer account) should be deployed to *AppCenter*. This could be achieved with the following: + +```yaml +android: + path: ... + app_name: + ... + variants: + default: + version_name: 0.0.1 + version_code: 1 + store_destination: PlayStore + ... + enterprise_release: + version_name: 0.0.1 + version_code: 1 + store_destination: AppCenter + ... +``` + Now, all we have to do is to switch to the correct variant and instruct *fastlane* to deploy as usual: ```sh -variants switch --platform ios --variant +variants switch --platform --variant fastlane deploy ``` diff --git a/docs/USAGE.md b/docs/USAGE.md index c7a991be..60be14e2 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -101,7 +101,75 @@ ios: value: $(inherited) -DBETA destination: project ``` - +```yaml +android: + path: {{ PROJECT_PATH }} + app_name: {{ APP_NAME }} + app_identifier: {{ APP_IDENTIFIER }} + variants: + # Default variant is mandatory, do not remove + # Usually regarded as `production` variant. + default: + version_name: 0.0.1 + version_code: 1 + task_build: bundleProdRelease + task_unittest: testProdReleaseUnitTest + task_uitest: connectedProdReleaseAndroidTest + # 'store_destination' can be: AppCenter or PlayStore + store_destination: PlayStore + # + # custom: - Not required. + # You can have as many custom fields as possible. + # Only strings allowed. + # + # The value of will be written to 1 of 2 possible destinations: + # - project => variants.gradle + # - fastlane => fastlane/parameters/variants_params.rb + # + custom: + - name: SAMPLE_PROPERTY + value: SAMPLE_VALUE + destination: fastlane + + - name: SAMPLE_PROPERTY_FROM_ENVIRONMENT + value: SAMPLE_ENVIRONMENT_VARIABLE + env: true + destination: fastlane + + # Sample variant "BETA" + BETA: + id_suffix: beta + version_name: 0.0.1 + version_code: 1 + task_build: assembleDevDebug + task_unittest: testDevDebugUnitTest + task_uitest: connectedDevDebugAndroidTest + # 'store_destination' can be: AppCenter or PlayStore + store_destination: AppCenter + custom: + - name: SAMPLE_PROPERTY + value: SAMPLE_ENVIRONMENT_VARIABLE + env: true + destination: fastlane + # ---------------------------------------------------------------------- + # custom: - Not required. + # + # Same as variant's `custom`, but this will be processed regardless of + # the chosen variant. + # + # Uncomment section below if necessary. + # ---------------------------------------------------------------------- + + #custom: + # - name: mvnUser + # value: MAVEN_USERNAME + # env: true + # destination: project + # - name: mvnPass + # value: MAVEN_PASSWORD + # env: true + # destination: project +``` #### Custom configuration Configuration through custom properties can bring a lot of value to your variants, such as defining different API base URLs, or credentials using environment variables. This allows us to also define its destination. Certain properties should not be available to the project but to fastlane and vice-versa.