Skip to content

Commit

Permalink
Support RCs via goreleaser (#129)
Browse files Browse the repository at this point in the history
* added vendor backup folder

* added a separate config just for publishing release candidates

* addressing updated linter warning

* Updated readme for how to prep a release candidate
  • Loading branch information
febbraro authored Dec 14, 2017
1 parent 86897dd commit 1eda7aa
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dist
build
vendor
vendor.orig
.idea
.outrigger.yml
.DS_Store
Expand Down
45 changes: 45 additions & 0 deletions .goreleaser.rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# One release file to rule them all
project_name: outrigger-cli

# Platforms/architectures to target
builds:
- binary: rig
main: ./cmd/main.go
env:
- CGO_ENABLED=0
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
prerelease: true

# 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
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,31 @@ We make use of a few key libraries to do all the fancy stuff that the `rig` CLI
* https://github.com/martinlindhe/notify
* Cross-platform desktop notifications

## Release Intructions
## Release Instructions

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

* 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
* Creating a GitHub release on our project page based on tag
* Creating archive files for each target platform and attach it to the GitHub release
* Creating .deb and .rpm packages for linux installations and attaching those to the GitHub release
* Updating the Homebrew formula and publish it

### To create a new release of rig:

To create a new release of rig:
* Get all the code committed to `master`
* Tag master with the new version number
* Tag master with the new version number `git tag 2.1.0 && git push --tags`
* Run `docker-compose run --rm goreleaser`
* ...
* Profit!

### To create a new release candidate (RC) of rig:

If we want to roll out an RC to GitHub for folks to test, we simply need to run with a different GoReleaser
configuration that does not publish to homebrew, just to a GitHub release that is marked preproduction.

* Get all the code committed to `develop`
* Tag develop with the new version number `git tag 2.1.0-rc1 && git push --tags`
* Run `docker-compose run --rm goreleaser --config .goreleaser.rc.yml`
* ...
* Profit!
7 changes: 7 additions & 0 deletions commands/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ func (cmd *Doctor) Commands() []cli.Command {
func (cmd *Doctor) Run(c *cli.Context) error {
// 0. Ensure all of rig's dependencies are available in the PATH.
cmd.out.Spin("Checking Docker installation...")
/* #nosec */
if err := exec.Command("docker", "-h").Start(); err == nil {
cmd.out.Info("Docker is installed.")
} else {
cmd.out.Error("Docker (docker) is not installed.")
}
if !util.SupportsNativeDocker() {
cmd.out.Spin("Checking Docker Machine installation...")
/* #nosec */
if err := exec.Command("docker-machine", "-h").Start(); err == nil {
cmd.out.Info("Docker Machine is installed.")
} else {
cmd.out.Error("Docker Machine (docker-machine) is not installed.")
}
}
cmd.out.Spin("Checking Docker Compose installation...")
/* #nosec */
if err := exec.Command("docker-compose", "-h").Start(); err == nil {
cmd.out.Info("Docker Compose is installed.")
} else {
Expand All @@ -67,6 +70,7 @@ func (cmd *Doctor) Run(c *cli.Context) error {
} else {
cmd.out.Info("Docker Machine (%s) name matches your environment configuration.", cmd.machine.Name)
}
/* #nosec */
if output, err := exec.Command("docker-machine", "url", cmd.machine.Name).Output(); err == nil {
hostURL := strings.TrimSpace(string(output))
if hostURL != os.Getenv("DOCKER_HOST") {
Expand Down Expand Up @@ -148,6 +152,7 @@ func (cmd *Doctor) Run(c *cli.Context) error {
// 4. Ensure that docker-machine-nfs script is available for our NFS mounts (Mac ONLY)
if util.IsMac() {
cmd.out.Spin("Checking NFS configuration...")
/* #nosec */
if err := exec.Command("which", "docker-machine-nfs").Run(); err != nil {
cmd.out.Error("Docker Machine NFS is not installed.")
} else {
Expand All @@ -158,6 +163,7 @@ func (cmd *Doctor) Run(c *cli.Context) error {
// 5. Check for storage on VM volume
if !util.SupportsNativeDocker() {
cmd.out.Spin("Checking Data (/data) volume capacity...")
/* #nosec */
output, err := exec.Command("docker-machine", "ssh", cmd.machine.Name, "df -h 2> /dev/null | grep /dev/sda1 | head -1 | awk '{print $5}' | sed 's/%//'").Output()
if err == nil {
dataUsage := strings.TrimSpace(string(output))
Expand All @@ -180,6 +186,7 @@ func (cmd *Doctor) Run(c *cli.Context) error {
// 6. Check for storage on /Users
if !util.SupportsNativeDocker() {
cmd.out.Spin("Checking Root (/Users) drive capacity...")
/* #nosec */
output, err := exec.Command("docker-machine", "ssh", cmd.machine.Name, "df -h 2> /dev/null | grep /Users | head -1 | awk '{print $5}' | sed 's/%//'").Output()
if err == nil {
userUsage := strings.TrimSpace(string(output))
Expand Down
2 changes: 2 additions & 0 deletions commands/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ func (cmd *Project) Run(c *cli.Context) error {
// @see https://github.com/medhoover/gom/blob/staging/config/command.go
func (cmd *Project) GetCommand(val string) *exec.Cmd {
if util.IsWindows() {
/* #nosec */
return exec.Command("cmd", "/c", val)
}

/* #nosec */
return exec.Command("sh", "-c", val)
}

Expand Down
2 changes: 1 addition & 1 deletion commands/project_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (cmd *ProjectCreate) RunGenerator(ctx *cli.Context, machine Machine, image
}

args = append(args, ctx.Args()...)

/* #nosec */
shellCmd := exec.Command("docker", args...)
if exitCode := util.PassthruCommand(shellCmd); exitCode != 0 {
return cmd.Failure(fmt.Sprintf("Failure running generator %s %s", image, strings.Join(ctx.Args(), " ")), "COMMAND-ERROR", exitCode)
Expand Down
1 change: 1 addition & 0 deletions commands/project_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (cmd *ProjectSync) StartUnisonSync(ctx *cli.Context, volumeName string, con
}
}
cmd.out.Verbose("Unison Args: %s", strings.Join(unisonArgs[:], " "))
/* #nosec */
command := exec.Command("unison", unisonArgs...)
command.Dir = workingDir
cmd.out.Verbose("Sync execution - Working Directory: %s", workingDir)
Expand Down
1 change: 1 addition & 0 deletions commands/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (cmd *Prune) Commands() []cli.Command {
// Run executes the `rig prune` command
func (cmd *Prune) Run(c *cli.Context) error {
cmd.out.Spin("Cleaning up unused Docker resources...")
/* #nosec */
if exitCode := util.PassthruCommand(exec.Command("docker", "system", "prune", "--all", "--volumes")); exitCode != 0 {
return cmd.Failure("Failure pruning Docker resources.", "COMMAND-ERROR", 13)
}
Expand Down
2 changes: 1 addition & 1 deletion util/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TouchFile(pathToFile string, workingDir string) error {
}

// If the file already exists there will be no error.
f, err := os.OpenFile(absoluteFilePath, os.O_RDONLY|os.O_CREATE, 0666)
f, err := os.OpenFile(absoluteFilePath, os.O_RDONLY|os.O_CREATE, 0600)
if err != nil {
return fmt.Errorf("Could not touch file: %s: %s", absoluteFilePath, err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions util/shell_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func ForceStreamCommand(path string, arg ...string) error {

// Command creates a new Executor instance from the execution arguments.
func Command(path string, arg ...string) Executor {
/* #nosec */
return Executor{exec.Command(path, arg...)}
}

Expand Down
5 changes: 4 additions & 1 deletion util/user_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ func AskYesNo(question string) bool {
fmt.Printf("%s? [y/N]: ", question)

var response string
fmt.Scanln(&response)
var _, err = fmt.Scanln(&response)
if err != nil {
return false
}

yesResponses := []string{"y", "Y", "yes", "Yes", "YES"}
for _, elem := range yesResponses {
Expand Down

0 comments on commit 1eda7aa

Please sign in to comment.