Devops

Hex.pmHex DocsCICoverage: 100%License: MIT

devops is a set of Mix tasks that automate the full git-flow / release / GitHub lifecycle for a single-package Elixir project: bootstrapping a new repository, validating and committing changes with Conventional Commit messages, running quality gates, and cutting a tagged, changelogged, hex-published release -- all driven by one small project config file.

It exists so that workflow (branch names, commit conventions, CI gates, release steps) lives in configuration and this shared library, not copied and adapted, script by script, into every project that needs it.

What it automates

Installation

Add devops to your project's dependencies in mix.exs:

def deps do
[
{:devops, "~> 0.6"}
]
end

Configuration

devops reads its config from the :devops application environment, using the standard Config DSL, imported from your project's own env-specific config file:

# config/devops.exs
import Config
config :devops, :repo, owner: "your-org", name: "your-project", visibility: :private
config :devops, :branches, production: "main"
config :devops, :commit_types, feat: :minor, fix: :patch, chore: :none
# config/config.exs (or config/dev.exs, etc.)
import Config
import_config "devops.exs"

Each section merges independently over its own defaults, so you only need to set the keys you want to change:

SectionKey(s)Default
:reposcs, owner, name, visibilityscs: :github, owner: nil, name: nil, visibility: :private
:branchesintegration, production, default, remote, tag_prefixdev, master, master, origin, v
:commit_typesConventional Commit type -> version-bump effectfeat: :minor, fix: :patch, chore: :none, etc.
:prehooktools, commit_message, ai_backend["git", "mix"], Devops.CommitMessage.AI, Devops.AI.ClaudeCLI
:posthookbump_versiontrue
:ciawait_timeout_ms, poll_interval_ms1_800_000, 15_000
:gatesa list or map of {label, args, where} gates, or nilnil (computes Devops.Gates.default_gates/1)

:gates is the one section that does not merge key-by-key: leave it unset to get the built-in gate list, set it to a plain list to replace the default outright, or set it to a map (%{label => {args, where}}) to merge over the default list, overriding or adding individual gates without respecifying the rest.

GITHUB_TOKEN (read by Devops.GitHub) and HEX_API_KEY (read by Devops.HexPublish) are expected in the environment -- via a real exported variable, or a gitignored .env/.env.#{MIX_ENV} file at the project root, loaded automatically at boot by the vendored DotenvParser.

Usage

# One-time bootstrap of a brand-new project
$ mix devops.init
# Day to day: validate, commit, push, open a PR, wait on CI, fast-forward
$ mix devops.commit
# Just the quality gates, without fetching/compiling deps
$ mix devops.quality
# Fetch deps, compile, then run quality gates
$ mix devops.build
# Cut a release: commit, tag, changelog, GitHub release, hex.publish
$ mix devops.release

Run mix help for the full list of devops.* tasks, or see each task's own @moduledoc for details.

Documentation

Full API documentation is generated with ExDoc and published on HexDocs.

Acknowledgements

lib/vendor/dotenv_parser.ex is vendored from dotenv_parser by Mikko Ahlroth, MIT licensed -- see lib/vendor/LICENSE. It is vendored rather than taken as a regular dependency so config/runtime.exs can load a project's .env file before any dependency's own config-time code runs.

License

devops is released under the MIT License.