105 lines
2.6 KiB
YAML
105 lines
2.6 KiB
YAML
variables:
|
|
BINARY_NAME: control_server
|
|
DOCKER_HOST: tcp://docker:2375/
|
|
DOCKER_DRIVER: overlay2
|
|
DOCKER_TLS_CERTDIR: ""
|
|
CARGO_HOME: $CI_PROJECT_DIR/.cargo
|
|
|
|
cache:
|
|
key: $CI_JOB_NAME
|
|
paths:
|
|
- target
|
|
- .cargo
|
|
|
|
stages:
|
|
- build
|
|
- collect
|
|
- release
|
|
|
|
before_script:
|
|
# - mkdir -p .cargo
|
|
- apt-get update -qqy
|
|
- apt-get install -y git ssh rsync dos2unix protobuf-compiler python3-pip python3
|
|
- python3 -m pip install --user pipenv
|
|
- git clone https://github.com/pyenv/pyenv.git ~/.pyenv
|
|
- export PYENV_ROOT="$HOME/.pyenv"
|
|
- export PATH=$PATH:~/.local/bin
|
|
- export PATH="$PYENV_ROOT/bin:$PATH"
|
|
- pyenv install 3.10.4
|
|
- pyenv global 3.10.4
|
|
- eval $(ssh-agent -s)
|
|
- mkdir -p output
|
|
- mkdir -p ~/.ssh
|
|
- touch ~/.ssh/config
|
|
- echo "$SSH_STATUSD_DEPLOY_KEY" | tr -d '\r' | ssh-add -
|
|
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
|
|
|
|
build_scripts:
|
|
stage: build
|
|
script:
|
|
- cp -avr install output
|
|
- cp -avr scripts output
|
|
artifacts:
|
|
name: $CI_PROJECT_NAME-$CI_COMMIT_TAG-$CI_JOB_NAME
|
|
paths:
|
|
- output
|
|
expire_in: 1 hour
|
|
|
|
build_statusd_server:
|
|
stage: build
|
|
script:
|
|
- mkdir -p statusd_server/proto
|
|
- python --version
|
|
- cd statusd_server
|
|
- cat Pipfile
|
|
- pipenv install
|
|
- pipenv run protoc --python_betterproto_out=proto -I ../ messages.proto
|
|
- cd ..
|
|
- cp -avr statusd_server output
|
|
only:
|
|
changes:
|
|
- statusd_server/**/*
|
|
artifacts:
|
|
name: $CI_PROJECT_NAME-$CI_COMMIT_TAG-$CI_JOB_NAME
|
|
paths:
|
|
- output
|
|
expire_in: 1 hour
|
|
|
|
.build_template: &build
|
|
image: registry.gitlab.com/silver_rust/gitlab-cross
|
|
services:
|
|
- docker:19.03.12-dind
|
|
script:
|
|
- rustup target add $CI_JOB_NAME
|
|
- rustc --version
|
|
- cargo version
|
|
- cross build --release --bin $BINARY_NAME --target=$CI_JOB_NAME
|
|
- cp target/$CI_JOB_NAME/release/$BINARY_NAME$BINARY_SUFFIX output
|
|
only:
|
|
changes:
|
|
- statusd_server/**/*
|
|
artifacts:
|
|
name: $CI_PROJECT_NAME-$CI_COMMIT_TAG-$CI_JOB_NAME
|
|
paths:
|
|
- output
|
|
expire_in: 1 hour
|
|
|
|
## cross compiling
|
|
## job name = target name
|
|
|
|
## arm-unknown-linux-musleabi:
|
|
## stage: build
|
|
## <<: *build
|
|
|
|
release:
|
|
stage: release
|
|
script:
|
|
- dos2unix output/scripts/pi_post_deploy.sh
|
|
- rsync -r --exclude 'output/scripts/local' --exclude 'output/install' output/* $STATUSD_SERVER_CONNECTION:/app
|
|
- ssh $STATUSD_SERVER_CONNECTION 'chmod +x /app/scripts/pi_post_deploy.sh && /app/scripts/pi_post_deploy.sh'
|
|
only:
|
|
changes:
|
|
- statusd_server/**/*
|
|
- install/**/*
|
|
- scripts/**/*
|