Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ os: linux

language: go
go:
- 1.7
- 1.9
- tip

matrix:
fast_finish: true
allow_failures:
- go: tip

env:
- GO15VENDOREXPERIMENT="0"

before_install: cd cli

script:
Expand Down
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
FROM golang:1.7-alpine
FROM golang:1.9-alpine

RUN apk add --no-cache \
ca-certificates \
git \
gcc \
libffi-dev \
make \
musl-dev \
&& go get github.com/tools/godep \
&& go get github.com/mitchellh/gox
rpm \
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
104 changes: 57 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ 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)

```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`)
Expand All @@ -27,71 +30,78 @@ Checkout the code into your `$GOPATH` in `$GOPATH/src/github.com/phase2/rig`
Get all the dependencies

```bash
# Go Dependency Manager
go get github.com/tools/godep

# 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
----
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
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`. 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:

```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:

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.
```bash
docker-compose run --rm update
```


Release
-------

We use [GoReleaser](https://goreleaser.com) to handle nearly all of our release concerns. GoReleaser will handle

- 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
* 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

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!


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
92 changes: 0 additions & 92 deletions brew-publish.sh

This file was deleted.

32 changes: 0 additions & 32 deletions build.sh

This file was deleted.

73 changes: 73 additions & 0 deletions cli/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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 <outrigger@phase2technology.com>
description: Containerized development environment for projects. See https://docs.outrigger.sh for documentation.
license: MIT
formats:
- deb
- rpm
dependencies:
- docker-ce
Loading