2017-12-13 12:11:00 -07:00
|
|
|
version: 2.0
|
|
|
|
defaults: &defaults
|
|
|
|
docker:
|
|
|
|
- image: nervesproject/nerves:0.13.5
|
2017-12-11 20:28:35 -07:00
|
|
|
|
2017-12-13 12:11:00 -07:00
|
|
|
install_elixir: &install_elixir
|
|
|
|
run:
|
|
|
|
name: Install Elixir
|
|
|
|
command: |
|
2018-01-03 17:09:13 -07:00
|
|
|
wget https://github.com/elixir-lang/elixir/releases/download/v1.5.2/Precompiled.zip
|
2017-12-13 12:11:00 -07:00
|
|
|
unzip -d /usr/local/elixir Precompiled.zip
|
|
|
|
echo 'export PATH=/usr/local/elixir/bin:$PATH' >> $BASH_ENV
|
2017-12-11 20:28:35 -07:00
|
|
|
|
2018-01-03 17:09:13 -07:00
|
|
|
install_hex_archives: &install_hex_archives
|
|
|
|
run:
|
|
|
|
name: Install archives
|
2018-01-03 17:10:34 -07:00
|
|
|
command: |
|
|
|
|
mix local.hex --force
|
|
|
|
mix local.rebar --force
|
|
|
|
mix archive.install hex nerves_bootstrap --force
|
2018-01-03 17:09:13 -07:00
|
|
|
|
|
|
|
fetch_and_compile_deps: &fetch_and_compile_deps
|
|
|
|
run:
|
|
|
|
name: Fetch and compile Elixir dependencies
|
2018-01-03 17:10:34 -07:00
|
|
|
command: |
|
|
|
|
mix deps.get
|
|
|
|
mix deps.compile
|
|
|
|
mix compile
|
2018-01-03 17:09:13 -07:00
|
|
|
|
2018-01-05 11:46:58 -07:00
|
|
|
install_arduino: &install_arduino
|
2018-01-05 11:48:19 -07:00
|
|
|
run:
|
|
|
|
name: Run setup script
|
|
|
|
command: bash .circleci/setup-arduino.sh
|
2018-01-05 11:46:58 -07:00
|
|
|
|
2017-12-13 12:11:00 -07:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
<<: *defaults
|
2017-12-31 18:42:26 -07:00
|
|
|
environment:
|
|
|
|
MIX_ENV: test
|
2018-01-03 16:48:16 -07:00
|
|
|
MIX_TARGET: host
|
2017-12-11 20:28:35 -07:00
|
|
|
steps:
|
2018-01-05 12:35:47 -07:00
|
|
|
- checkout
|
2018-01-05 12:27:12 -07:00
|
|
|
- run: git submodule update --init --recursive
|
2017-12-11 20:43:47 -07:00
|
|
|
- <<: *install_elixir
|
2018-01-05 12:11:12 -07:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- v3-arduino-cache-{{ checksum ".circleci/setup-arduino.sh" }}
|
2018-01-05 12:27:12 -07:00
|
|
|
- <<: *install_arduino
|
2018-01-03 17:09:13 -07:00
|
|
|
- <<: *install_hex_archives
|
|
|
|
- <<: *fetch_and_compile_deps
|
2018-01-05 12:11:12 -07:00
|
|
|
- save_cache:
|
|
|
|
key: v3-arduino-cache-{{ checksum ".circleci/setup-arduino.sh" }}
|
|
|
|
paths:
|
|
|
|
- ~/arduino-1.8.5
|
2017-12-13 12:11:00 -07:00
|
|
|
- run:
|
2018-01-03 21:58:14 -07:00
|
|
|
command: mix coveralls.circle --exclude farmbot_firmware
|
2017-12-11 20:28:35 -07:00
|
|
|
|
2018-01-03 16:48:16 -07:00
|
|
|
firmware_dev:
|
2017-12-13 12:11:00 -07:00
|
|
|
<<: *defaults
|
2017-12-13 11:51:27 -07:00
|
|
|
environment:
|
|
|
|
MIX_TARGET: rpi3
|
2018-01-03 16:48:16 -07:00
|
|
|
MIX_ENV: dev
|
2017-12-13 12:22:30 -07:00
|
|
|
ENV: CI
|
2017-12-13 11:51:27 -07:00
|
|
|
steps:
|
2018-01-05 12:35:47 -07:00
|
|
|
- checkout
|
2018-01-05 12:27:12 -07:00
|
|
|
- run: git submodule update --init --recursive
|
2018-01-03 16:54:27 -07:00
|
|
|
- <<: *install_elixir
|
2018-01-05 12:11:12 -07:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2018-01-05 12:27:12 -07:00
|
|
|
- v3-arduino-cache-{{ checksum ".circleci/setup-arduino.sh" }}
|
2018-01-05 11:46:58 -07:00
|
|
|
- <<: *install_arduino
|
2018-01-03 16:54:27 -07:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- v3-dependency-cache-{{ checksum "mix.lock.rpi3" }}
|
2018-01-03 17:09:13 -07:00
|
|
|
- <<: *install_hex_archives
|
|
|
|
- <<: *fetch_and_compile_deps
|
2018-01-03 16:54:27 -07:00
|
|
|
- run: mix firmware
|
|
|
|
- save_cache:
|
|
|
|
key: v3-dependency-cache-{{ checksum "mix.lock.rpi3" }}
|
|
|
|
paths:
|
|
|
|
- ~/.nerves
|
2018-01-03 16:48:16 -07:00
|
|
|
- run: mix firmware.slack --channels C58DCU4A3
|
|
|
|
- run: mkdir -p artifacts
|
|
|
|
- run:
|
|
|
|
name: Decode fwup priv key
|
|
|
|
command: echo $FWUP_KEY_BASE64 | base64 --decode --ignore-garbage > $NERVES_FW_PRIV_KEY
|
2017-12-31 18:58:49 -07:00
|
|
|
- run:
|
2018-01-03 16:48:16 -07:00
|
|
|
name: Sign firmware
|
|
|
|
command: fwup -S -s $NERVES_FW_PRIV_KEY -i _build/${MIX_TARGET}/${MIX_ENV}/nerves/images/farmbot.fw -o artifacts/farmbot-${MIX_TARGET}-$(cat VERSION)-beta.fw
|
2017-12-31 18:31:37 -07:00
|
|
|
- save_cache:
|
2018-01-03 16:48:16 -07:00
|
|
|
key: v3-firmware-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }}
|
2017-12-31 18:31:37 -07:00
|
|
|
paths:
|
2018-01-03 16:48:16 -07:00
|
|
|
- ./artifacts
|
|
|
|
|
|
|
|
firmware_prod:
|
|
|
|
<<: *defaults
|
|
|
|
environment:
|
|
|
|
MIX_TARGET: rpi3
|
|
|
|
MIX_ENV: prod
|
|
|
|
ENV: CI
|
|
|
|
steps:
|
2018-01-05 12:35:47 -07:00
|
|
|
- checkout
|
2018-01-05 12:27:12 -07:00
|
|
|
- run: git submodule update --init --recursive
|
2018-01-03 16:54:27 -07:00
|
|
|
- <<: *install_elixir
|
2018-01-05 12:11:12 -07:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2018-01-05 12:27:12 -07:00
|
|
|
- v3-arduino-cache-{{ checksum ".circleci/setup-arduino.sh" }}
|
2018-01-05 11:46:58 -07:00
|
|
|
- <<: *install_arduino
|
2018-01-05 12:27:12 -07:00
|
|
|
- <<: *install_hex_archives
|
2018-01-03 16:54:27 -07:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- v3-dependency-cache-{{ checksum "mix.lock.rpi3" }}
|
|
|
|
- run: mix deps.get
|
|
|
|
- run: mix deps.compile
|
|
|
|
- run: mix compile
|
|
|
|
- run: mix firmware
|
|
|
|
- save_cache:
|
|
|
|
key: v3-dependency-cache-{{ checksum "mix.lock.rpi3" }}
|
|
|
|
paths:
|
|
|
|
- ~/.nerves
|
2018-01-03 16:48:16 -07:00
|
|
|
- run: mkdir -p artifacts
|
2018-01-03 12:09:05 -07:00
|
|
|
- run:
|
|
|
|
name: Decode fwup priv key
|
|
|
|
command: echo $FWUP_KEY_BASE64 | base64 --decode --ignore-garbage > $NERVES_FW_PRIV_KEY
|
|
|
|
- run:
|
|
|
|
name: Sign firmware
|
2018-01-03 16:48:16 -07:00
|
|
|
command: fwup -S -s $NERVES_FW_PRIV_KEY -i _build/${MIX_TARGET}/${MIX_ENV}/nerves/images/farmbot.fw -o artifacts/farmbot-${MIX_TARGET}-$(cat VERSION)-beta.fw
|
2018-01-03 11:56:52 -07:00
|
|
|
- save_cache:
|
|
|
|
key: v3-firmware-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }}
|
|
|
|
paths:
|
2018-01-03 12:42:26 -07:00
|
|
|
- ./artifacts
|
2018-01-03 11:56:52 -07:00
|
|
|
|
|
|
|
deploy_firmware:
|
|
|
|
<<: *defaults
|
|
|
|
steps:
|
2018-01-03 12:00:03 -07:00
|
|
|
- checkout
|
2018-01-04 10:18:46 -07:00
|
|
|
- run:
|
|
|
|
name: Run setup script
|
|
|
|
command: bash .circleci/setup-heroku.sh
|
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
- "97:92:32:5d:d7:96:e1:fa:f3:6b:f3:bd:d6:aa:84:c6"
|
2018-01-03 11:56:52 -07:00
|
|
|
- run:
|
2018-01-03 11:57:59 -07:00
|
|
|
name: Install dependencies
|
|
|
|
command: |
|
|
|
|
wget https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_linux_amd64.zip
|
|
|
|
unzip ghr_v0.5.4_linux_amd64.zip
|
2018-01-04 10:37:06 -07:00
|
|
|
wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
|
|
|
|
chmod +x ./jq-linux64
|
2018-01-03 11:56:52 -07:00
|
|
|
- run:
|
2018-01-03 12:35:30 -07:00
|
|
|
command: grep -Pazo "(?s)(?<=# $(cat VERSION))[^#]+" CHANGELOG.md > RELEASE_NOTES
|
2018-01-03 11:56:52 -07:00
|
|
|
- restore_cache:
|
2018-01-03 11:57:59 -07:00
|
|
|
key: v3-firmware-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }}
|
2018-01-03 11:56:52 -07:00
|
|
|
- run:
|
2018-01-03 15:47:43 -07:00
|
|
|
command: ./ghr -t $GITHUB_TOKEN -u farmbot -r farmbot_os -recreate -prerelease -b "$(cat RELEASE_NOTES)" -c $(git rev-parse --verify HEAD) "v$(cat VERSION)-beta" $PWD/artifacts
|
2018-01-04 10:19:38 -07:00
|
|
|
- run:
|
2018-01-04 10:18:46 -07:00
|
|
|
name: Update heroku env
|
|
|
|
command: |
|
2018-01-04 10:37:06 -07:00
|
|
|
export OTA_URL=$(wget https://api.github.com/repos/farmbot/farmbot_os/releases -qO- | ./jq-linux64 '.[0].url')
|
2018-01-04 10:54:33 -07:00
|
|
|
heroku config:set BETA_OTA_URL=$OTA_URL --app=farmbot-production
|
|
|
|
heroku config:set BETA_OTA_URL=$OTA_URL --app=farmbot-staging
|
2017-12-13 11:51:27 -07:00
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
2017-12-13 12:11:00 -07:00
|
|
|
test_firmware_upload:
|
2017-12-13 11:51:27 -07:00
|
|
|
jobs:
|
|
|
|
- test:
|
2017-12-13 12:11:00 -07:00
|
|
|
context: org-global
|
2018-01-03 10:28:48 -07:00
|
|
|
filters:
|
|
|
|
branches:
|
2018-01-03 14:14:35 -07:00
|
|
|
ignore: beta
|
2018-01-03 16:48:16 -07:00
|
|
|
- firmware_dev:
|
2017-12-13 12:11:00 -07:00
|
|
|
context: org-global
|
2018-01-03 16:48:16 -07:00
|
|
|
requires:
|
|
|
|
- test
|
2018-01-03 10:28:48 -07:00
|
|
|
filters:
|
2018-01-03 10:32:04 -07:00
|
|
|
branches:
|
2018-01-03 14:14:35 -07:00
|
|
|
ignore: beta
|
2018-01-03 10:32:04 -07:00
|
|
|
|
2018-01-03 14:14:35 -07:00
|
|
|
deploy_beta:
|
2018-01-03 14:16:35 -07:00
|
|
|
jobs:
|
2018-01-03 16:48:16 -07:00
|
|
|
- firmware_prod:
|
2018-01-03 14:16:35 -07:00
|
|
|
context: org-global
|
2018-01-03 14:03:44 -07:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
2018-01-03 14:14:35 -07:00
|
|
|
- beta
|
2018-01-03 11:56:52 -07:00
|
|
|
- deploy_firmware:
|
|
|
|
context: org-global
|
2018-01-03 14:16:35 -07:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- beta
|
2018-01-03 12:00:03 -07:00
|
|
|
requires:
|
2018-01-03 16:48:16 -07:00
|
|
|
- firmware_prod
|