Skip to content

Commit

Permalink
🔀 Merge branch 'ladislas/feature/fastlane-release-to-app-store'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Feb 26, 2024
2 parents 224b360 + 5b108c6 commit 5a90cbc
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 20 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ci-fastlane-release_app_store.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Leka - iOS Monorepo
# Copyright APF France handicap
# SPDX-License-Identifier: Apache-2.0

name: Fastlane - Release to App Store

on:
pull_request:
types: [labeled]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
TUIST_TURN_OFF_LINTERS: TRUE
APP_STORE_CONNECT_API_KEY_CONTENT_RELEASE_APP_STORE: ${{ secrets. APP_STORE_CONNECT_API_KEY_CONTENT_RELEASE_APP_STORE }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets. APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_API_KEY_ID_RELEASE_APP_STORE: ${{ secrets. APP_STORE_CONNECT_API_KEY_ID_RELEASE_APP_STORE }}
FASTLANE_KEYCHAIN_PASSWORD: ${{ secrets.FASTLANE_KEYCHAIN_PASSWORD }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}

jobs:
release_app_store:
if: contains(github.event.label.name, 'fastlane:ras')
name: fastlane upload_to_app_store
runs-on: [self-hosted, iOS]

env:
PR_NUMBER: ${{ github.event.pull_request.number }}
FASTLANE_SKIP_UPDATE_CHECK: 1

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1 # shallow clone

- name: Setup mise
run: |
echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH
- name: bundle install
run: |
bundle install
- name: tuist fetch
run: |
tuist fetch
- name: fastlane helloworld
run: |
bundle exec fastlane helloworld
- name: fastlane sync_certificates
run: |
bundle exec fastlane sync_certificates release:true --verbose
- name: fastlane release LekaApp
if: contains(github.event.label.name, 'LekaApp')
run: |
bundle exec fastlane release target:LekaApp --verbose
- name: fastlane release LekaUpdater
if: contains(github.event.label.name, 'LekaUpdater')
run: |
bundle exec fastlane release target:LekaUpdater --verbose
- name: remove label
if: always()
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { LABEL_NAME } = process.env
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: LABEL_NAME
})
env:
LABEL_NAME: ${{ github.event.label.name }}
37 changes: 20 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
CFPropertyList (3.0.7)
base64
nkf
rexml
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
artifactory (3.0.15)
ast (2.4.2)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.880.0)
aws-sdk-core (3.190.2)
aws-partitions (1.894.0)
aws-sdk-core (3.191.3)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.76.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sdk-kms (1.77.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.142.0)
aws-sdk-core (~> 3, >= 3.189.0)
aws-sdk-s3 (1.143.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
claide (1.1.0)
colored (1.2)
colored2 (3.1.2)
Expand Down Expand Up @@ -110,15 +113,14 @@ GEM
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
google-apis-core (0.11.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
Expand Down Expand Up @@ -151,18 +153,20 @@ GEM
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.1)
jwt (2.7.1)
jwt (2.8.0)
base64
language_server-protocol (3.17.0.3)
mini_magick (4.12.0)
mini_mime (1.1.5)
multi_json (1.15.0)
multipart-post (2.3.0)
multipart-post (2.4.0)
nanaimo (0.3.0)
naturally (2.2.1)
nkf (0.2.0)
optparse (0.4.0)
os (1.1.4)
parallel (1.24.0)
parser (3.3.0.3)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
plist (3.7.1)
Expand All @@ -178,11 +182,11 @@ GEM
retriable (3.1.2)
rexml (3.2.6)
rouge (2.0.7)
rubocop (1.59.0)
rubocop (1.60.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
Expand All @@ -195,7 +199,7 @@ GEM
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.18.0)
signet (0.19.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
Expand All @@ -213,9 +217,8 @@ GEM
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcodeproj (1.23.0)
xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand Down
1 change: 1 addition & 0 deletions Tuist/ProjectDescriptionHelpers/InfoPlist+Base.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public extension InfoPlist {
"UIInterfaceOrientationLandscapeLeft",
],
"LSApplicationCategoryType": "public.app-category.utilities",
"LSMinimumSystemVersion": "14.0",
]
}

Expand Down
6 changes: 4 additions & 2 deletions fastlane/Deliverfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@

username('[email protected]') # your Apple ID user

submit_for_review(true)
automatic_release(true)
submit_for_review(false)
automatic_release(false)

