From 1eda7aa164bca5553733c36024033388915af380 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Thu, 14 Dec 2017 10:05:58 -0800 Subject: [PATCH] Support RCs via goreleaser (#129) * 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 --- .gitignore | 1 + .goreleaser.rc.yml | 45 ++++++++++++++++++++++++++++++++++++++ README.md | 26 ++++++++++++++++------ commands/doctor.go | 7 ++++++ commands/project.go | 2 ++ commands/project_create.go | 2 +- commands/project_sync.go | 1 + commands/prune.go | 1 + util/filesystem.go | 2 +- util/shell_exec.go | 1 + util/user_input.go | 5 ++++- 11 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 .goreleaser.rc.yml diff --git a/.gitignore b/.gitignore index 1c561f0..53090d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ dist build vendor +vendor.orig .idea .outrigger.yml .DS_Store diff --git a/.goreleaser.rc.yml b/.goreleaser.rc.yml new file mode 100644 index 0000000..0430b6c --- /dev/null +++ b/.goreleaser.rc.yml @@ -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 + description: Containerized development environment for projects. See https://docs.outrigger.sh for documentation. + license: MIT + formats: + - deb + - rpm + dependencies: + - docker-ce diff --git a/README.md b/README.md index 2a979da..7afc958 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/commands/doctor.go b/commands/doctor.go index 7d3396f..fba4675 100644 --- a/commands/doctor.go +++ b/commands/doctor.go @@ -34,6 +34,7 @@ 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 { @@ -41,6 +42,7 @@ func (cmd *Doctor) Run(c *cli.Context) error { } 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 { @@ -48,6 +50,7 @@ func (cmd *Doctor) Run(c *cli.Context) error { } } 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 { @@ -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") { @@ -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 { @@ -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)) @@ -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)) diff --git a/commands/project.go b/commands/project.go index fe32a83..56021ee 100644 --- a/commands/project.go +++ b/commands/project.go @@ -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) } diff --git a/commands/project_create.go b/commands/project_create.go index dcfec3f..626e195 100644 --- a/commands/project_create.go +++ b/commands/project_create.go @@ -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) diff --git a/commands/project_sync.go b/commands/project_sync.go index 983ceb9..8d01cbf 100644 --- a/commands/project_sync.go +++ b/commands/project_sync.go @@ -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) diff --git a/commands/prune.go b/commands/prune.go index 04f8ee7..9cc5b3e 100644 --- a/commands/prune.go +++ b/commands/prune.go @@ -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) } diff --git a/util/filesystem.go b/util/filesystem.go index 607962f..28c16af 100644 --- a/util/filesystem.go +++ b/util/filesystem.go @@ -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()) } diff --git a/util/shell_exec.go b/util/shell_exec.go index e704de2..45bf785 100644 --- a/util/shell_exec.go +++ b/util/shell_exec.go @@ -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...)} } diff --git a/util/user_input.go b/util/user_input.go index f58ad3a..f8bf69d 100644 --- a/util/user_input.go +++ b/util/user_input.go @@ -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 {