Skip to content

Commit

Permalink
Merge branch 'release/3.1.0-RC1'
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Aug 13, 2020
2 parents 643b72a + 904fce9 commit f47de61
Show file tree
Hide file tree
Showing 73 changed files with 1,595 additions and 1,810 deletions.
210 changes: 78 additions & 132 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,196 +1,142 @@
---
kind: pipeline
name: default

# Disable default clone
clone:
disable: true
type: docker

steps:
# This clone step doesn't use "root" user
- name: clone
image: plugins/git:next

# Restore cache of downloaded dependencies
- name: restore cache
- name: restore-cache
image: drillster/drone-volume-cache
settings:
restore: true
mount:
- .sbt
- .ivy2
- www/node_modules
- ui/node_modules
- ui/bower_components
volumes: [{name: cache, path: /cache}]

# Run project tests
- name: run tests and build stage
- name: run-tests
image: thehiveproject/drone-scala-node
commands:
- . ~/.nvm/nvm.sh
- sbt -Duser.home=$PWD test stage
- sbt -Duser.home=$PWD test:compile test

# Build packages
- name: build packages
- name: build-packages
image: thehiveproject/drone-scala-node
settings:
pgp_key: {from_secret: pgp_key}
commands:
- |
V=$(sbt -no-colors --error "print cortex/version" | tail -1)
if ( echo $V | grep -qi snapshot)
then
exit 1
fi
. ~/.nvm/nvm.sh
[ -n "$PLUGIN_PGP_KEY" ] && gpg --batch --import - <<< $PLUGIN_PGP_KEY
sbt -Duser.home=$PWD docker:stage debian:packageBin rpm:packageBin universal:packageBin
if ( echo $V | grep -qi rc )
then
echo $( echo $V | sed -re 's/([0-9]+.[0-9]+.[0-9]+)-RC([0-9]+)-([0-9]+)/\1-RC\2,\1-RC\2-\3/' ) > .tags
else
echo $( echo $V | sed -re 's/([0-9]+).([0-9]+).([0-9]+)-([0-9]+)/\1,\1.\2,\1.\2.\3,\1.\2.\3-\4,latest/' ) > .tags
fi
echo $V > cortex-version.txt
mv target/rpm/RPMS/noarch/cortex*.rpm target/
mv target/universal/cortex*.zip target/
when:
event: [tag]

# Save external libraries in cache
- name: save cache
- name: save-cache
image: drillster/drone-volume-cache
settings:
rebuild: true
backend: "filesystem"
mount:
- .sbt
- .ivy2
- www/node_modules
- .cache
- ui/node_modules
- ui/bower_components
volumes: [{name: cache, path: /cache}]

# Send packages using scp
- name: send packages
image: appleboy/drone-scp
settings:
host: {from_secret: package_host}
username: {from_secret: package_user}
key: {from_secret: package_key}
target: {from_secret: incoming_path}
source:
- target/cortex*.deb
- target/cortex*.rpm
- target/cortex*.zip
strip_components: 1
when:
event: [tag]