languages(%w[en-US fr-FR])
91 changes: 90 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ platform :ios do
build_number = "#{next_build_number}.#{pr_number or '000'}.#{last_commit_sha_hex}"
version_number = get_version_number(xcodeproj: app_xcodeproj.to_s)

UI.important "Version number: #{version_number} / Build number: #{build_number}"
UI.important "App: #{app} / Version number: #{version_number} / Build number: #{build_number}"

increment_build_number(
build_number: build_number,
Expand Down Expand Up @@ -237,4 +237,93 @@ platform :ios do
end
end
end

desc 'Release new app version to App Store Connect'
lane :release do |options|
UI.user_error! 'A target must be specified, for example: LekaApp, LekaUpdater, etc.' if options[:target].nil?
UI.user_error! 'Only one app can be released at a time' if options[:target].split(',').count > 1

app = options[:target].split(',').first

UI.header 'Step: Set target to build'
UI.important "The following targets will be built: #{app}"

build_date = Time.new.strftime('%Y_%m_%d')

UI.header "Step: Generate, build & upload target: #{app}"
Dir.chdir('..') do
ENV['TUIST_TURN_OFF_LINTERS'] = 'TRUE'
system('tuist', 'generate', '-n', app.to_s)
end

app_id = "io.leka.apf.app.#{app}"
app_xcodeproj = "#{ROOT_DIR}/Apps/#{app}/#{app}.xcodeproj"

begin
if ENV['CI']
app_store_connect_api_key(
key_id: ENV.fetch('APP_STORE_CONNECT_API_KEY_ID_RELEASE_APP_STORE', nil),
issuer_id: ENV.fetch('APP_STORE_CONNECT_ISSUER_ID', nil),
key_content: ENV.fetch('APP_STORE_CONNECT_API_KEY_CONTENT_RELEASE_APP_STORE', nil)
)

unlock_keychain(
path: 'io.leka.fastlane.keychain',
password: ENV.fetch('FASTLANE_KEYCHAIN_PASSWORD', nil)
)

UI.header 'Step: keychain security set-key-partition-list'
system('security', 'set-key-partition-list', '-S', 'apple-tool:,apple:', '-s', '-k',
ENV.fetch('FASTLANE_KEYCHAIN_PASSWORD', nil), 'io.leka.fastlane.keychain')
end

latest_build_number = latest_testflight_build_number(app_identifier: app_id.to_s).to_s
next_build_number = latest_build_number.split('.').first.to_i + 1
pr_number = ENV.fetch('PR_NUMBER', `gh pr view --json number -q .number`.strip)
last_commit_sha_hex = last_git_commit[:abbreviated_commit_hash].to_i(16)

build_number = "#{next_build_number}.#{pr_number or '000'}.#{last_commit_sha_hex}"
version_number = get_version_number(xcodeproj: app_xcodeproj.to_s)

UI.important "App: #{app} / Version number: #{version_number} / Build number: #{build_number}"
UI.important "Metadata path: #{ROOT_DIR}/fastlane/release/#{app}/metadata"

# capture_screenshots # ? not working yet

increment_build_number(
build_number: build_number,
xcodeproj: app_xcodeproj.to_s
)

build_app(
workspace: 'ios-monorepo.xcworkspace',
scheme: app,
output_directory: './.build',
output_name: "#{build_date}-#{app}-v#{version_number}-#{build_number}"
)

upload_to_app_store(
force: true,
app_identifier: app_id.to_s,
metadata_path: "#{ROOT_DIR}/fastlane/release/#{app}/metadata",
screenshots_path: "#{ROOT_DIR}/fastlane/release/#{app}/screenshots",
reject_if_possible: true,
app_rating_config_path: "#{ROOT_DIR}/fastlane/release/#{app}/metadata/app_rating_config.json",
submission_information: {
export_compliance_uses_encryption: false,
add_id_info_uses_idfa: false,
content_rights_contains_third_party_content: true,
content_rights_has_rights: true
},
run_precheck_before_submit: true,
precheck_include_in_app_purchases: false
)
ensure
next unless ENV['CI']

delete_keychain(
name: 'io.leka.fastlane.keychain'
)
end
end
end
8 changes: 8 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ Create certificates

Submit new internal beta app

### ios release

```sh
[bundle exec] fastlane ios release
```

Release new app version to App Store Connect

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
Expand Down

0 comments on commit 5a90cbc

Please sign in to comment.