https://github.com/ICIJ/datashare
Tip revision: d8b9956adc8e4c36eab48557a55075fe6ecf9113 authored by Anne L'Hôte on 08 March 2021, 14:39:27 UTC
[release] 9.4.4
[release] 9.4.4
Tip revision: d8b9956
config.yml
version: 2.1
parameters:
publish_backend_api:
type: boolean
default: false
jobs:
build_back:
docker:
- image: circleci/openjdk:8-stretch
- image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
environment:
- "discovery.type=single-node"
- "cluster.name=datashare"
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
name: elasticsearch
- image: redis:4.0.1-alpine
name: redis
- image: postgres:11.2
name: postgres
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
working_directory: /tmp/datashare
environment:
MAVEN_OPTS: "-Xms512m -Xmx512m -Xss10M"
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
- run:
name: create a bootstrap datashare DB for jooq code generation
command: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-client
echo "postgres:5432:test:test:test" > ~/.pgpass && chmod 600 ~/.pgpass
psql -h postgres -U test test -c "CREATE DATABASE datashare;"
- run: mvn validate
- run: mvn -pl commons-test -am install
- run: mvn -pl datashare-db liquibase:update
- run: mvn test
- run: mvn -pl datashare-app -pl datashare-nlp-corenlp -am install -Dmaven.test.skip=true
- run: .circleci/publish_doc_if_web_changed.sh
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
publish_doc:
docker:
- image: circleci/openjdk:8-stretch
- image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
environment:
- "discovery.type=single-node"
- "cluster.name=datashare"
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
name: elasticsearch
working_directory: ~/datashare
environment:
MAVEN_OPTS: "-Xms512m -Xmx512m -Xss10M"
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
- run:
name: Prepare SSH directory
command: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
- add_ssh_keys:
fingerprints:
- "b3:e6:7c:f3:86:9e:e9:88:d1:cf:22:8c:97:3e:93:54"
- run:
name: Configure Git identity
command: |
git config --global user.name $CIRCLE_USERNAME
git config --global user.email "engineering@icij.org"
- run:
name: Checkout Datashare Wiki repository
command: |
ssh-keyscan github.com >> ~/.ssh/known_hosts
git clone git@github.com:ICIJ/datashare.wiki.git ~/datashare-wiki
- run:
name: make dist without frontend
command: mvn -pl datashare-dist package > mvn.out
- run:
name: populate apigen index
command: ./doc/apigen/populate_apigen.sh
- run:
name: launch datashare apigen
command: ./doc/apigen/datashare_for_apigen.sh
background: true
- run:
name: install apigen
command: |
sudo apt-get update
sudo apt-get install -y python3-pip
sudo pip3 install fluent-http-apigen
- run:
name: run apigen
command: apigen datashare-app/src/main/java/org/icij/datashare/web/*Resource.java > ~/datashare-wiki/Backend-›-API.md
- run:
name: Add/Commit changes to the Wiki
command: |
git -C ~/datashare-wiki commit -am "Publish backend documentation [${CIRCLE_SHA1}]" || true
- run:
name: Push changes to the Wiki
command: git -C ~/datashare-wiki push origin master
package_back:
docker:
- image: circleci/openjdk:8-stretch
working_directory: /tmp/datashare
environment:
MAVEN_OPTS: "-Xms512m -Xmx512m -Xss10M"
steps:
- attach_workspace:
at: /tmp/datashare-client
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
- run:
name: make app link to front
command: ln -s /tmp/datashare-client/dist /tmp/datashare/app
- run:
name: make dist including frontend
command: mvn -pl datashare-dist package > mvn.out
- persist_to_workspace:
root: /tmp/datashare
paths:
- datashare-dist
deploy_back:
docker:
- image: circleci/openjdk:8-stretch
working_directory: /tmp
steps:
- attach_workspace:
at: /tmp/datashare
- run:
name: deploy datashare dist jar to github release
command: |
upload_url=$(curl -X POST -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -d "{\"tag_name\":\"${CIRCLE_TAG}\", \"name\":\"${CIRCLE_TAG}\",\"body\":\"release ${CIRCLE_TAG}\"}" "https://api.github.com/repos/ICIJ/datashare/releases" | jq -r '.upload_url')
upload_url="${upload_url%\{*}"
echo "uploading asset to release url: $upload_url"
curl -X POST -s -m 120 -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/java-archive" --data-binary "@/tmp/datashare/datashare-dist/target/datashare-dist-${CIRCLE_TAG}-all.jar" "$upload_url?name=datashare-dist-${CIRCLE_TAG}-all.jar&label=datashare-dist-${CIRCLE_TAG}-all.jar"
curl -X POST -s -m 120 -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/java-archive" --data-binary "@/tmp/datashare/datashare-dist/target/datashare-dist-${CIRCLE_TAG}-back.jar" "$upload_url?name=datashare-dist-${CIRCLE_TAG}.jar&label=datashare-dist-${CIRCLE_TAG}.jar"
build_front:
docker:
- image: circleci/node:14.15.5
- image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
environment:
- "discovery.type=single-node"
- "cluster.name=datashare"
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
- "http.cors.enabled=true"
- "http.cors.allow-origin=*"
- "http.cors.allow-methods=OPTIONS, HEAD, GET, POST, PUT, DELETE"
name: elasticsearch
working_directory: /tmp
steps:
- attach_workspace:
at: /tmp/datashare
- run:
name: adds_ssh_dir
command: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
- add_ssh_keys:
fingerprints:
- "b3:e6:7c:f3:86:9e:e9:88:d1:cf:22:8c:97:3e:93:54"
- run:
name: clone
command: |
ssh-keyscan github.com >> ~/.ssh/known_hosts
git clone git@github.com:ICIJ/datashare-client.git
- run:
name: release client on GitHub
command: |
upload_url=$(curl -X POST -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -d "{ \"tag_name\": \"${CIRCLE_TAG}\", \"target_commitish\": \"master\", \"name\": \"${CIRCLE_TAG}\", \"body\": \"Released by Circle CI\", \"draft\": false, \"prerelease\": false }" "https://api.github.com/repos/ICIJ/datashare-client/releases")
echo $upload_url > /tmp/datashare-client/datashare-client.url
- run:
name: checkout tag
command: |
cd datashare-client
git pull origin master --tags
git checkout ${CIRCLE_TAG}
- run:
name: make install
command: |
cd /tmp/datashare-client
make install
- save_cache:
key: dependency-cache-{{ checksum "/tmp/datashare-client/package.json" }}
paths:
- /tmp/datashare-client/node_modules
- run:
name: run tests and build dist
command: |
cd /tmp/datashare-client
make unit dist
- persist_to_workspace:
root: /tmp/datashare-client
paths:
- dist
- datashare-client.url
deploy_front:
docker:
- image: circleci/node:14.15.5
working_directory: /tmp
steps:
- attach_workspace:
at: /tmp/datashare
- run:
name: deploy datashare-client dist to github release
command: |
cd /tmp/datashare/dist
tar czf ../datashare-client-${CIRCLE_TAG}.tgz .
zip -r ../datashare-client-${CIRCLE_TAG}.zip .
upload_url=$(cat /tmp/datashare/datashare-client.url | jq -r '.upload_url')
if [ "$upload_url" = "null" ]; then
upload_url=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/ICIJ/datashare-client/releases/tags/${CIRCLE_TAG}" | jq -r '.upload_url')
fi
upload_url="${upload_url%\{*}"
echo "uploading asset to release url: $upload_url"
curl -X POST -s -m 120 -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/zip" --data-binary "@/tmp/datashare/datashare-client-${CIRCLE_TAG}.zip" "$upload_url?name=datashare-client-${CIRCLE_TAG}.zip&label=datashare-client-${CIRCLE_TAG}.zip"
curl -X POST -s -m 120 -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/gzip" --data-binary "@/tmp/datashare/datashare-client-${CIRCLE_TAG}.tgz" "$upload_url?name=datashare-client-${CIRCLE_TAG}.tgz&label=datashare-client-${CIRCLE_TAG}.tgz"
build_docker:
docker:
- image: docker:17.05.0-ce-git
working_directory: /tmp
steps:
- attach_workspace:
at: /tmp/datashare
- setup_remote_docker
- run:
name: Install dependencies
command: |
apk add --no-cache py-pip=9.0.0-r1
pip install docker-compose==1.12.0
- run:
name: build and push docker image
command: |
docker build -t icij/datashare:${CIRCLE_TAG} /tmp/datashare/datashare-dist/target/datashare-dist-$CIRCLE_TAG-docker/
docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
docker push icij/datashare:${CIRCLE_TAG}
build_installers:
docker:
- image: circleci/build-image
working_directory: /tmp
steps:
- attach_workspace:
at: /tmp/datashare
- run:
name: install dependencies
command: |
apt-get install -y nsis cpio jq imagemagick icnsutils
wget https://nsis.sourceforge.io/mediawiki/images/c/c9/Inetc.zip && unzip Inetc.zip && cp Plugins/x86-ansi/INetC.dll /usr/share/nsis/Plugins/
wget https://github.com/hogliux/bomutils/archive/0.2.tar.gz && tar -zxf 0.2.tar.gz && cd bomutils-0.2 && make && make install
wget https://github.com/downloads/mackyle/xar/xar-1.6.1.tar.gz && tar -zxf xar-1.6.1.tar.gz && cd xar-1.6.1 && ./configure && make && make install
wget https://nsis.sourceforge.io/mediawiki/images/9/9d/Untgz.zip && unzip Untgz.zip && cp untgz/untgz.dll /usr/share/nsis/Plugins/
- run:
name: adds_ssh_dir
command: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
- add_ssh_keys:
fingerprints:
- "b3:e6:7c:f3:86:9e:e9:88:d1:cf:22:8c:97:3e:93:54"
- run:
name: checkout
command: |
ssh-keyscan github.com >> ~/.ssh/known_hosts
git clone git@github.com:ICIJ/datashare-installer.git
- run:
name: build mac installer
command: |
cd /tmp/datashare-installer/mac
make VERSION=${CIRCLE_TAG} all
- run:
name: build windows installer
command: |
cd /tmp/datashare-installer/windows
make VERSION=${CIRCLE_TAG} dist/installDatashare.exe
make VERSION=${CIRCLE_TAG} dist/installDatashareStandalone.exe
- run:
name: build linux installer
command: |
cd /tmp/datashare-installer/linux
make VERSION=${CIRCLE_TAG} dist/datashare.sh
- run:
name: deploy installers on github
command: |
cd /tmp/datashare-installer
./deploy.sh ${CIRCLE_TAG}
upload_url=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/ICIJ/datashare-installer/releases/tags/${CIRCLE_TAG}" | jq -r '.upload_url')
upload_url="${upload_url%\{*}"
curl -X POST -s -m 120 -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/vnd.debian.binary-package" --data-binary "@/tmp/datashare/datashare-dist/target/datashare-dist_${CIRCLE_TAG}_all.deb" "$upload_url?name=datashare-dist_${CIRCLE_TAG}_all.deb&label=datashare-dist_${CIRCLE_TAG}_all.deb"
workflows:
version: 2
build_workflow:
when:
not: << pipeline.parameters.publish_backend_api >>
jobs:
- build_back:
filters:
tags:
only: /.*/
- package_back:
requires:
- build_back
- build_front
filters:
tags:
only: /^[0-9.]*/
branches:
ignore: /.*/
- deploy_back:
requires:
- package_back
filters:
tags:
only: /^[0-9.]*/
branches:
ignore: /.*/
- build_front:
requires:
- build_back
filters:
tags:
only: /^[0-9.]*/
branches:
ignore: /.*/
- deploy_front:
requires:
- build_front
filters:
tags:
only: /^[0-9.]*/
branches:
ignore: /.*/
- build_docker:
requires:
- package_back
filters:
tags:
only: /^[0-9.]*/
branches:
ignore: /.*/
- build_installers:
requires:
- build_docker
filters:
tags:
only: /^[0-9.]*/
branches:
ignore: /.*/
publish_doc_workflow:
when: << pipeline.parameters.publish_backend_api >>
jobs:
- publish_doc