Last active
August 5, 2020 01:38
-
-
Save damiancipolat/9ae1192b72efb98e939a231ed1b4fe13 to your computer and use it in GitHub Desktop.
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
stages: | |
- test | |
- build | |
- deploy | |
- notify | |
run_test: | |
stage: test | |
image: node:10.16.0-alpine | |
script: | |
- npm install | |
- echo "Running unit test..." | |
- npm test | |
build_android: | |
stage: build | |
image: reactnativecommunity/react-native-android | |
only: | |
- develop | |
- staging | |
- master | |
- merge_requests | |
script: | |
- echo "Processing branch $CI_COMMIT_REF_NAME" | |
- echo "Extracting project version..." | |
- export PKG_VERSION=$(node -p "require('./package.json').version") #Extract project version from package.json | |
- echo "Version $PKG_VERSION" | |
- echo $PKG_VERSION >> .version #Save the project version to be used in the next job | |
- echo "Installing npm modules.." | |
- npm install | |
- echo "Buildindg APK..." | |
- cd android && chmod +x gradlew | |
- if [ $CI_COMMIT_REF_NAME == "master" ]; then ./gradlew assembleRelease; else ./gradlew assembleDebug; fi #Build debug or release version | |
artifacts: | |
paths: | |
- .version | |
- android/app/build/outputs/apk/ | |
deploy_android: | |
stage: deploy | |
only: | |
- develop | |
- staging | |
- master | |
- merge_requests | |
image: | |
name: amazon/aws-cli | |
entrypoint: [""] | |
script: | |
- echo "Reading project version..." | |
- export PKG_VERSION=$(cat .version) #Get version from the artifact file. | |
- echo "Uploading to S3..." | |
- aws configure set region us-east-1 #Configure region and upload to s3, depending the branch. | |
- if [ $CI_COMMIT_REF_NAME == "master" ]; then | |
aws s3 cp android/app/build/outputs/apk/release/app-release.apk s3://jupitec-mobile-repository/android/${CI_COMMIT_REF_NAME}/${PKG_VERSION}/app.apk; | |
else | |
aws s3 cp android/app/build/outputs/apk/debug/app-debug.apk s3://jupitec-mobile-repository/android/${CI_COMMIT_REF_NAME}/${PKG_VERSION}/app.apk; | |
fi | |
- echo "Get download signed URL" | |
- export SIGNED_URL=$(aws s3 presign s3://jupitec-mobile-repository/android/${CI_COMMIT_REF_NAME}/${PKG_VERSION}/app.apk --expires-in 300000) | |
- echo $SIGNED_URL | |
- echo $SIGNED_URL > .url #Save the signed url in a file to use in the next job. | |
artifacts: | |
paths: | |
- .url | |
notify_android: | |
stage: notify | |
only: | |
- develop | |
- staging | |
- master | |
- merge_requests | |
image: | |
name: curlimages/curl | |
entrypoint: [""] | |
script: | |
- echo "Reading download url..." | |
- export DOWNLOAD_URL=$(cat .url) #Get download url from file. | |
- export PKG_VERSION=$(cat .version) #Get version url from file. | |
- echo "Sending to slack..." | |
- export MESSAGE="New APK release available :+1:! - ENV $CI_COMMIT_REF_NAME - version $PKG_VERSION - dowload link $DOWNLOAD_URL" | |
- | | |
curl -X POST "https://hooks.slack.com/services/$SLACK_TOKEN" \ | |
--header "Content-Type: application/json" \ | |
--data "{\"text\": \"${MESSAGE}\"}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment