Last active
September 4, 2023 21:17
-
-
Save lunks/e90eaf03a0db50463d32b47af4cb1589 to your computer and use it in GitHub Desktop.
React Native with Expo app publishing in Circle CI
This file contains hidden or 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
--- | |
version: 2.1 | |
aliases: | |
- &install_yarn_dependencies | |
run: | |
name: Install yarn dependencies | |
command: yarn install --frozen-lockfile --ignore-engines | |
- &update_yarn | |
run: | |
name: Update yarn | |
command: | | |
sudo rm -rf /usr/local/bin/yarn | |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0 | |
echo 'export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"' >> $BASH_ENV | |
- &install_bundle_dependencies | |
run: | |
name: Install bundle dependencies | |
command: bundle install --jobs=4 --retry=3 --path vendor/bundle | |
- &install_bundle_ios_dependencies | |
run: | |
name: Install bundle dependencies | |
command: cd ios && bundle install --jobs=4 --retry=3 --path vendor/bundle | |
- &install_cocoapods | |
run: | |
name: Install Cocoapods | |
command: | | |
curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf | |
- &install_pod_dependencies | |
run: | |
name: Install pod dependencies | |
command: cd ios && bundle exec pod install | |
- &install_expo_cli | |
run: | |
name: Install Expo CLI | |
command: npm install -g expo-cli | |
- &restore_yarn_cache | |
restore_cache: | |
keys: | |
- v2-dependencies-node_modules-{{ arch }}-{{ checksum "yarn.lock" }} | |
- &restore_gemfile_cache | |
restore_cache: | |
keys: | |
- v2-dependencies-gemfile-{{ arch }}-{{ checksum "Gemfile.lock" }} | |
- &restore_gemfile_ios_cache | |
restore_cache: | |
keys: | |
- v2-dependencies-gemfile-ios-{{ arch }}-{{ checksum "ios/Gemfile.lock" }} | |
- &restore_pods_cache | |
restore_cache: | |
keys: | |
- v2-dependencies-pods-{{ arch }}-{{ checksum "ios/Podfile.lock" }} | |
- &save_node_modules_cache | |
save_cache: | |
paths: | |
- node_modules | |
key: v2-dependencies-node_modules-{{ arch }}-{{ checksum "yarn.lock" }} | |
- &save_bundle_cache | |
save_cache: | |
paths: | |
- vendor/bundle | |
key: v2-dependencies-gemfile-{{ arch }}-{{ checksum "Gemfile.lock" }} | |
- &save_bundle_ios_cache | |
save_cache: | |
paths: | |
- ios/vendor/bundle | |
key: v2-dependencies-gemfile-ios-{{ arch }}-{{ checksum "ios/Gemfile.lock" }} | |
- &save_pods_cache | |
save_cache: | |
paths: | |
- ios/Pods | |
key: v2-dependencies-pods-{{ arch }}-{{ checksum "ios/Podfile.lock" }} | |
- &expo_login | |
run: | |
name: Login into Expo | |
command: yarn expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD | |
- &install_android_sdk | |
run: | |
name: Install Android SDK | |
command: | | |
brew cask install android-sdk | |
yes | sdkmanager --licenses | |
sdkmanager "platform-tools" "platforms;android-28" | |
sdkmanager "build-tools;28.0.3" | |
- &build_and_publish | |
run: | |
name: Build and Publish | |
command: yarn beta | |
experimental: | |
notify: | |
branches: | |
only: | |
- master | |
jobs: | |
lint: | |
docker: | |
- image: circleci/node:10.15.1 | |
working_directory: ~/repo | |
steps: | |
- checkout | |
- *update_yarn | |
- *restore_yarn_cache | |
- *install_yarn_dependencies | |
- *save_node_modules_cache | |
- run: | |
name: Run linters | |
command: yarn lint-ci | |
build_to_testflight: | |
macos: | |
xcode: "10.1.0" | |
working_directory: ~/repo | |
environment: | |
FL_OUTPUT_DIR: output | |
FASTLANE_LANE: test | |
LANG: en_US.UTF-8 | |
LC_ALL: en_US.UTF-8 | |
ANDROID_HOME: /usr/local/share/android-sdk | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
shell: /bin/bash --login -o pipefail | |
steps: | |
- checkout | |
- *update_yarn | |
- *install_cocoapods | |
- *restore_yarn_cache | |
- *restore_gemfile_cache | |
- *restore_gemfile_ios_cache | |
- *restore_pods_cache | |
- *install_yarn_dependencies | |
- *install_bundle_dependencies | |
- *install_bundle_ios_dependencies | |
- *install_pod_dependencies | |
- *save_node_modules_cache | |
- *save_bundle_cache | |
- *save_bundle_ios_cache | |
- *save_pods_cache | |
- *install_expo_cli | |
- *expo_login | |
- *install_android_sdk | |
- *build_and_publish | |
workflows: | |
version: 2 | |
build: | |
jobs: | |
- lint | |
- build_to_testflight: | |
requires: | |
- lint | |
filters: | |
branches: | |
only: | |
- master |
This file contains hidden or 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 the fastlane.tools configuration | |
# You can find the documentation at https://docs.fastlane.tools | |
# | |
# For a list of all available actions, check out | |
# | |
# https://docs.fastlane.tools/actions | |
# | |
# For a list of all available plugins, check out | |
# | |
# https://docs.fastlane.tools/plugins/available-plugins | |
# | |
# Uncomment the line if you want fastlane to automatically update itself | |
# update_fastlane | |
default_platform(:ios) | |
lane :beta do |options| | |
Fastlane::LaneManager.cruise_lane("ios", "beta", options) | |
Fastlane::LaneManager.cruise_lane("android", "beta", options) | |
sh "git push origin master" | |
end | |
private_lane :publish_expo do | |
if ENV["EXPO_BUILT"].nil? | |
sh 'yarn expo publish' | |
ENV["EXPO_BUILT"] = "true" | |
# sh 'git commit -am "Build artifacts for Expo [skip ci]"' | |
else | |
UI.message("Skipping Expo build because it was already ran") | |
end | |
end | |
platform :ios do | |
before_all do | |
setup_circle_ci if is_ci | |
end | |
desc 'Push a new iOS beta build to TestFlight' | |
lane :beta do | |
match(type: 'appstore', readonly: true) | |
xcversion(version: "10.1") | |
bump_version_and_build_numbers | |
build_release_app | |
upload_to_testflight(skip_waiting_for_build_processing: true, apple_id: "YOUR_APP_ID") | |
clean_build_artifacts | |
end | |
private_lane :build_release_app do | |
publish_expo | |
build_app(workspace: './ios/project.xcworkspace', scheme: 'Release', silent: true) | |
end | |
desc 'Bump build version and commit' | |
private_lane :bump_version_and_build_numbers do | |
build_number = increment_build_with_number_of_commits | |
version_number = increment_version_number(xcodeproj: './ios/project.xcodeproj') | |
sh "git commit -am \"Bump iOS version to #{version_number} (#{build_number}) [skip ci]\"" | |
end | |
private_lane :increment_build_with_number_of_commits do | |
number_of_commits = sh 'git rev-list HEAD --count' | |
increment_build_number(build_number: number_of_commits, xcodeproj: './ios/project.xcodeproj') | |
lane_context[SharedValues::BUILD_NUMBER] | |
end | |
end | |
platform :android do | |
desc 'Push a new Android beta build to Play Store' | |
lane :beta do | |
ENV["ANDROID_KEY_ALIAS"] = "release" | |
# path is relative to android/app | |
ENV["ANDROID_KEYSTORE_PATH"] = "../../fastlane/android.jks" | |
unless ENV["ANDROID_KEY_PASSWORD"] && ENV["ANDROID_KEYSTORE_PASSWORD"] | |
UI.user_error!("Android keys as env vars are missing. Exiting") | |
end | |
gradle( | |
task: 'clean', | |
project_dir: './android', | |
) | |
bump_version_and_build_numbers | |
build_release_app | |
upload_to_play_store( | |
package_name: "your.app.bundle.id", | |
track: 'beta', | |
skip_upload_images: true | |
) | |
end | |
desc 'Bump build version and commit' | |
private_lane :bump_version_and_build_numbers do | |
# Always match iOS version | |
ios_version_number = get_version_number(xcodeproj: './ios/project.xcodeproj') | |
android_set_version_name(gradle_file: 'android/app/build.gradle', version_name: ios_version_number) | |
build_number = android_set_version_code(gradle_file: 'android/app/build.gradle') | |
sh "git commit -am \"Bump Android version to #{ios_version_number} (#{build_number}) [skip ci]\"" | |
end | |
private_lane :build_release_app do | |
publish_expo | |
gradle( | |
task: 'assemble', | |
build_type: 'Release', | |
project_dir: './android', | |
flavor: "prodKernel", | |
print_command: false, | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this increment version as a whole number ?