GithubHelp home page GithubHelp logo

go-versioning's Introduction

go-versioning

This repository demonstrates one way to version go projects.

Artifacts

  • Go binary
    To create a Go binary from this repository's source code, just run make without arguments in your local copy. Every binary built with this command knows its version number. You can retrieve it like this:

    $ ./go-versioning --version
    go-versionining version 0.3.0 build 2106621
    
  • Docker image
    To create a Docker image with the Go binary in it, run make docker-image. This will build a Docker image with the output of git describe --tags --always as tag name. This means that when your repository is currently on the revision of tag v0.3.0, the Docker image's tag will be v0.3.0. If you add one commit and build the Docker image again, its tag will be something like v0.3.0-1-gabc123.

Releasing new Versions

Applying the concept of Semantic Versioning, there are three make targets to create releases:

  • make release-major
  • make release-minor
  • make release-patch

Each of these targets increments the respective version number in the VERSION file, commits it, and tags the commit with the correct version number.

Note:
While preparing this setup, I created several releases in order to test the setup itself. Because I went back and forth between commits and edited things in old releases (which is not a good practice in general), I added a Make target retag-releases that makes sure that all git tags point to the correct release commits. It's probably not a good idea to do this in a real life project.

Limitations of this approach:

  • In the current implementation, there is no check that your working copy is clean when executing one of the above-mentioned make targets. This means that you could build a docker image ...:v1.0.0 with changes that are only present on your local hard drive.
  • Code-Duplication: Having this kind of logic in Makefiles makes it hard to reuse it in other repositories. This could be resolved by implementing it in a separate tool that is just being executed in the Makefile.

go-versioning's People

Contributors

seiffert avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.