forked from redlink-gmbh/smarti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/openjdk:8-jdk-node-browsers | ||
|
||
working_directory: ~/repo | ||
|
||
environment: | ||
# Customize the JVM maximum heap limit | ||
MAVEN_OPTS: -Xmx3200m | ||
|
||
steps: | ||
- checkout | ||
|
||
- setup_remote_docker | ||
|
||
- run: | ||
name: Install dependencies | ||
command: | | ||
sudo apt-get update | ||
sudo apt-get install -y rpm pbzip2 ruby ruby-sass ruby-compass | ||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "pom.xml" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: | ||
name: Build & Test | ||
command: | | ||
mvn -B clean install -Dquick | ||
- run: | ||
name: dist | ||
command: | | ||
mvn -B -f dist/ install -Pdeb,rpm,docker | ||
- run: | ||
name: docker image | ||
command: | | ||
export SMARTI_VERSION="$(mvn -B -q -N exec:exec -Dexec.executable=echo -Dexec.args='${project.version}')" | ||
docker save redlinkgmbh/smarti:${SMARTI_VERSION} | pbzip2 > "dist/target/smarti-${SMARTI_VERSION}.docker.tbz2" | ||
- run: | ||
name: copy artifacts | ||
command: | | ||
export SMARTI_VERSION="$(mvn -B -q -N exec:exec -Dexec.executable=echo -Dexec.args='${project.version}')" | ||
mkdir tmp | ||
mkdir tmp/build/ | ||
cp application/target/*-exec.jar tmp/build/ | ||
cp application/target/*-solrcores.zip tmp/build/ | ||
cp dist/target/*.deb tmp/build/ | ||
cp dist/target/rpm/smarti/RPMS/noarch/*.rpm tmp/build/smarti-${SMARTI_VERSION}.noarch.rpm | ||
cp dist/target/*.docker.tbz2 tmp/build/ | ||
- save_cache: | ||
paths: | ||
- ~/.m2 | ||
- frontend/src/bower_components | ||
- frontend/src/node_modules | ||
- integration/rocket-chat/node_modules | ||
key: v1-dependencies-{{ checksum "pom.xml" }} | ||
|
||
- persist_to_workspace: | ||
root: tmp | ||
paths: | ||
- build | ||
|
||
aws-upload-artifact: | ||
docker: | ||
- image: circleci/openjdk:8-jdk-node-browsers | ||
|
||
steps: | ||
- attach_workspace: | ||
at: /tmp | ||
|
||
- checkout | ||
|
||
- run: | ||
name: Install AWS cli | ||
command: | | ||
sudo apt-get -y -qq update | ||
sudo apt-get -y -qq install python-dev | ||
curl -O https://bootstrap.pypa.io/get-pip.py | ||
python get-pip.py --user | ||
export PATH=~/.local/bin:$PATH | ||
pip install awscli --upgrade --user | ||
- run: | ||
name: Publish assets | ||
command: | | ||
bash .circleci/deploy-assistify-smarti.sh | ||
workflows: | ||
version: 2 | ||
build-and-test: | ||
jobs: | ||
- build: | ||
filters: | ||
branches: | ||
only: | ||
- develop | ||
- master | ||
- aws-upload-artifact: | ||
requires: | ||
- build | ||
filters: | ||
branches: | ||
only: | ||
- develop | ||
- master |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
export BRANCH=${CIRCLE_BRANCH} | ||
export SMARTI_VERSION="$(mvn -B -q -N exec:exec -Dexec.executable=echo -Dexec.args='${project.version}')" | ||
export BUILD_FILE=smarti-${SMARTI_VERSION}.noarch.rpm # replace slashes from the branch name (e. g. "feature/...") | ||
export DEPLOY_PATH=/tmp/build/ | ||
|
||
echo "BRANCH: ${BRANCH}" | ||
echo "SMARTI_VERSION: ${SMARTI_VERSION}" | ||
echo "BUILD_FILE: ${BUILD_FILE}" | ||
echo "DEPLOY_PATH: ${DEPLOY_PATH}" | ||
echo "AWS_REGION: ${AWS_REGION}" | ||
echo "AWS_BUCKET: ${AWS_BUCKET}" | ||
echo "AWS_ACCESS_KEY: ${AWS_ACCESS_KEY}" | ||
|
||
# Install AWS-CLI - if it's there, this will be done quickly | ||
sudo apt-get -y -qq update | ||
sudo apt-get -y -qq install python-dev | ||
curl -O https://bootstrap.pypa.io/get-pip.py | ||
python get-pip.py --user | ||
export PATH=~/.local/bin:$PATH | ||
pip install awscli --upgrade --user | ||
|
||
# in Circle-Ci, the containers already got a aws-config, so if it exsists, assume it's ok | ||
if [ ! -f ~/.aws/credentials ] | ||
then | ||
mkdir -p ~/.aws | ||
echo "Creating AWS credentials from environment variables" | ||
echo "[default] | ||
region=${AWS_REGION} | ||
aws_access_key_id=${AWS_ACCESS_KEY} | ||
aws_secret_access_key=${AWS_SECRET_KEY}" > ~/.aws/config | ||
fi | ||
|
||
cd ${DEPLOY_PATH} | ||
aws s3 cp ${BUILD_FILE} s3://${AWS_BUCKET}/redlink/ --region ${AWS_REGION} --acl bucket-owner-full-control | ||
# For dedicated branches, we tag the artifacts - this should actually be based on git tags | ||
TARGET_ENVIRONMENT=undefined | ||
if [ ${BRANCH} = master ] | ||
then | ||
TARGET_ENVIRONMENT=production | ||
# publish a new "latest"-file in order to make new clients be created with it | ||
aws s3 cp ${BUILD_FILE} s3://${AWS_BUCKET}/redlink/assistify-smarti-latest.rpm --region ${AWS_REGION} --acl bucket-owner-full-control | ||
else | ||
if [[ ${BRANCH} == develop ]] || [[ ${BRANCH} == "release/"* ]] | ||
then | ||
TARGET_ENVIRONMENT=test | ||
fi | ||
fi | ||
aws s3api put-object-tagging --region ${AWS_REGION} --bucket ${AWS_BUCKET} --key redlink/${BUILD_FILE} --tagging "{ \"TagSet\": [ { \"Key\": \"environment\", \"Value\": \"${TARGET_ENVIRONMENT}\" }, { \"Key\": \"nodejs_version\", \"Value\": \"${NODEJS_VERSION}\" }, { \"Key\": \"nodejs_checksum\", \"Value\": \"${NODEJS_CHECKSUM}\" }, { \"Key\": \"assets\", \"Value\": \"${ASSETS_URL}\" } ] }" |