Skip to content

Integrate with CircleCI

Steven Thomas edited this page Mar 15, 2018 · 1 revision

The most common use case for semantics that we've had so far has involved integrating with CircleCI. This allows all master builds in CircleCI to automatically create and push a new tag to GitHub.

Unfortunately, it's a little tricky getting everything set up properly. So here's a quick walkthrough:

Setting up semantics in CircleCI

  1. Create a deploy key for your GitHub repo. Ensure that it has read/write permissions.
  2. Import that deploy key into the CircleCI settings page for that repo. Set the hostname to github.com.
  3. If you're using CircleCI 2.0 you will also need change your config.yml file.
    • Add the command add_ssh_keys to the step that is responsible for executing semantics. Example.

Once you follow the steps above, you should have the necessary permissions to create tags in GitHub.

Using semantics in CircleCI

You're free to use semantics however you like, but here's a simple method that works well in CircleCI.

Just add the following bash commands in the deploy phase of your CircleCI 2.0 config:

go get -u github.com/stevenmatthewt/semantics
tag=$(semantics --output-tag) # This pushes to GitHub, and also captures the tag
if [ "$tag" ]; then
  # You have the new tag, so you're free to do whatever you want with it.
  # You can push it to NPM, DockerHub, Quay...
else
  echo "The commit message(s) did not indicate a major/minor/patch version."
fi
Clone this wiki locally