Skip to content

Instantly share code, notes, and snippets.

@moatazeldebsy
Last active February 28, 2023 16:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moatazeldebsy/ca0e8badea10d81a4084ebc786183943 to your computer and use it in GitHub Desktop.
Save moatazeldebsy/ca0e8badea10d81a4084ebc786183943 to your computer and use it in GitHub Desktop.
pipeline {
agent {
// Run on a build agent where we have the Android and iOS are configured
label 'reactNative'
}
environment {
CI = 'true'
}
stages {
stage('Checkout') {
steps {
git 'https://github.com/awesome-reactNative-app'
}
}
stage('Build and Test') {
steps {
sh 'npm install && npm test'
}
}
// Automating the Android build, test and deploy
stage('Configure Google Service Account') {
steps {
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) {
sh 'copy "%GOOGLE_SERVICES_SRC%" "google-services.json"'
}
}
}
stage('Release Android App') {
steps {
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) {
sh 'cd android && ./gradlew assembleRelease && cd ..'
}
}
}
stage('Sign Android App') {
steps{
signAndroidApks (
keyStoreId: "certificate",
keyAlias: "key0",
apksToSign: "android/app/build/outputs/apk/app-release.apk"
)
}
}
stage('Run Androis UI tests with Detox') {
steps {
sh('detox build -c android && detox test -c android')
}
}
stage('Authenticate Google Cloud Project') {
steps {
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) {
sh 'gcloud auth activate-service-account --key-file "%GOOGLE_CLOUD_SERVICE_ACCOUNT_KEY%"'
}
}
}
stage('Config Google CLoud Project') {
steps {
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) {
sh 'gcloud config set project reactnative-demo'
}
}
}
stage('Upload Android Beta App to Firebase App Distribution') {
steps {
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) {
sh 'firebase appdistribution:distribute android/app/build/outputs/apk/app-release.apk --app [FIREBASE_APP_ID] --release-notes "Bug fixes and improvements" --testers "comma seperated email"'
}
}
}
stage('Upload Android App to Goole Play Store') {
androidApkUpload googleCredentialsId: 'Google Play Key', apkFilesPattern: '**/*-release.apk', trackName: 'production'
}
// Automating the iOS build, test and deploy
stage('Install iOS dependencies'){
steps{
sh 'bundle exec pod install'
}
}
stage('Fetch dev Certificates'){
steps{
sh 'bundle exec fastlane fetch_dev_certificates'
}
}
stage('Fetch Distribution Certificates'){
steps{
sh 'bundle exec fastlane fetch_distribution_certificates'
}
}
stage('Run iOS UI tests with Detox') {
steps {
sh('detox build -c ios && detox test -c ios')
}
}
stage('Release build to TestFlight'){
steps{
sh 'bundle exec fastlane release'
}
}
stage('Release the app to App Store'){
steps{
sh 'bundle exec fastlane release_applestore'
}
}
post {
success {
slackSend channel: '#automation', message: 'The $BUILD_NUMBER succeeded and the apps uploaded successfully'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment