From a20e7b15e4a8e168a0050b7b1db0cb40fa1edf5a Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Fri, 20 Oct 2017 15:07:29 -0700 Subject: [PATCH 01/13] Upgraded to Go 1.9 and dep --- Dockerfile | 6 ++--- README.md | 4 +-- build.sh | 6 ++--- cli/Godeps/Godeps.json | 46 ---------------------------------- cli/Godeps/Readme | 5 ---- cli/Gopkg.lock | 56 ++++++++++++++++++++++++++++++++++++++++++ cli/Gopkg.toml | 42 +++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- 8 files changed, 107 insertions(+), 60 deletions(-) delete mode 100644 cli/Godeps/Godeps.json delete mode 100644 cli/Godeps/Readme create mode 100644 cli/Gopkg.lock create mode 100644 cli/Gopkg.toml diff --git a/Dockerfile b/Dockerfile index c6a4b61..fadd77b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM golang:1.7-alpine +FROM golang:1.9-alpine RUN apk add --no-cache \ ca-certificates \ git \ gcc \ musl-dev \ - && go get github.com/tools/godep \ - && go get github.com/mitchellh/gox + && go get -u github.com/golang/dep/... \ + && go get -u github.com/mitchellh/gox diff --git a/README.md b/README.md index 8f45ef1..4d012bd 100644 --- a/README.md +++ b/README.md @@ -28,14 +28,14 @@ Get all the dependencies ```bash # Go Dependency Manager -go get github.com/tools/godep +go get -u github.com/golang/dep/... # Go Cross Platform Build Tool go get github.com/mitchellh/gox # Install the project dependencies into $GOPATH cd $GOPATH/src/github.com/phase2/rig/cli -godep restore +dep ensure ``` Code diff --git a/build.sh b/build.sh index c4871e2..0e3b7ec 100755 --- a/build.sh +++ b/build.sh @@ -2,12 +2,12 @@ # # To use this you will need to: go get github.com/mitchellh/gox -go get github.com/tools/godep -go get github.com/mitchellh/gox +go get -u github.com/golang/dep/... +go get -u github.com/mitchellh/gox pushd cli -godep restore +dep ensure # Build for platforms gox -osarch="Darwin/amd64" -output="../build/darwin/rig" diff --git a/cli/Godeps/Godeps.json b/cli/Godeps/Godeps.json deleted file mode 100644 index fbc03bf..0000000 --- a/cli/Godeps/Godeps.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "ImportPath": "github.com/phase2/rig/cli", - "GoVersion": "go1.7", - "GodepVersion": "v79", - "Deps": [ - { - "ImportPath": "github.com/bitly/go-simplejson", - "Comment": "v0.5.0", - "Rev": "aabad6e819789e569bd6aabf444c935aa9ba1e44" - }, - { - "ImportPath": "github.com/fatih/color", - "Comment": "v0.1-12-g9aae6aa", - "Rev": "9aae6aaa22315390f03959adca2c4d395b02fcef" - }, - { - "ImportPath": "github.com/hashicorp/go-version", - "Rev": "03c5bf6be031b6dd45afec16b1cf94fc8938bc77" - }, - { - "ImportPath": "github.com/kardianos/osext", - "Rev": "29ae4ffbc9a6fe9fb2bc5029050ce6996ea1d3bc" - }, - { - "ImportPath": "github.com/mattn/go-colorable", - "Rev": "4af63d73f5bea08b682ad2cd198b1e607afd6be0" - }, - { - "ImportPath": "github.com/mattn/go-isatty", - "Rev": "56b76bdf51f7708750eac80fa38b952bb9f32639" - }, - { - "ImportPath": "github.com/urfave/cli", - "Comment": "v1.18.0", - "Rev": "1efa31f08b9333f1bd4882d61f9d668a70cd902e" - }, - { - "ImportPath": "golang.org/x/sys/unix", - "Rev": "eb2c74142fd19a79b3f237334c7384d5167b1b46" - }, - { - "ImportPath": "gopkg.in/yaml.v2", - "Rev": "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b" - } - ] -} diff --git a/cli/Godeps/Readme b/cli/Godeps/Readme deleted file mode 100644 index 4cdaa53..0000000 --- a/cli/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/cli/Gopkg.lock b/cli/Gopkg.lock new file mode 100644 index 0000000..c7578df --- /dev/null +++ b/cli/Gopkg.lock @@ -0,0 +1,56 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "github.com/bitly/go-simplejson" + packages = ["."] + revision = "aabad6e819789e569bd6aabf444c935aa9ba1e44" + version = "v0.5.0" + +[[projects]] + name = "github.com/fatih/color" + packages = ["."] + revision = "9aae6aaa22315390f03959adca2c4d395b02fcef" + +[[projects]] + name = "github.com/hashicorp/go-version" + packages = ["."] + revision = "03c5bf6be031b6dd45afec16b1cf94fc8938bc77" + +[[projects]] + name = "github.com/kardianos/osext" + packages = ["."] + revision = "29ae4ffbc9a6fe9fb2bc5029050ce6996ea1d3bc" + +[[projects]] + name = "github.com/mattn/go-colorable" + packages = ["."] + revision = "4af63d73f5bea08b682ad2cd198b1e607afd6be0" + +[[projects]] + name = "github.com/mattn/go-isatty" + packages = ["."] + revision = "56b76bdf51f7708750eac80fa38b952bb9f32639" + +[[projects]] + name = "github.com/urfave/cli" + packages = ["."] + revision = "1efa31f08b9333f1bd4882d61f9d668a70cd902e" + version = "v1.18.0" + +[[projects]] + name = "golang.org/x/sys" + packages = ["unix"] + revision = "eb2c74142fd19a79b3f237334c7384d5167b1b46" + +[[projects]] + name = "gopkg.in/yaml.v2" + packages = ["."] + revision = "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "4cd1f45b0ba850d30ae29ff8d3f8f524952fe397230c87f76af0007b54706cd3" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/cli/Gopkg.toml b/cli/Gopkg.toml new file mode 100644 index 0000000..1d721f3 --- /dev/null +++ b/cli/Gopkg.toml @@ -0,0 +1,42 @@ + +# Gopkg.toml example +# +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" + + +[[constraint]] + name = "github.com/bitly/go-simplejson" + version = "0.5.0" + +[[constraint]] + name = "github.com/fatih/color" + +[[constraint]] + name = "github.com/hashicorp/go-version" + +[[constraint]] + name = "github.com/kardianos/osext" + +[[constraint]] + name = "github.com/urfave/cli" + version = "1.18.0" + +[[constraint]] + name = "gopkg.in/yaml.v2" diff --git a/docker-compose.yml b/docker-compose.yml index c04bedd..ea2cef2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: # Install project dependencies. install: extends: base - command: godep restore -v + command: dep ensure # Foundational service to run commands within the container. base: From b95f96686e7aa7b7898b5b2a3fc020a2f8441d93 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 12:51:11 -0700 Subject: [PATCH 02/13] Remove the GO15VENDOREXPERIMENT variable, also updated to go 1.9 --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index efb2310..79dff23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ os: linux language: go go: - - 1.7 + - 1.9 - tip matrix: @@ -12,9 +12,6 @@ matrix: allow_failures: - go: tip -env: - - GO15VENDOREXPERIMENT="0" - before_install: cd cli script: From a4b34de94df3d8985da99ecee58d70e14409a44d Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 13:32:04 -0700 Subject: [PATCH 03/13] Updated contraints with versions/branches --- cli/Gopkg.lock | 27 +++++++++++++++++---------- cli/Gopkg.toml | 13 ++++++++++++- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/cli/Gopkg.lock b/cli/Gopkg.lock index c7578df..bba6676 100644 --- a/cli/Gopkg.lock +++ b/cli/Gopkg.lock @@ -10,47 +10,54 @@ [[projects]] name = "github.com/fatih/color" packages = ["."] - revision = "9aae6aaa22315390f03959adca2c4d395b02fcef" + revision = "570b54cabe6b8eb0bc2dfce68d964677d63b5260" + version = "v1.5.0" [[projects]] + branch = "master" name = "github.com/hashicorp/go-version" packages = ["."] - revision = "03c5bf6be031b6dd45afec16b1cf94fc8938bc77" + revision = "fc61389e27c71d120f87031ca8c88a3428f372dd" [[projects]] + branch = "master" name = "github.com/kardianos/osext" packages = ["."] - revision = "29ae4ffbc9a6fe9fb2bc5029050ce6996ea1d3bc" + revision = "ae77be60afb1dcacde03767a8c37337fad28ac14" [[projects]] name = "github.com/mattn/go-colorable" packages = ["."] - revision = "4af63d73f5bea08b682ad2cd198b1e607afd6be0" + revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" + version = "v0.0.9" [[projects]] name = "github.com/mattn/go-isatty" packages = ["."] - revision = "56b76bdf51f7708750eac80fa38b952bb9f32639" + revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" + version = "v0.0.3" [[projects]] name = "github.com/urfave/cli" packages = ["."] - revision = "1efa31f08b9333f1bd4882d61f9d668a70cd902e" - version = "v1.18.0" + revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1" + version = "v1.20.0" [[projects]] + branch = "master" name = "golang.org/x/sys" packages = ["unix"] - revision = "eb2c74142fd19a79b3f237334c7384d5167b1b46" + revision = "8dbc5d05d6edcc104950cc299a1ce6641235bc86" [[projects]] + branch = "v2" name = "gopkg.in/yaml.v2" packages = ["."] - revision = "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b" + revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "4cd1f45b0ba850d30ae29ff8d3f8f524952fe397230c87f76af0007b54706cd3" + inputs-digest = "678adfbe5598e3c66325e41d24ad40c157b194fb0e6b8947da376121810cd414" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cli/Gopkg.toml b/cli/Gopkg.toml index 1d721f3..ddca016 100644 --- a/cli/Gopkg.toml +++ b/cli/Gopkg.toml @@ -27,16 +27,27 @@ [[constraint]] name = "github.com/fatih/color" + version = "1.5.0" + +[[constraint]] + name = "github.com/mattn/go-isatty" + version = "0.0.3" [[constraint]] name = "github.com/hashicorp/go-version" + branch = "master" + revision = "fc61389" [[constraint]] name = "github.com/kardianos/osext" + branch = "master" + revision = "ae77be6" [[constraint]] name = "github.com/urfave/cli" - version = "1.18.0" + version = "1.20.0" [[constraint]] name = "gopkg.in/yaml.v2" + branch = "v2" + revision = "eb3733d" From bd7437be3e67c653a6c6fefc9a1282c4b77a6ec8 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 13:35:55 -0700 Subject: [PATCH 04/13] update with explicit/full revisions for projects that don't have versions/tags --- cli/Gopkg.lock | 5 +---- cli/Gopkg.toml | 9 +++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cli/Gopkg.lock b/cli/Gopkg.lock index bba6676..84cd8b2 100644 --- a/cli/Gopkg.lock +++ b/cli/Gopkg.lock @@ -14,13 +14,11 @@ version = "v1.5.0" [[projects]] - branch = "master" name = "github.com/hashicorp/go-version" packages = ["."] revision = "fc61389e27c71d120f87031ca8c88a3428f372dd" [[projects]] - branch = "master" name = "github.com/kardianos/osext" packages = ["."] revision = "ae77be60afb1dcacde03767a8c37337fad28ac14" @@ -50,7 +48,6 @@ revision = "8dbc5d05d6edcc104950cc299a1ce6641235bc86" [[projects]] - branch = "v2" name = "gopkg.in/yaml.v2" packages = ["."] revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" @@ -58,6 +55,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "678adfbe5598e3c66325e41d24ad40c157b194fb0e6b8947da376121810cd414" + inputs-digest = "77a6e334601c4bcd44e4c2f213a8f6d48e0e918760c916a4c21024fdec091e3a" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cli/Gopkg.toml b/cli/Gopkg.toml index ddca016..9381d60 100644 --- a/cli/Gopkg.toml +++ b/cli/Gopkg.toml @@ -35,13 +35,11 @@ [[constraint]] name = "github.com/hashicorp/go-version" - branch = "master" - revision = "fc61389" + revision = "fc61389e27c71d120f87031ca8c88a3428f372dd" [[constraint]] name = "github.com/kardianos/osext" - branch = "master" - revision = "ae77be6" + revision = "ae77be60afb1dcacde03767a8c37337fad28ac14" [[constraint]] name = "github.com/urfave/cli" @@ -49,5 +47,4 @@ [[constraint]] name = "gopkg.in/yaml.v2" - branch = "v2" - revision = "eb3733d" + revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" From 4436d1ef20dd638a58f87b62adc7401a5886e888 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 14:24:18 -0700 Subject: [PATCH 05/13] Initial support for goreleaser --- README.md | 3 ++ cli/.goreleaser.yml | 73 +++++++++++++++++++++++++++++++++++++++++++++ cli/main.go | 4 +-- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 cli/.goreleaser.yml diff --git a/README.md b/README.md index 4d012bd..b903d7d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ Install go from homebrew using the flag to include common cross-compiler targets ```bash brew install go --with-cc-common +brew install dep +brew tap goreleaser/tap +brew install goreleaser/tap/goreleaser ``` Setup `$GOPATH` and `$PATH` in your favorite shell (`~/.bashrc` or `~/.zshrc`) diff --git a/cli/.goreleaser.yml b/cli/.goreleaser.yml new file mode 100644 index 0000000..6326038 --- /dev/null +++ b/cli/.goreleaser.yml @@ -0,0 +1,73 @@ +# One release file to rule them all + +# Platforms/architectures to target +builds: + - binary: rig + goos: + - windows + - darwin + - linux + goarch: + - amd64 + +# Generating the archives +archive: + name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + format_overrides: + - goos: windows + format: zip + replacements: + darwin: macOS + +# Publishing releases to GitHub +release: + github: + owner: phase2 + name: rig + +# Publishing Homebrew Formula to the Tap repo +brew: + github: + owner: phase2 + name: homebrew-outrigger + + # Git author used to commit to the repository. + # Defaults are shown. + commit_author: + name: Outrigger + email: outrigger@phase2technology.com + + folder: Formula + homepage: "https://outrigger.sh/" + description: "Containerized development environment for projects. See https://docs.outrigger.sh for documentation." + dependencies: + - docker + - docker-machine + - docker-compose + - docker-machine-nfs + - unison + - eugenmayer/dockersync/unox + + # So you can `brew test` your formula. + # Default is empty. + test: | + system "#{bin}/rig", "--version" + + # Custom install script for brew. + # Default is 'bin.install "program"'. + install: | + bin.install "rig" + +# Build linux packages +fpm: + vendor: Phase2 + homepage: https://outrigger.sh/ + maintainer: Outrigger + description: Containerized development environment for projects. See https://docs.outrigger.sh for documentation. + license: MIT + formats: + - deb + - rpm + dependencies: + - docker-ce diff --git a/cli/main.go b/cli/main.go index f5ccd5d..2512a40 100644 --- a/cli/main.go +++ b/cli/main.go @@ -8,14 +8,14 @@ import ( "github.com/urfave/cli" ) -const VERSION = "1.3.2" +var version = "master" // It all starts here func main() { app := cli.NewApp() app.Name = "rig" app.Usage = "Containerized platform environment for projects" - app.Version = VERSION + app.Version = version app.EnableBashCompletion = true app.Flags = []cli.Flag{ From d90ae65e2917c73fe6620f7e7a262e2c9955d482 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 15:09:12 -0700 Subject: [PATCH 06/13] Trying to contain all goreleaser dependencies in a Docker image --- Dockerfile.goreleaser | 15 +++++++++++++++ docker-compose.yml | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 Dockerfile.goreleaser diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser new file mode 100644 index 0000000..9f103b1 --- /dev/null +++ b/Dockerfile.goreleaser @@ -0,0 +1,15 @@ +FROM golang:1.9-alpine + +RUN apk add --no-cache \ + ca-certificates \ + git \ + gcc \ + libffi-dev \ + make \ + musl-dev \ + ruby \ + ruby-dev \ + && go get -u github.com/goreleaser/goreleaser + +RUN gem install --no-rdoc --no-ri fpm + diff --git a/docker-compose.yml b/docker-compose.yml index ea2cef2..69c70b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,19 @@ version: '2.1' services: + # Install project dependencies. + goreleaser: + build: + context: . + dockerfile: Dockerfile.goreleaser + network_mode: bridge + environment: + GOPATH: "/go" + volumes: + - .:/go/src/github.com/phase2/rig + working_dir: /go/src/github.com/phase2/rig/cli + entrypoint: goreleaser + # Build rig, dropping off a working binary in build/darwin/rig. compile: extends: base From d93e07634cc3c3297f9079b3e5935c54c8e46d85 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 15:24:27 -0700 Subject: [PATCH 07/13] added GITHUB_TOKEN that needs to be set in the shell environment --- docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 69c70b2..435c98c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,8 @@ services: dockerfile: Dockerfile.goreleaser network_mode: bridge environment: - GOPATH: "/go" + - GOPATH=/go + - GITHUB_TOKEN volumes: - .:/go/src/github.com/phase2/rig working_dir: /go/src/github.com/phase2/rig/cli From 9c006a4282286cc9f78a5d74c0d120b111fb4afc Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 15:28:50 -0700 Subject: [PATCH 08/13] added tar for building packages --- Dockerfile.goreleaser | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser index 9f103b1..a2d8a0e 100644 --- a/Dockerfile.goreleaser +++ b/Dockerfile.goreleaser @@ -9,6 +9,7 @@ RUN apk add --no-cache \ musl-dev \ ruby \ ruby-dev \ + tar \ && go get -u github.com/goreleaser/goreleaser RUN gem install --no-rdoc --no-ri fpm From 7f3a1ff442921ab96a365b4d9f6c8913f38a734d Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Sat, 21 Oct 2017 15:35:29 -0700 Subject: [PATCH 09/13] Added rpm to the goreleaser dockerfile to try to satisfy rpmbuid --- Dockerfile.goreleaser | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser index a2d8a0e..97efccc 100644 --- a/Dockerfile.goreleaser +++ b/Dockerfile.goreleaser @@ -7,6 +7,7 @@ RUN apk add --no-cache \ libffi-dev \ make \ musl-dev \ + rpm \ ruby \ ruby-dev \ tar \ From 1a5811630c8fe8096f2f5ca43bd680099a98aace Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Wed, 25 Oct 2017 09:43:55 -0700 Subject: [PATCH 10/13] added a dep update to the docker compose, also pinned to branches and let dep resolve the proper revision (and put it in the .lock) --- cli/Gopkg.lock | 7 +++++-- cli/Gopkg.toml | 6 +++--- docker-compose.yml | 8 ++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cli/Gopkg.lock b/cli/Gopkg.lock index 84cd8b2..6dda64e 100644 --- a/cli/Gopkg.lock +++ b/cli/Gopkg.lock @@ -14,11 +14,13 @@ version = "v1.5.0" [[projects]] + branch = "master" name = "github.com/hashicorp/go-version" packages = ["."] revision = "fc61389e27c71d120f87031ca8c88a3428f372dd" [[projects]] + branch = "master" name = "github.com/kardianos/osext" packages = ["."] revision = "ae77be60afb1dcacde03767a8c37337fad28ac14" @@ -45,9 +47,10 @@ branch = "master" name = "golang.org/x/sys" packages = ["unix"] - revision = "8dbc5d05d6edcc104950cc299a1ce6641235bc86" + revision = "92ac112afc6efd90284acda2b046fc0e351228f6" [[projects]] + branch = "v2" name = "gopkg.in/yaml.v2" packages = ["."] revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" @@ -55,6 +58,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "77a6e334601c4bcd44e4c2f213a8f6d48e0e918760c916a4c21024fdec091e3a" + inputs-digest = "9866632c6655f2b13c5a6567e87d824685c882e40fc4a1a7513bdf9d4710045a" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cli/Gopkg.toml b/cli/Gopkg.toml index 9381d60..58d6728 100644 --- a/cli/Gopkg.toml +++ b/cli/Gopkg.toml @@ -35,11 +35,11 @@ [[constraint]] name = "github.com/hashicorp/go-version" - revision = "fc61389e27c71d120f87031ca8c88a3428f372dd" + branch = "master" [[constraint]] name = "github.com/kardianos/osext" - revision = "ae77be60afb1dcacde03767a8c37337fad28ac14" + branch = "master" [[constraint]] name = "github.com/urfave/cli" @@ -47,4 +47,4 @@ [[constraint]] name = "gopkg.in/yaml.v2" - revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" + branch = "v2" diff --git a/docker-compose.yml b/docker-compose.yml index 435c98c..9225a7d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,14 @@ services: extends: base command: dep ensure + # Update project dependencies. + # Will update all if no arguments are provided. To update a particular package use: + # docker-compose run --rm update [PACKAGENAME] + update: + extends: base + entrypoint: [ "dep", "ensure", "-update" ] + command: "" + # Foundational service to run commands within the container. base: build: . From 341f3a881186369ce980b11383d06bbb4d3404e6 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Wed, 25 Oct 2017 10:19:41 -0700 Subject: [PATCH 11/13] removed old build scripts and update documentation around new build & process --- Dockerfile | 11 +++++- Dockerfile.goreleaser | 17 -------- README.md | 53 +++++++++++++++---------- brew-publish.sh | 92 ------------------------------------------- build.sh | 32 --------------- docker-compose.yml | 15 +++---- 6 files changed, 47 insertions(+), 173 deletions(-) delete mode 100644 Dockerfile.goreleaser delete mode 100755 brew-publish.sh delete mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile index fadd77b..b8bff7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,13 @@ RUN apk add --no-cache \ ca-certificates \ git \ gcc \ + libffi-dev \ + make \ musl-dev \ - && go get -u github.com/golang/dep/... \ - && go get -u github.com/mitchellh/gox + rpm \ + ruby \ + ruby-dev \ + tar \ + && go get -u github.com/goreleaser/goreleaser + +RUN gem install --no-rdoc --no-ri fpm \ No newline at end of file diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser deleted file mode 100644 index 97efccc..0000000 --- a/Dockerfile.goreleaser +++ /dev/null @@ -1,17 +0,0 @@ -FROM golang:1.9-alpine - -RUN apk add --no-cache \ - ca-certificates \ - git \ - gcc \ - libffi-dev \ - make \ - musl-dev \ - rpm \ - ruby \ - ruby-dev \ - tar \ - && go get -u github.com/goreleaser/goreleaser - -RUN gem install --no-rdoc --no-ri fpm - diff --git a/README.md b/README.md index b903d7d..ce0582f 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,6 @@ Checkout the code into your `$GOPATH` in `$GOPATH/src/github.com/phase2/rig` Get all the dependencies ```bash -# Go Dependency Manager -go get -u github.com/golang/dep/... - -# Go Cross Platform Build Tool -go get github.com/mitchellh/gox - # Install the project dependencies into $GOPATH cd $GOPATH/src/github.com/phase2/rig/cli dep ensure @@ -66,11 +60,11 @@ For development, sometimes you will just want to build for your target platform do that, simply run the following command. ```bash -gox -osarch="Darwin/amd64" -output="build/{{.OS}}/rig" +GOARCH=amd64 GOOS=darwin go build -o ../build/darwin/rig ``` -This command targets an OS/Architecture (Darwin/Mac and 64bit) and puts the resultant file in the `bin/` -directory for the appropriate OS with the name `rig`. +This command targets an OS/Architecture (Darwin/Mac and 64bit) and puts the resultant file in the `build/darwin/` +with the name `rig`. Developing Rig with Docker [Experimental] ----------------------------------------- @@ -80,21 +74,38 @@ local golang environment. Using docker-compose, run the following commands: ```bash docker-compose run --rm install -docker-compose run --rm build +docker-compose run --rm compile ``` This will produce a working OSX binary at `build/darwin/rig`. -Deploy to Homebrew ------------------- +If you change a dependency in `Gopkg.toml` you can update an individual package dependency with: + +```bash +docker-compose run --rm update [package] +``` + +If you want to update all packages use: + +```bash +docker-compose run --rm update +``` + + +Release +------- + +We use [GoReleaser](https://goreleaser.com) to handle nearly all of our release concerns. GoReleaser will handle -We now manage the Mac / OSX version of the binaries via `brew`. To publish a new build to `brew` you must -perform the following operations. +* Building for all target platforms +* Create a GitHub release on our project page based on tag +* Create archive file for each target platform and attach it to the GitHub release +* Update the Homebrew formula and publish it +* Create .deb and .rpm packages for linux installations - - Change the code :) - - When changing the code make sure to update the VERSION variable in main.go - - Build all the code via `build.sh` - - Make sure you have https://github.com/phase2/homebrew-outrigger cloned into ~/Projects/homebrew-outrigger - - Prepare a new `brew` version via `brew-publish.sh` - - Part of this will write a new formula into homebrew-outrigger - - Commit & push the updated formula to publish the new version +To create a new release of rig: +* Get all the code committed to `master` +* Tag master with the new version number +* Run `docker-compose run --rm goreleaser` +* ... +* Profit! \ No newline at end of file diff --git a/brew-publish.sh b/brew-publish.sh deleted file mode 100755 index c758613..0000000 --- a/brew-publish.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env bash -# -# Publish a release of Rig. -# -# This entails -# 1) Creating an archive of the correct files -# 2) Getting a checksum of the archive -# 3) Publishing the archive to S3 -# 4) Generating a Homebrew formula for the release -# -# Once completed, the only thing that remains is committing/pushing the -# changes in the homebrew-outrigger repo. -# - -BASE_DIR=${PWD} -BIN_DIR="${BASE_DIR}/build/darwin" -VERSION=`${BIN_DIR}/rig --version | awk '{print $3}'` - -FILENAME="rig-${VERSION}.tar.gz" -DIST_DIR="${BASE_DIR}/dist" -DIST="${DIST_DIR}/${FILENAME}" -S3_BUCKET="phase2.outrigger" - -HOMEBREW_DIR="${HOME}/Projects/homebrew-outrigger" -HOMEBREW_FORMULA="${HOMEBREW_DIR}/Formula/rig.rb" - -# Make sure the Homebrew Tap is present -if [ ! -f "$HOMEBREW_FORMULA" ]; then - echo "[ERROR] Could not find Rig Homebrew formula in: ${HOMEBREW_FORMULA}" - exit 1 -fi - -# Package rig and any additional scripts -echo "[INFO] Packaging rig ${VERSION} for publishing" -mkdir -p $DIST_DIR -cp ${BASE_DIR}/scripts/docker-machine-watch-rsync.sh $BIN_DIR/. -#cp ${BASE_DIR}/scripts/bash_autocomplete $BIN_DIR/. -#cp ${BASE_DIR}/scripts/zsh_autocomplete $BIN_DIR/. -pushd $BIN_DIR -#tar czf $DIST rig docker-machine-watch-rsync.sh bash_autocomplete zsh_autocomplete -tar czf $DIST rig docker-machine-watch-rsync.sh -popd - -# Generate the checksum -SHA=`shasum -a 256 $DIST | awk '{print $1}'` -echo "[INFO] Rig ${VERSION} checksum is ${SHA}" - -# Move the file to S3 for distribution -echo "[INFO] Deploying ${VERSION}" -aws s3 ls $S3_BUCKET | grep "${FILENAME}" && { - read -p "[WARN] Version ${VERSION} is already published to S3. Overwrite? " prompt - if [[ ! $prompt =~ [yY](es)* ]]; then - echo "Publish cancelled." - exit 1 - fi -} - -echo "[INFO] Writing to AWS/S3" -aws s3 cp $DIST s3://${S3_BUCKET}/${FILENAME} --acl public-read - -# Write out the Homebrew formula -echo "[INFO] Writing Homebrew formula" -cat < $HOMEBREW_FORMULA -class Rig < Formula - desc "Containerized platform environment for projects. See https://outrigger.sh for documentation. " - homepage "https://outrigger.sh" - url "https://s3.amazonaws.com/${S3_BUCKET}/${FILENAME}" - version "${VERSION}" - sha256 "${SHA}" - - depends_on "docker" - depends_on "docker-machine" - depends_on "docker-compose" - depends_on "docker-machine-nfs" - depends_on "unison" - depends_on "eugenmayer/dockersync/unox" - - def install - bin.install "rig" - bin.install "docker-machine-watch-rsync.sh" - - #bash_completion.install "bash_autocomplete" => "rig" - #zsh_completion.install "zsh_autocomplete" => "_rig" - end - - test do - system "#{bin}/rig", "--version" - end -end -EOF - -echo "[NOTICE] Remember that you need to commit the formula change to homebrew-outrigger" diff --git a/build.sh b/build.sh deleted file mode 100755 index 0e3b7ec..0000000 --- a/build.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# To use this you will need to: go get github.com/mitchellh/gox - -go get -u github.com/golang/dep/... -go get -u github.com/mitchellh/gox - -pushd cli - -dep ensure - -# Build for platforms -gox -osarch="Darwin/amd64" -output="../build/darwin/rig" -gox -osarch="Linux/amd64" -output="../build/linux/rig" -gox -osarch="Windows/amd64" -output="../build/windows/rig" - -popd - -# Get version -VERSION=`build/darwin/rig --version 2>&1 | grep 'rig version' | awk '{print $3}'` - -# Create archives for publishing to GitHub -cp scripts/docker-machine-watch-rsync.sh build/darwin/. -pushd build/darwin -tar czf ../rig-${VERSION}-darwin-amd64.tar.gz rig docker-machine-watch-rsync.sh -popd -pushd build/linux -tar czf ../rig-${VERSION}-linux-amd64.tar.gz rig -popd -pushd build/windows -zip ../rig-${VERSION}-windows-amd64.zip rig.exe -popd \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 9225a7d..01abf85 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,22 +4,19 @@ services: # Install project dependencies. goreleaser: - build: - context: . - dockerfile: Dockerfile.goreleaser - network_mode: bridge + extends: base environment: - GOPATH=/go - GITHUB_TOKEN - volumes: - - .:/go/src/github.com/phase2/rig - working_dir: /go/src/github.com/phase2/rig/cli - entrypoint: goreleaser + entrypoint: [ "goreleaser" ] # Build rig, dropping off a working binary in build/darwin/rig. compile: extends: base - command: gox -osarch="Darwin/amd64" -output="../build/{{.OS}}/rig" + command: go build -o ../build/darwin/rig + environment: + - GOOS=darwin + - GOARCH=amd64 # Install project dependencies. install: From 24865fda7d8700115fc5ed596438f284e69de4db Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Wed, 25 Oct 2017 10:40:49 -0700 Subject: [PATCH 12/13] added dep back into the mix --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index b8bff7c..720954c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN apk add --no-cache \ ruby \ ruby-dev \ tar \ + && go get -u github.com/golang/dep/... \ && go get -u github.com/goreleaser/goreleaser RUN gem install --no-rdoc --no-ri fpm \ No newline at end of file From 86e165d8147dc02168393c3142b71331f55978c9 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Wed, 25 Oct 2017 10:58:09 -0700 Subject: [PATCH 13/13] Cleaned up the README a bit --- README.md | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index ce0582f..8a6d04b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ See the [documentation for more details](http://docs.outrigger.sh). Use this readme when you want to develop the Outrigger CLI. Setup ------ +------ Install go from homebrew using the flag to include common cross-compiler targets (namely Darwin, Linux, and Windows) @@ -35,39 +35,20 @@ cd $GOPATH/src/github.com/phase2/rig/cli dep ensure ``` -Code ----- +Developing Locally +------------------- -We make use of a few key libraries to do all the fancy stuff that the `rig` CLI will do. - - * https://github.com/urfave/cli - * The entire CLI framework from helps text to flags. This was an easy cli to build b/c of this library - * https://github.com/fatih/color - * All the fancy terminal color output - * https://github.com/bitly/go-simplejson - * The JSON parse and access library used primarily with the output of `docker-machine inspect` - * https://gopkg.in/yaml.v2 - * The YAML library for parsing/reading YAML files - -Build ------ - -If you want to build `rig` for all platforms, simply execute the `build.sh` script from the root -directory. This script will build the binary for Darwin, Linux and Windows and put it in the appropriate - `dist/[PLATFORM]` directory for each operating system. - -For development, sometimes you will just want to build for your target platform because it is faster. TO -do that, simply run the following command. +If you want to build `rig` locally for your target platform, simply run the following command: ```bash GOARCH=amd64 GOOS=darwin go build -o ../build/darwin/rig ``` This command targets an OS/Architecture (Darwin/Mac and 64bit) and puts the resultant file in the `build/darwin/` -with the name `rig`. +with the name `rig`. Change `GOARCH` and `GOOS` if you need to target a different platform -Developing Rig with Docker [Experimental] ------------------------------------------ +Developing with Docker +----------------------- You can use the Docker integration within this repository to facilitate development in lieu of setting up a local golang environment. Using docker-compose, run the following commands: @@ -108,4 +89,19 @@ To create a new release of rig: * Tag master with the new version number * Run `docker-compose run --rm goreleaser` * ... -* Profit! \ No newline at end of file +* Profit! + + +Dependencies +------------- + +We make use of a few key libraries to do all the fancy stuff that the `rig` CLI will do. + + * https://github.com/urfave/cli + * The entire CLI framework from helps text to flags. This was an easy cli to build b/c of this library + * https://github.com/fatih/color + * All the fancy terminal color output + * https://github.com/bitly/go-simplejson + * The JSON parse and access library used primarily with the output of `docker-machine inspect` + * https://gopkg.in/yaml.v2 + * The YAML library for parsing/reading YAML files