All checks were successful
continuous-integration/drone/push Build is passing
351 lines
9.2 KiB
YAML
351 lines
9.2 KiB
YAML
kind: pipeline
|
|
type: docker
|
|
name: build
|
|
|
|
steps:
|
|
- name: restore ASDF cache
|
|
image: meltwater/drone-cache
|
|
pull: "always"
|
|
environment:
|
|
AWS_ACCESS_KEY_ID:
|
|
from_secret: ACCESS_KEY_ID
|
|
AWS_SECRET_ACCESS_KEY:
|
|
from_secret: SECRET_ACCESS_KEY
|
|
AWS_PLUGIN_PATH_STYLE: true
|
|
settings:
|
|
restore: true
|
|
endpoint:
|
|
from_secret: S3_ENDPOINT
|
|
bucket:
|
|
from_secret: CACHE_BUCKET
|
|
region: us-east-1
|
|
path-style: true
|
|
cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}'
|
|
mount:
|
|
- .asdf
|
|
|
|
- name: restore build cache
|
|
image: meltwater/drone-cache
|
|
environment:
|
|
AWS_ACCESS_KEY_ID:
|
|
from_secret: ACCESS_KEY_ID
|
|
AWS_SECRET_ACCESS_KEY:
|
|
from_secret: SECRET_ACCESS_KEY
|
|
AWS_PLUGIN_PATH_STYLE: true
|
|
settings:
|
|
restore: true
|
|
endpoint:
|
|
from_secret: S3_ENDPOINT
|
|
bucket:
|
|
from_secret: CACHE_BUCKET
|
|
region: us-east-1
|
|
path-style: true
|
|
cache_key: 'elixir-{{ checksum "mix.lock" }}-{{ checksum ".tool-versions" }}'
|
|
mount:
|
|
- deps
|
|
- _build
|
|
- .hex
|
|
- .mix
|
|
- .rebar3
|
|
|
|
- name: install dependencies
|
|
image: harton.dev/james/asdf_container:latest
|
|
pull: "always"
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
ASDF_DIR: /root/.asdf
|
|
depends_on:
|
|
- restore ASDF cache
|
|
- restore build cache
|
|
commands:
|
|
- asdf_install
|
|
- rm -rf .asdf/downloads
|
|
- . $ASDF_DIR/asdf.sh
|
|
- mix local.hex --if-missing --force
|
|
- mix local.rebar --if-missing --force
|
|
- mix deps.get
|
|
- mix deps.compile
|
|
|
|
- name: store ASDF cache
|
|
image: meltwater/drone-cache
|
|
environment:
|
|
AWS_ACCESS_KEY_ID:
|
|
from_secret: ACCESS_KEY_ID
|
|
AWS_SECRET_ACCESS_KEY:
|
|
from_secret: SECRET_ACCESS_KEY
|
|
AWS_PLUGIN_PATH_STYLE: true
|
|
depends_on:
|
|
- install dependencies
|
|
settings:
|
|
rebuild: true
|
|
override: false
|
|
endpoint:
|
|
from_secret: S3_ENDPOINT
|
|
bucket:
|
|
from_secret: CACHE_BUCKET
|
|
region: us-east-1
|
|
path-style: true
|
|
cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}'
|
|
mount:
|
|
- .asdf
|
|
|
|
- name: store build cache
|
|
image: meltwater/drone-cache
|
|
environment:
|
|
AWS_ACCESS_KEY_ID:
|
|
from_secret: ACCESS_KEY_ID
|
|
AWS_SECRET_ACCESS_KEY:
|
|
from_secret: SECRET_ACCESS_KEY
|
|
AWS_PLUGIN_PATH_STYLE: true
|
|
depends_on:
|
|
- install dependencies
|
|
settings:
|
|
rebuild: true
|
|
override: false
|
|
endpoint:
|
|
from_secret: S3_ENDPOINT
|
|
bucket:
|
|
from_secret: CACHE_BUCKET
|
|
region: us-east-1
|
|
path-style: true
|
|
cache_key: 'elixir-{{ checksum "mix.lock" }}-{{ checksum ".tool-versions" }}'
|
|
mount:
|
|
- deps
|
|
- _build
|
|
- .hex
|
|
- .mix
|
|
- .rebar3
|
|
|
|
- name: mix compile
|
|
image: harton.dev/james/asdf_container:latest
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
depends_on:
|
|
- install dependencies
|
|
commands:
|
|
- asdf mix compile --warnings-as-errors
|
|
|
|
- name: mix test
|
|
image: harton.dev/james/asdf_container:latest
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
depends_on:
|
|
- mix compile
|
|
commands:
|
|
- asdf mix test
|
|
|
|
- name: mix credo
|
|
image: harton.dev/james/asdf_container:latest
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
depends_on:
|
|
- mix compile
|
|
commands:
|
|
- asdf mix credo --strict
|
|
|
|
- name: mix hex.audit
|
|
image: harton.dev/james/asdf_container:latest
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
depends_on:
|
|
- mix compile
|
|
commands:
|
|
- asdf mix hex.audit
|
|
|
|
- name: mix format
|
|
image: harton.dev/james/asdf_container:latest
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
depends_on:
|
|
- mix compile
|
|
commands:
|
|
- asdf mix format --check-formatted
|
|
|
|
- name: mix deps.unlock
|
|
image: harton.dev/james/asdf_container:latest
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
depends_on:
|
|
- mix compile
|
|
commands:
|
|
- asdf mix deps.unlock --check-unused
|
|
|
|
- name: mix git_ops.check_message
|
|
image: harton.dev/james/asdf_container:latest
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
depends_on:
|
|
- mix compile
|
|
commands:
|
|
- git log -1 --format=%s > .last_commit_message
|
|
- asdf mix git_ops.check_message .last_commit_message
|
|
|
|
- name: mix git_ops.release
|
|
image: harton.dev/james/asdf_container:latest
|
|
when:
|
|
branch:
|
|
- main
|
|
event:
|
|
exclude:
|
|
- pull_request
|
|
depends_on:
|
|
- mix test
|
|
- mix credo
|
|
- mix hex.audit
|
|
- mix format
|
|
- mix deps.unlock
|
|
- mix git_ops.check_message
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
ASDF_DIR: /root/.asdf
|
|
DRONE_TOKEN:
|
|
from_secret: DRONE_TOKEN
|
|
commands:
|
|
- git fetch --tags
|
|
- . $ASDF_DIR/asdf.sh
|
|
- mix git_ops.project_info --format=shell > before.env
|
|
- mix git_ops.release --yes --no-major || true
|
|
- mix git_ops.project_info --format=shell > after.env
|
|
- . ./before.env
|
|
- export OLD_APP_VERSION=$${APP_VERSION}
|
|
- . ./after.env
|
|
- export NEW_APP_VERSION=$${APP_VERSION}
|
|
- if [ "v$${OLD_APP_VERSION}" != "v$${NEW_APP_VERSION}" ]; then
|
|
- export GIT_URL=$(echo $DRONE_GIT_HTTP_URL | sed -e "s/:\\/\\//:\\/\\/$DRONE_REPO_OWNER:$DRONE_TOKEN@/")
|
|
- git push $${GIT_URL} "HEAD:${DRONE_COMMIT_REF}" "refs/tags/v$${NEW_APP_VERSION}"
|
|
- fi
|
|
|
|
- name: build artifacts
|
|
image: harton.dev/james/asdf_container:latest
|
|
when:
|
|
event:
|
|
- tag
|
|
refs:
|
|
include:
|
|
- refs/tags/v*
|
|
depends_on:
|
|
- mix test
|
|
- mix credo
|
|
- mix hex.audit
|
|
- mix format
|
|
- mix deps.unlock
|
|
- mix git_ops.check_message
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
ASDF_DIR: /root/.asdf
|
|
commands:
|
|
- . $ASDF_DIR/asdf.sh
|
|
- mix git_ops.project_info --format=shell > app.env
|
|
- . ./app.env
|
|
- mkdir artifacts
|
|
- mix hex.build -o "artifacts/$${APP_NAME}-$${APP_VERSION}-pkg.tar"
|
|
- gzip "artifacts/$${APP_NAME}-$${APP_VERSION}-pkg.tar"
|
|
- mix docs
|
|
- tar zcvf "artifacts/$${APP_NAME}-$${APP_VERSION}-docs.tar.gz" doc/
|
|
- git tag -l --format='%(contents:subject)' v$${APP_VERSION} > tag_subject
|
|
- git tag -l --format='%(contents:body)' v$${APP_VERSION} > tag_body
|
|
|
|
- name: gitea release
|
|
image: plugins/gitea-release
|
|
when:
|
|
event:
|
|
- tag
|
|
refs:
|
|
include:
|
|
- refs/tags/v*
|
|
depends_on:
|
|
- build artifacts
|
|
settings:
|
|
api_key:
|
|
from_secret: DRONE_TOKEN
|
|
base_url: https://harton.dev
|
|
files: artifacts/*.tar.gz
|
|
checksum: sha256
|
|
title: tag_subject
|
|
note: tag_body
|
|
|
|
- name: docs release
|
|
when:
|
|
event:
|
|
- tag
|
|
refs:
|
|
include:
|
|
- refs/tags/v*
|
|
image: minio/mc
|
|
environment:
|
|
S3_ENDPOINT:
|
|
from_secret: S3_ENDPOINT
|
|
ACCESS_KEY:
|
|
from_secret: ACCESS_KEY_ID
|
|
SECRET_KEY:
|
|
from_secret: SECRET_ACCESS_KEY
|
|
depends_on:
|
|
- build artifacts
|
|
commands:
|
|
- mc alias set store $${S3_ENDPOINT} $${ACCESS_KEY} $${SECRET_KEY}
|
|
- mc mb -p store/docs.harton.nz
|
|
- mc mirror --overwrite doc/ store/docs.harton.nz/$${DRONE_REPO}/$${DRONE_TAG}
|
|
- mc mirror --overwrite doc/ store/docs.harton.nz/$${DRONE_REPO}
|
|
|
|
- name: hex release
|
|
image: harton.dev/james/asdf_container:latest
|
|
when:
|
|
event:
|
|
- tag
|
|
refs:
|
|
include:
|
|
- refs/tags/v*
|
|
depends_on:
|
|
- build artifacts
|
|
environment:
|
|
MIX_ENV: test
|
|
HEX_HOME: /drone/src/.hex
|
|
MIX_HOME: /drone/src/.mix
|
|
REBAR_BASE_DIR: /drone/src/.rebar3
|
|
ASDF_DATA_DIR: /drone/src/.asdf
|
|
ASDF_DIR: /root/.asdf
|
|
HEX_API_KEY:
|
|
from_secret: HEX_API_KEY
|
|
commands:
|
|
- . $ASDF_DIR/asdf.sh
|
|
- mix hex.publish --yes
|