Step 2: Generate Semantic Versions

Automatically generate semantic versions based on git tag/branch and commit hash (sha).

Semvers allow us to deploy applications that remain stable despite a constantly changing and evolving web of dependencies. Everytime we build a docker image or helm chart, we want to use strict version pinning so that dependent services (e.g. helm charts) can reference them. Using this strategy we may rest assured that our applications can be safely deployed at any point in the future without worrying about dependencies.

Dependency

Examples

Generate Semantic Versions using Build Harness

version: '1.0'

steps:
  init_variables:
    title: Init variables
    image: alpine
    commands:
    - cf_export BUILD_HARNESS_VERSION=0.5.5
    - cf_export CF_BUILD_UNIX_TIMESTAMP=$(expr ${{CF_BUILD_TIMESTAMP}} / 1000)
    - cf_export GIT_BRANCH=${{CF_BRANCH}}
    - cf_export BASE_HOST=us-west-2.staging.example.com
    - cf_export NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}}
    - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.us-west-2.staging.example.com