CircleCI Field Guide
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

Field Engineering Workbench Orb

The FE orb is a collection of common function level steps, mostly bash snippets, with some improvement to encourage best practices.

Semantic Versioning helpers

There are 3 commands and a job that emcompasses them in a single call.

Example

Given current version 1.2.3:

  • [semver:patch] would be 1.2.4
  • [semver:minor] would be 1.3.0
  • [semver:major] would be 2.0.0

The values are then stored as ${MAJOR}, ${MINOR}, ${PATCH} varaiables which can be read in subsequent steps.

Job: Bump (4)

Bump runs the incremental logic script based on input variables CURRENT_VERSION and SEMVER_INCREMENT which can be provided via git commit messages, files in the repo, or git tags.

Available as:

  • a job that also parses the CURRENT_VERSION and SEMVER_INCREMENT from git and tags the remote repository with new version.
  • a command which performs only the incrementing logic, requiring input variables are provided as input.

Command: incrementfromgit parses Bump Increment from Git Commit Log (2)

This command will use git log to find the specified “bump” {major, minor, patch}

You can alternately just manually set SEMVER_INCREMENT

Command: versionfromgit parses Current Version from Git Tags (2)

This command will use git tag to find current version

You can alternately just manually set CURRENT_VERSION

command: tagremote Tags Remote repo with new ‘bumped’ version (3)

Creates and pushes tag matching ${PREFIX}${MAJOR}.${MINOR}.${PATCH} to remote repo.

Bumping SEMVER with prefix

If you use a prefix on versions (i.e. v1.2.3, RC0.0.1, beta-0.1.1, etc) You must provide that as an orb parameter version-prefix. The prefix will be retained as ${PREFIX} along side the version digits, and included in remote tag.

Key Commands

Trust GH Keys (1)

This queries api.github.com/meta for current SSH keys, and adds them to the /.ssh/known_hosts

This is safer than use of keyscan which is vulnerable to Man-in-the-middle attacks (MITM).

Workbench Orb Example Config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
version: 2.1
orbs:
  terraform: circleci/terraform@3.2.1
  workbench: cci-labs/workbench@0.0.1 # (0)

jobs:
  tf-validate:
    executor: terraform/default
    steps:
      - workbench/trust_gh_keys # (1)
      - run: SomeCustomCHeckout.sh
      - terraform/fmt
      - terraform/validate
  manual-bump:
    executor: terraform/default
    steps:
      - run: | # (2)
          # Manually set values that `versionfromgit` and `incrementfromgit` commands would parse for us.
          echo "export CURRENT_VERSION=1.2.3" >> $BASH_ENV
          echo "export SEMVER_INCREMENT=minor" >> $BASH_ENV
      # Use bump and tag commands.    
      - workbench/bump
      - workbench/tagremote  # (3)

workflows:
  main:
    jobs:
      - tf-validate:
          name: Validate Terraform Plan
      - workbench/bump: # (4)
          requires: [Validate Terraform Plan]
          filters:
            branches:
              only: [main]
  alternate:
    jobs:
      - manual-bump:
          filters:
            branches:
              only: [main]