Skip to content

Commit

Permalink
feat: lint version and publish docker images on version tags (#1343)
Browse files Browse the repository at this point in the history
* feat: publish docker images on vMAJOR.MINOR.PATCH tags

* fix: enfore version branch and tag filtering with a leading "v"

* feat: lint that the git tag and VERSION must match before publishing a version-tagged docker image

* fix: git tag has a leading "v"

* fix: more descriptive version check error message

* fix: move version tag checking to circleci job level
  • Loading branch information
unnawut authored Feb 25, 2020
1 parent 4cc1445 commit 2ae0e84
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ jobs:
- run: make install-hex-rebar
- run: mix do compile --warnings-as-errors --force, credo, format --check-formatted --dry-run

lint_version:
executor: builder
steps:
- setup_elixir-omg_workspace
- run:
command: |
if [ -n "$CIRCLE_TAG" ]; then
_tagged_version="${CIRCLE_TAG#*v}"
_filed_version="$(head -n 1 ./VERSION | sed 's/^[ \t]*//;s/[ \t]*$//')"
if [ "$_tagged_version" != "$_filed_version" ]; then
echo "The git tag \"${CIRCLE_TAG}\" expects the VERSION to be \"${_tagged_version}\". Got \"${_filed_version}\"."
exit 1
fi
else
echo "This build is not version-tagged. Skipping version lint."
exit 0
fi
sobelow:
executor: builder_pg
environment:
Expand Down Expand Up @@ -674,6 +693,8 @@ workflows:
requires: [build]
- lint:
requires: [build]
- lint_version:
requires: [build]
- sobelow:
requires: [build]
- dialyzer:
Expand All @@ -682,7 +703,7 @@ workflows:
requires: [build]
- property_tests:
requires: [build]
# Publish in case of master branch.
# Publish in case of master branch, version branches and version tags.
- publish_child_chain:
requires:
[
Expand All @@ -694,13 +715,18 @@ workflows:
property_tests,
dialyzer,
lint,
lint_version,
]
filters:
branches:
only:
- master
# vMAJOR.MINOR (e.g. v0.1, v0.2, v1.0, v2.1, etc.)
- /v[0-9]+\.[0-9]+/
- /^v[0-9]+\.[0-9]+/
tags:
only:
# vMAJOR.MINOR.PATCH (e.g. v0.1.0, v0.2.9, v1.0.0, v2.1.3 etc.)
- /^v[0-9]+\.[0-9]+\.[0-9]+/
- publish_watcher:
requires:
[
Expand All @@ -712,13 +738,18 @@ workflows:
property_tests,
dialyzer,
lint,
lint_version,
]
filters:
branches:
only:
- master
# vMAJOR.MINOR (e.g. v0.1, v0.2, v1.0, v2.1, etc.)
- /v[0-9]+\.[0-9]+/
- /^v[0-9]+\.[0-9]+/
tags:
only:
# vMAJOR.MINOR.PATCH (e.g. v0.1.0, v0.2.9, v1.0.0, v2.1.3 etc.)
- /^v[0-9]+\.[0-9]+\.[0-9]+/
- publish_watcher_info:
requires:
[
Expand All @@ -730,13 +761,18 @@ workflows:
property_tests,
dialyzer,
lint,
lint_version,
]
filters:
branches:
only:
- master
# vMAJOR.MINOR (e.g. v0.1, v0.2, v1.0, v2.1, etc.)
- /v[0-9]+\.[0-9]+/
- /^v[0-9]+\.[0-9]+/
tags:
only:
# vMAJOR.MINOR.PATCH (e.g. v0.1.0, v0.2.9, v1.0.0, v2.1.3 etc.)
- /^v[0-9]+\.[0-9]+\.[0-9]+/
# Release deploy to development in case of master branch.
- deploy_child_chain:
requires: [publish_child_chain, publish_watcher, publish_watcher_info]
Expand Down

0 comments on commit 2ae0e84

Please sign in to comment.