Hacker News new | ask | show | jobs
by turboponyy 52 days ago
> It seemed reasonable to me record the deployment history in the repository

That doesn't seem reasonable to me. You'd be using Git for persistence concerns that are not directly related to source code management.

"Environment X had commit a1b2c3d deployed at 1970-01-01T00:00:00Z" is all you need to store, and I don't see why you'd want to do that in the repo itself. Commit a1b2c3d exists regardless of where or when it's deployed.

Store that data in the thing that handles the deployments.

2 comments

I'm a big fan of just adding a simple script like `git describe --always --dirty > VERSION` in the output files of the deployment process. Or otherwise including it in bundle or executable metadata. (Subtly reformatting it to pass to `dotnet build -p:Version $GITDESCRIBEISH`, for instance, or putting it into a .json file that a web service will statically serve.) Similarly outputting `git describe --always --dirty` into CI/CD logs can be very handy.

You can use git describe's output to exactly name a commit. You can also use annotated tags to tag semver releases or marver (Marketing Version) releases and if you output the git describe to users that care about semver or marver they see confidence in your deployment system when you deploy exactly a tag versus deploy something like a hotfix after it. But git describe is also useful for lower environments because it will have useful output when not directly on a tag.

(ETA: For a monorepo you can still use semver/marver annotated tags with `git describe --match subproject/` to use a tree structure for tags.)

Totally agree. It seems like a good idea at first as it's simple, but, since the deployment concerns don't match the source code management ones it breaks down quite quickly.

For example it's quite readable when deployment order matches the commit order, but it gets problematic when e.g. the deployed version is rolled back to a previous version.

It also gets messy as environments are added, or even worse you have to manage customer-specific deployments.