Skip to content

Instantly share code, notes, and snippets.

@jukben
Last active October 28, 2021 10:51
Show Gist options
  • Save jukben/ee49e59a0f33e2eb299b0bf1573f77a1 to your computer and use it in GitHub Desktop.
Save jukben/ee49e59a0f33e2eb299b0bf1573f77a1 to your computer and use it in GitHub Desktop.
Example of Circle CI config for React Native CI (Appcenter, Kotlin, Swift, RN 0.49+, Haul packager, signing via Match, be sure that you have set env MATCH_PASSWORD, FASTLANE_PASSWORD and SLACK_URL)
fastlane_version "2.64.1"
default_platform :android
platform :android do
lane :beta do
gradle(task: "assembleRelease")
appcenter_upload(
api_token: "",
owner_name: "",
group: "",
app_name: "",
apk: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
release_notes: (is_ci ? "This release is **automatic** from *master* branch." : "This release is **manual** from *"+git_branch+"* branch. Probably don't test it.") + "\n\n" + last_git_commit[:message],
)
clean_build_artifacts
end
after_all do |lane|
if is_ci?
id = lane_context[SharedValues::APPCENTER_BUILD_INFORMATION]['id']
slack(
username: "",
icon_url: "",
message: "<https://install.appcenter.ms/users//apps//releases/#{id}/|Android Releases>\n🚀 Release number: #{id}",
)
end
end
error do |lane, exception|
if is_ci?
slack(
username: "",
icon_url: "",
message: exception.message,
success: false
)
end
end
end
version: 2
defaults: &defaults
working_directory: ~/project
docker:
- image: circleci/node:latest
android_defaults: &android_defaults
working_directory: ~/project/android
docker:
- image: farwayer/react-native
environment:
- LANG: "en_US.UTF-8"
- _JAVA_OPTIONS: "-Xms518m -Xmx2048m"
- GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
- BUILD_THREADS: 2
ios_defaults: &ios_defaults
working_directory: ~/project/ios
macos:
xcode: "9.1.0"
environment:
- LANG: "en_US.UTF-8"
- MATCH_KEYCHAIN_NAME: "circle"
- MATCH_KEYCHAIN_PASSWORD: "circle"
jobs:
install-dependencies:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- restore_cache:
keys:
- v1-0-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-0-dependencies-
- run:
name: Install Dependencies
command: yarn
- save_cache:
key: v1-0-dependencies-{{ checksum "package.json" }}
paths:
- node_modules
- yarn.lock
- persist_to_workspace:
root: .
paths: .
flow:
<<: *defaults
steps:
- attach_workspace:
at: ~/project
- run: yarn flow
lint:
<<: *defaults
steps:
- attach_workspace:
at: ~/project
- run: yarn lint
unit-tests:
<<: *defaults
steps:
- attach_workspace:
at: ~/project
- restore_cache:
keys:
- v1-0-jest-cache-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-0-jest-cache-
- run: yarn test:ci
- save_cache:
key: v1-0-jest-cache-{{ checksum "package.json" }}
paths:
- .jestCache
- persist_to_workspace:
root: .
paths: .
danger:
<<: *defaults
steps:
- attach_workspace:
at: ~/project
- run: yarn danger
ios-beta:
<<: *ios_defaults
steps:
- attach_workspace:
at: ~/project
- run:
name: Install CocoaPod Spec
command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
- run:
name: Install Ruby and Fastlane
command: |
brew install ruby
gem install fastlane
- run:
name: Update CocaPods dependencies
command: pod install --verbose
timeout: 1200
- run:
name: Bundle update
command: bundle update
- run:
name: Fastlane
command: bundle exec fastlane beta
android-beta:
<<: *android_defaults
steps:
- attach_workspace:
at: ~/darwin
- run:
name: "Optimize build.gradle for CI"
command: sed -i 's/2g/1g/' app/build.gradle
- run:
name: Install Fastlane
command: |
gem install fastlane -NV
- run:
name: Bundle update
command: bundle update
- run:
name: Fastlane
command: bundle exec fastlane beta
workflows:
version: 2
test:
jobs:
- install-dependencies
- lint:
requires:
- install-dependencies
- flow:
requires:
- install-dependencies
- unit-tests:
requires:
- install-dependencies
- danger:
requires:
- install-dependencies
- ios-beta:
requires:
- install-dependencies
- unit-tests
filters:
branches:
only: master
- android-beta:
requires:
- install-dependencies
- unit-tests
filters:
branches:
only: master
fastlane_version "2.61.0"
default_platform :ios
platform :ios do
lane :beta do
if is_ci?
create_keychain(
name: ENV["MATCH_KEYCHAIN_NAME"],
password: ENV["MATCH_KEYCHAIN_PASSWORD"],
timeout: 1200
)
end
match(type: "adhoc")
gym(
scheme: "darwin",
silent: true,
clean: true,
sdk: "iphoneos11.1",
export_options: { compileBitcode: false },
export_method: "ad-hoc"
)
appcenter_upload(
api_token: "",
owner_name: "",
group: "",
app_name: "",
ipa: lane_context[SharedValues::IPA_OUTPUT_PATH],
dsym: lane_context[SharedValues::DSYM_OUTPUT_PATH],
release_notes: (is_ci ? "This release is **automatic** from *master* branch." : "This release is **manual** from *"+git_branch+"* branch. Probably don't test it.") + "\n\n" + last_git_commit[:message],
)
clean_build_artifacts
if is_ci?
id = lane_context[SharedValues::APPCENTER_BUILD_INFORMATION]['id']
slack(
username: "",
icon_url: "",
message: "<https://install.appcenter.ms/users//apps//releases/#{id}/|iOS Releases>\n🚀 Release number: #{id}",
)
end
end
error do |lane, exception|
if is_ci?
slack(
username: "",
icon_url: "",
message: exception.message,
success: false
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment