Skip to content

Commit

Permalink
separate install binary
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperkha committed Nov 7, 2024
1 parent 7e86dc2 commit e6707ff
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
binary_name: cenv
project_path: .
multi_binaries: true
binary_name: cenv cenv-install
project_path: . ./installer
10 changes: 3 additions & 7 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ func showHelp() {
fmt.Println(" update Generate schema based on .env")
fmt.Println(" fix Automatically fix issues with the .env")
fmt.Println(" Tries to reuse previous env values")
fmt.Println()
fmt.Println(" help Show this help message")
fmt.Println(" install Get latest release of cenv")
fmt.Println()
fmt.Println("Flags:")
fmt.Println(" --env <path> Path to env file, default is current dir")
fmt.Println(" --schema <path> Path to schema file, default is current dir")
fmt.Println()
fmt.Println("Install latest version:")
fmt.Println(" cenv-install")
fmt.Println()
}

func errorExitS(message string) {
Expand Down Expand Up @@ -72,11 +73,6 @@ func Run() {
return
}

if command == "install" {
errorExitS("not implemented, install manually: https://github.com/echo-webkom/cenv")
return
}

if command == "fix" {
if err := cenv.Fix(envPath, schemaPath); err != nil {
errorExit(err)
Expand Down
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ echo "[LOG] Downloaded and unpacked to $TARGET_DIR/"

echo "[LOG] Copying to usr/local/bin"
sudo cp $TARGET_DIR/cenv /usr/local/bin
sudo cp $TARGET_DIR/cenv-install /usr/local/bin

echo "[LOG] Cleanup"
rm cenv.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions installer/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/echo-webkom/cenv/installer

go 1.23.2
18 changes: 18 additions & 0 deletions installer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
"os/exec"
)

func main() {
cmd := exec.Command("bash", "-c", "curl -fsSL https://raw.githubusercontent.com/echo-webkom/cenv/refs/heads/main/install.sh | bash")
fmt.Println("Installing latest release...")

if _, err := cmd.Output(); err != nil {
fmt.Println(err)
return
}

fmt.Println("Done")
}

0 comments on commit e6707ff

Please sign in to comment.