Skip to content

Commit

Permalink
Merge pull request #21 from pantheon-systems/go-mod
Browse files Browse the repository at this point in the history
convert to go modules and circleci 2.x
  • Loading branch information
joemiller committed Aug 4, 2019
2 parents 9054164 + a0f294b commit 07233ec
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 158 deletions.
76 changes: 76 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
version: 2.1

executors:
go-build:
docker:
- image: circleci/golang:1.12

commands:
save-go-mod-cache:
steps:
- save_cache:
key: v1-dependencies-{{ checksum "go.sum" }}
paths:
- /go/pkg/mod

restore-go-mod-cache:
steps:
- restore_cache:
keys:
- v1-dependencies-{{ checksum "go.sum" }}

save-workspace:
steps:
- persist_to_workspace:
root: .
paths:
- ./

restore-workspace:
steps:
- attach_workspace:
at: .

jobs:
test:
executor: go-build
steps:
- checkout
- restore-go-mod-cache
# commands
- run: |
git config --global user.email circleci
git config --global user.name circleci
- run: make deps-coverage
- run: go get
- run: make test-circle
- run: make build
# persist
- save-go-mod-cache
- save-workspace

release:
executor: go-build
steps:
- restore-workspace
- restore-go-mod-cache
# commands
- run: |
# ./autotag/autotag binary from the test job is not saved to the workspace with +x bit, restore it
chmod +x ./autotag/autotag
- run: GO111MODULE=off go get github.com/aktau/github-release
- run: make release

workflows:
version: 2
primary:
jobs:
- test
- release:
requires:
- test
filters:
branches:
only:
- master
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
APP=autotag
APP := autotag

include scripts/make/common.mk
include scripts/make/common-go.mk

# need to be able to commit with git to run tests on cirlce
deps-circle::
git config --global user.email circleci
git config --global user.name circleci
ifeq (, $(shell which gihub-release))
go get github.com/aktau/github-release
endif

build::
go build -o $(APP)/$(APP) $(APP)/*.go

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
AutoTag
=======

[![Circle CI](https://circleci.com/gh/pantheon-systems/autotag.svg?style=shield&circle-token=ef9a68c180d0d470c594d39caf9e2a86fc529935)](https://circleci.com/gh/pantheon-systems/autotag)
[![Coverage Status](https://coveralls.io/repos/github/pantheon-systems/autotag/badge.svg?branch=master)](https://coveralls.io/github/pantheon-systems/autotag?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/pantheon-systems/autotag)](https://goreportcard.com/report/github.com/pantheon-systems/autotag)

AutoTag
-------

Automatically add version tags to a git repo based on commit messages.

Dependencies
============
------------

* [Git 2.x](https://git-scm.com/downloads) available in PATH
* [Git 2.x](https://git-scm.com/downloads) available in PATH (version v1.0.0+)

Installing
==========
----------

On Linux the easy way to get going is to use the pre-built binary release from [GitHub Releases](https://github.com/pantheon-systems/autotag/releases).

If using a recent version that depends on the Git CLI, install Git with your distribution's package management system.
Version v1.0.0+ depends on the Git CLI, install Git with your distribution's package management system.

If using an older release with cgo libgit or native golang Git, the binary will work standalone.
Versions prior to v1.0.0 use cgo libgit or native golang Git, the binary will work standalone.

Calculating Tags
================
----------------

The `autotag` utility will use the current state of the git repository to determine what the next tag should be (when following SemVer 2.0).
Tags created by `autotag` have the following format: `vMajor.Minor.Patch` (e.g., `v1.2.3`).
Expand Down Expand Up @@ -76,7 +76,7 @@ implemented in the `-p` flag, while the timestamp layout is implemented in the `
information.

Usage
=====
-----

The default behavior with no arguments will tag a new version on current repo and emit the version tagged:

Expand Down Expand Up @@ -124,7 +124,7 @@ Help Options:
```

Build from Source
=================
-----------------

Assuming you have Go 1.5+ installed you can checkout and run make deps build to compile the binary. It will be built as ./autotag/autotag

Expand Down
6 changes: 3 additions & 3 deletions autotag.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ func parseVersion(v string) (*version.Version, error) {
}

// LatestVersion Reports the Lattest version of the given repo
// TODO:(jnelson) this could be more intelligent, looking for a nil new and reporitng the latest version found if we refactor autobump at some point Mon Sep 14 13:05:49 2015
// TODO:(jnelson) this could be more intelligent, looking for a nil new and reporting the latest version found if we refactor autobump at some point Mon Sep 14 13:05:49 2015
func (r *GitRepo) LatestVersion() string {
return fmt.Sprintf("%s", r.newVersion)
return r.newVersion.String()
}

func (r *GitRepo) retrieveBranchInfo() error {
Expand Down Expand Up @@ -288,7 +288,7 @@ func (r *GitRepo) calcVersion() error {
for e := l.Back(); e != nil; e = e.Prev() {
commit := e.Value.(*git.Commit)
if commit == nil {
return fmt.Errorf("commit pointed to nil object. This should not happen: %s", e)
return fmt.Errorf("commit pointed to nil object. This should not happen: %v", e)
}

v, nerr := r.parseCommit(commit)
Expand Down
32 changes: 0 additions & 32 deletions circle.yml

This file was deleted.

12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module github.com/pantheon-systems/autotag

go 1.12

require (
github.com/Unknwon/com v0.0.0-20170213072014-0db4a625e949 // indirect
github.com/gogits/git-module v0.0.0-20170404055912-2a496cad1f36
github.com/hashicorp/go-version v0.0.0-20161031182605-e96d38404026
github.com/jessevdk/go-flags v0.0.0-20161025193802-0648c820cd4e
github.com/mcuadros/go-version v0.0.0-20161105183618-257f7b9a7d87 // indirect
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect
)
23 changes: 23 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
github.com/Unknwon/com v0.0.0-20170213072014-0db4a625e949 h1:/Ex2JgvIGodN4zioOyd3w4NyicUO36egyncpI05kmu8=
github.com/Unknwon/com v0.0.0-20170213072014-0db4a625e949/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no=
github.com/gogits/git-module v0.0.0-20170404055912-2a496cad1f36 h1:sZNxvHsqrwZ5AZp+UhzkhHQ8LH8O0SBR2NavZN1O42A=
github.com/gogits/git-module v0.0.0-20170404055912-2a496cad1f36/go.mod h1:oTJZlouTqkUQTWbH0xMMlMuMSHBmj7FtcxvguKfYUkE=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hashicorp/go-version v0.0.0-20161031182605-e96d38404026 h1:qWx/DcC6l4ZzuS+JBAzI5XjtLFDCc08zYeZ0kLnaH2g=
github.com/hashicorp/go-version v0.0.0-20161031182605-e96d38404026/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/jessevdk/go-flags v0.0.0-20161025193802-0648c820cd4e h1:l/+xY46pWbjciNv4PwYctnKUi7ks9Qx7c2SbDSwLwrc=
github.com/jessevdk/go-flags v0.0.0-20161025193802-0648c820cd4e/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/mcuadros/go-version v0.0.0-20161105183618-257f7b9a7d87 h1:SDD/Ssrg7y8McDKzCytoY2OsBD5U5ERzEiFsnryQMZc=
github.com/mcuadros/go-version v0.0.0-20161105183618-257f7b9a7d87/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
Loading

0 comments on commit 07233ec

Please sign in to comment.