# Publish packages
- name: publish packages
image: thehiveproject/drone-bintray
image: appleboy/drone-ssh
settings:
user: {from_secret: bintray_user}
key: {from_secret: bintray_key}
subject: thehive-project
package: cortex
host: {from_secret: package_host}
user: {from_secret: package_user}
key: {from_secret: package_key}
publish_script: {from_secret: publish_script}
commands:
- |
export PLUGIN_USER
export PLUGIN_KEY
export PLUGIN_SUBJECT
export PLUGIN_PACKAGE
export PLUGIN_VERSION=$(cut -d\" -f2 version.sbt)
echo "Publishing package version $PLUGIN_VERSION"
if echo $PLUGIN_VERSION | grep -qvi -E \
-e '^[0-9]+\.[0-9]+\.[0-9]+$' \
-e '^[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$' \
-e '^[0-9]+\.[0-9]+\.[0-9]+-RC[0-9]+$'; then
echo The version $PLUGIN_VERSION has invalid format
exit 1
fi
CHANNEL=stable
if $(echo $PLUGIN_VERSION | grep -qi rc)
then
CHANNEL=beta
V=$(echo $PLUGIN_VERSION | sed -e 's/-\([rR][cC]\)/-0.1\1/')
DEB_FILE=target/cortex_$${V}_all.deb
RPM_FILE=target/rpm/RPMS/noarch/cortex-$${V}.noarch.rpm
else
DEB_FILE=target/cortex_$${PLUGIN_VERSION}_all.deb
RPM_FILE=target/rpm/RPMS/noarch/cortex-$${PLUGIN_VERSION}.noarch.rpm
fi
ZIP_FILE=target/universal/cortex-$${PLUGIN_VERSION}.zip
upload \
--file $DEB_FILE \
--repo debian-beta \
--extra-param deb_distribution=any \
--extra-param deb_component=main \
--extra-param deb_architecture=all
[ $CHANNEL = stable ] && upload \
--file $DEB_FILE \
--repo debian-stable \
--extra-param deb_distribution=any \
--extra-param deb_component=main \
--extra-param deb_architecture=all
upload \
--file $RPM_FILE \
--repo rpm-beta
[ $CHANNEL = stable ] && upload \
--file $RPM_FILE \
--repo rpm-stable
upload \
--file $ZIP_FILE \
--repo binary
LATEST_VERSION=latest
[ $CHANNEL = beta ] && LATEST_VERSION=latest-beta
removeVersion \
--repo binary \
--version $LATEST_VERSION
upload \
--file $ZIP_FILE \
--repo binary \
--version $LATEST_VERSION \
--dest-file cortex-$${LATEST_VERSION}.zip
- PLUGIN_SCRIPT="bash $PLUGIN_PUBLISH_SCRIPT cortex $(cat cortex-version.txt)" /bin/drone-ssh
when:
event: [tag]

# Publish docker image
# Publish docker image on Docker Hub
- name: docker
image: plugins/docker
settings:
context: target/docker/stage
dockerfile: target/docker/stage/Dockerfile
repo: thehiveproject/cortex
auto_tag: true
username: {from_secret: docker_username}
password: {from_secret: docker_password}
when:
event: [tag]

# Deploy binaries in integration environment
- name: copy binaries in integration environment
image: appleboy/drone-scp
settings:
host: {from_secret: deploy_beta_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
target: ./cortex-builds/${DRONE_BUILD_NUMBER}
source: target/universal/stage
strip_components: 3
when:
branch: [develop]

- name: deploy binaries in integration environment
image: appleboy/drone-ssh
settings:
host: {from_secret: deploy_beta_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
script:
- ./start cortex ${DRONE_BUILD_NUMBER}
when:
branch: [develop]

# Deploy binaries in staging environment
- name: copy binaries in staging environment
image: appleboy/drone-scp
# Publish docker image on Harbor
- name: harbor
image: plugins/docker
settings:
host: {from_secret: deploy_stable_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
target: ./cortex-builds/${DRONE_BUILD_NUMBER}
source: target/universal/stage
strip_components: 3
context: target/docker/stage
dockerfile: target/docker/stage/Dockerfile
registry: {from_secret: harbor_registry}
repo: {from_secret: harbor_repo}
username: {from_secret: harbor_username}
password: {from_secret: harbor_password}
when:
branch: [master]
event: [tag]

- name: deploy binaries in staging environment
image: appleboy/drone-ssh
- name: send message
image: thehiveproject/drone_keybase
settings:
host: {from_secret: deploy_stable_host}
username: {from_secret: deploy_username}
key: {from_secret: deploy_key}
script:
- ./start cortex ${DRONE_BUILD_NUMBER}
username: {from_secret: keybase_username}
paperkey: {from_secret: keybase_paperkey}
channel: {from_secret: keybase_channel}
commands:
- |
keybase oneshot -u "$PLUGIN_USERNAME" --paperkey "$PLUGIN_PAPERKEY"
URL="$DRONE_SYSTEM_PROTO://$DRONE_SYSTEM_HOST/$DRONE_REPO/$DRONE_BUILD_NUMBER"
if [ $DRONE_BUILD_STATUS = "success" ]
then
keybase chat send "$PLUGIN_CHANNEL" ":white_check_mark: $DRONE_REPO: build succeeded $URL"
else
keybase chat send "$PLUGIN_CHANNEL" ":x: $DRONE_REPO: build failed $URL"
fi
when:
branch: [master]
status:
- success
- failure

volumes:
- name: cache
Expand Down
12 changes: 6 additions & 6 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version = "2.0.0-RC7"
version = 2.3.2
project.git = true
align = more # For pretty alignment.
assumeStandardLibraryStripMargin = true
style = defaultWithAlign
maxColumn = 150

align.openParenCallSite = false
align.openParenDefnSite = false
newlines.alwaysBeforeTopLevelStatements = true
newlines.alwaysBeforeTopLevelStatements = false
rewrite.rules = [
# ExpandImportSelectors
RedundantBraces
RedundantParens
SortModifiers
Expand All @@ -20,7 +20,7 @@ includeCurlyBraceInSelectChains = true
includeNoParensInSelectChains = true

rewriteTokens {
"=>" : ""
"<-" : ""
"->": ""
"" : "=>"
"" : "<-"
"→" : "->"
}
Loading

0 comments on commit f47de61

Please sign in to comment.