Skip to content

Instantly share code, notes, and snippets.

@julianfalcionelli
Created January 29, 2018 13:45
Show Gist options
  • Save julianfalcionelli/84c5d4ebd0be5e6001bcb069f555d206 to your computer and use it in GitHub Desktop.
Save julianfalcionelli/84c5d4ebd0be5e6001bcb069f555d206 to your computer and use it in GitHub Desktop.
Circle CI + Slack Config
version: 2
jobs:
check-build:
docker:
# specify the version you desire here
- image: circleci/android:api-27-alpha
working_directory: ~/code
steps:
- checkout
- run: echo "Running..."
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Initial build
command: ./gradlew clean assembleDebug --no-daemon --stacktrace
- store_artifacts:
path: app/build/outputs/apk/
destination: apks/
dev-build:
docker:
# specify the version you desire here
- image: circleci/android:api-27-alpha
working_directory: ~/code
steps:
- checkout
- run: echo "Running..."
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Initial build
command: ./gradlew clean assembleDebug --no-daemon --stacktrace
- store_artifacts:
path: app/build/outputs/apk/
destination: apks/
- run:
name: Upload to Slack
command: |
export GIT_COMMIT_DESC=$(git log --format=oneline -n 1 | sed -E 's/^[^ ]+ (.*)$/\1/g')
curl -F file=@app/build/outputs/apk/debug/app-debug.apk -F channels=$SLACK_CHANNEL -F token=$SLACK_API_TOKEN -F title="${CIRCLE_PROJECT_REPONAME} | branch -> ${CIRCLE_BRANCH} | commit -> ${GIT_COMMIT_DESC}" https://slack.com/api/files.upload
prod-build:
docker:
# specify the version you desire here
- image: circleci/android:api-27-alpha
working_directory: ~/code
steps:
- checkout
- run: echo "Running..."
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Initial build
command: ./gradlew clean assembleRelease --no-daemon --stacktrace
- store_artifacts:
path: app/build/outputs/apk/
destination: apks/
- run:
name: Upload to Slack
command: |
export GIT_COMMIT_DESC=$(git log --format=oneline -n 1 | sed -E 's/^[^ ]+ (.*)$/\1/g')
curl -F file=@app/build/outputs/apk/release/app-release.apk -F channels=$SLACK_CHANNEL -F token=$SLACK_API_TOKEN -F title="${CIRCLE_PROJECT_REPONAME} | branch -> ${CIRCLE_BRANCH} | commit -> ${GIT_COMMIT_DESC}" https://slack.com/api/files.upload
workflows:
version: 2
deploy:
jobs:
- check-build:
filters:
branches:
ignore:
- master
- develop
- dev-build:
filters:
branches:
only: develop
- prod-build:
filters:
branches:
only: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment