From 915a2b659ff7e6effe5614bea128c9cddc2e866c Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 6 Feb 2024 14:03:15 +0530 Subject: [PATCH 1/9] :sparkles: Added source to support multiple binary in single repo --- handler/handler.go | 18 +++++++++++++++--- handler/handler_execute.go | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/handler/handler.go b/handler/handler.go index 76c0db5..37e2935 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -31,9 +31,9 @@ var ( ) type Query struct { - User, Program, AsProgram, Release string - MoveToPath, Search, Insecure bool - SudoMove bool // deprecated: not used, now automatically detected + User, Program, AsProgram, Release, BinSource string + MoveToPath, Search, Insecure bool + SudoMove bool // deprecated: not used, now automatically detected } type Result struct { @@ -112,6 +112,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Release: "", Insecure: r.URL.Query().Get("insecure") == "1", AsProgram: r.URL.Query().Get("as"), + BinSource: r.URL.Query().Get("source"), } // set query from route path := strings.TrimPrefix(r.URL.Path, "/") @@ -123,55 +124,66 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var rest string q.User, rest = splitHalf(path, "/") q.Program, q.Release = splitHalf(rest, "@") + // no program? treat first part as program, use default user if q.Program == "" { q.Program = q.User q.User = h.Config.User q.Search = true } + if q.Release == "" { q.Release = "latest" } + // micro > nano! if q.User == "" && q.Program == "micro" { q.User = "zyedidia" } + // force user/repo if h.Config.ForceUser != "" { q.User = h.Config.ForceUser } + if h.Config.ForceRepo != "" { q.Program = h.Config.ForceRepo } + // validate query valid := q.Program != "" if !valid && path == "" { http.Redirect(w, r, "https://github.com/jpillora/installer", http.StatusMovedPermanently) return } + if !valid { log.Printf("invalid path: query: %#v", q) showError("Invalid path", http.StatusBadRequest) return } + // fetch assets result, err := h.execute(q) if err != nil { showError(err.Error(), http.StatusBadGateway) return } + // load template t, err := template.New("installer").Parse(script) if err != nil { showError("installer BUG: "+err.Error(), http.StatusInternalServerError) return } + // execute template buff := bytes.Buffer{} if err := t.Execute(&buff, result); err != nil { showError("Template error: "+err.Error(), http.StatusInternalServerError) return } + log.Printf("serving script %s/%s@%s (%s)", q.User, q.Program, q.Release, ext) // ready w.Write(buff.Bytes()) diff --git a/handler/handler_execute.go b/handler/handler_execute.go index f04292c..75aeb73 100644 --- a/handler/handler_execute.go +++ b/handler/handler_execute.go @@ -26,6 +26,8 @@ func (h *Handler) execute(q Query) (Result, error) { //do real operation ts := time.Now() release, assets, err := h.getAssetsNoCache(q) + + // fmt.Printf("release: %s\n", assets) if err == nil { //didn't need search q.Search = false @@ -64,6 +66,8 @@ func (h *Handler) execute(q Query) (Result, error) { h.cacheMut.Lock() h.cache[key] = result h.cacheMut.Unlock() + + // fmt.Printf("result: %v\n", result.Assets) return result, nil } @@ -74,6 +78,7 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { //not cached - ask github log.Printf("fetching asset info for %s/%s@%s", user, repo, release) url := fmt.Sprintf("https://api.github.com/repos/%s/%s/releases", user, repo) + ghas := ghAssets{} if release == "" || release == "latest" { url += "/latest" @@ -81,13 +86,16 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { if err := h.get(url, &ghr); err != nil { return release, nil, err } + release = ghr.TagName //discovered ghas = ghr.Assets } else { + ghrs := []ghRelease{} if err := h.get(url, &ghrs); err != nil { return release, nil, err } + found := false for _, ghr := range ghrs { if ghr.TagName == release { @@ -95,21 +103,26 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { if err := h.get(ghr.AssetsURL, &ghas); err != nil { return release, nil, err } + ghas = ghr.Assets break } } + if !found { return release, nil, fmt.Errorf("release tag '%s' not found", release) } } + if len(ghas) == 0 { return release, nil, errors.New("no assets found") } + sumIndex, _ := ghas.getSumIndex() if l := len(sumIndex); l > 0 { log.Printf("fetched %d asset shasums", l) } + assets := Assets{} index := map[string]bool{} for _, ga := range ghas { @@ -117,6 +130,14 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { //only binary containers are supported //TODO deb,rpm etc fext := getFileExt(url) + + if q.BinSource != "" { + //filter by bin source + if !strings.Contains(ga.Name[0:len(q.BinSource)], fmt.Sprint(q.BinSource, "-")) { + continue + } + } + if fext == "" && ga.Size > 1024*1024 { fext = ".bin" // +1MB binary } @@ -143,6 +164,7 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { continue } log.Printf("fetched asset: %s", ga.Name) + asset := Asset{ OS: os, Arch: arch, @@ -151,6 +173,7 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { Type: fext, SHA256: sumIndex[ga.Name], } + //there can only be 1 file for each OS/Arch if index[asset.Key()] { continue From 7cad81d6448f5de083894ebd92f1f49d3e897be5 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 6 Feb 2024 15:59:34 +0530 Subject: [PATCH 2/9] :bookmark: Setup docker build --- .github/workflows/ci.yml | 70 +++++++++++++++++++++++++++++++++++++--- Dockerfile | 16 +++++++++ 2 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af7defe..2fc5439 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,14 @@ on: push: {} workflow_dispatch: inputs: {} + +permissions: + contents: read + packages: write + jobs: - ci: - name: CI + build: + name: Build Binaries runs-on: ubuntu-latest steps: - name: Checkout @@ -16,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: '1.19' + go-version: '1.21.5' check-latest: true cache: true - name: Build @@ -31,4 +36,61 @@ jobs: version: latest args: release --rm-dist --config .github/goreleaser.yml env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + docker-build: + runs-on: ubuntu-latest + name: Deploy to Docker Image + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Image Tag from branch name + if: startsWith(github.ref, 'refs/heads/release') + run: | + set +e + IMAGE_TAG=$(echo ${GITHUB_REF#refs/heads/} | sed 's/release-//g') + echo "$IMAGE_TAG" | grep -i '\-nightly$' + if [ $? -ne 0 ]; then + IMAGE_TAG="$IMAGE_TAG-nightly" + fi + set -e + + echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV + echo "OVERRIDE_PUSHED_IMAGE=true" >> $GITHUB_ENV + + - name: Create Image Tag from tag + if: startsWith(github.ref, 'refs/tags/') + run: | + IMAGE_TAG=$(echo ${GITHUB_REF#refs/tags/}) + + echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV + echo "OVERRIDE_PUSHED_IMAGE=false" >> $GITHUB_ENV + + - name: Build & Push Image + if: startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/') + run: | + set +e + image_name="ghcr.io/${{ github.repository }}/bin-installer + + docker manifest inspect $image_name:$IMAGE_TAG + exit_status=$? + if [ $exit_status -eq 0 ]; then + [ "$OVERRIDE_PUSHED_IMAGE" = "false" ] && echo "image ($image_name:$IMAGE_TAG) already exists, and override image is disable, exiting" && exit 0 + echo "image exists, but override pushed image is set to true. proceeding with building image" + fi + + set -e + + docker build -t $image_name:$IMAGE_TAG . + docker push $image_name:$IMAGE_TAG diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4cd1dee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# syntax=docker/dockerfile:1.4 +FROM golang:1.18.3-alpine3.16 AS base +USER 1001 +ENV GOPATH=/tmp/go +ENV GOCACHE=/tmp/go-cache +WORKDIR /tmp/app +COPY . . +RUN go mod download -x + +RUN CGO_ENABLED=0 go build -tags musl -o /tmp/bin/bin-installer ./main.go +RUN chmod +x /tmp/bin/bin-installer + +FROM gcr.io/distroless/static-debian11:nonroot +LABEL org.opencontainers.image.source=https://github.com/kloudlite/bin-installer +COPY --from=base /tmp/bin/bin-installer ./bin-installer +CMD ["./bin-installer"] From 6e100e914e611aa7094527bbe64f3a79bdac7264 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 6 Feb 2024 16:48:20 +0530 Subject: [PATCH 3/9] :bookmark: Fixed issue with build command --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fc5439..5e7c8c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,17 +80,9 @@ jobs: - name: Build & Push Image if: startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/') run: | - set +e image_name="ghcr.io/${{ github.repository }}/bin-installer docker manifest inspect $image_name:$IMAGE_TAG - exit_status=$? - if [ $exit_status -eq 0 ]; then - [ "$OVERRIDE_PUSHED_IMAGE" = "false" ] && echo "image ($image_name:$IMAGE_TAG) already exists, and override image is disable, exiting" && exit 0 - echo "image exists, but override pushed image is set to true. proceeding with building image" - fi - - set -e docker build -t $image_name:$IMAGE_TAG . docker push $image_name:$IMAGE_TAG From dea168977c5839e86f27bb282179c868fd1fca8d Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 6 Feb 2024 16:50:50 +0530 Subject: [PATCH 4/9] :bookmark: Fixed issue with build command --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e7c8c6..8fb86d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,7 +80,7 @@ jobs: - name: Build & Push Image if: startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/') run: | - image_name="ghcr.io/${{ github.repository }}/bin-installer + image_name="ghcr.io/${{ github.repository }}" docker manifest inspect $image_name:$IMAGE_TAG From 56642ed54958ac8dc941fd3e25ee8261d1d7c91a Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 6 Feb 2024 16:52:41 +0530 Subject: [PATCH 5/9] :bookmark: Fixed issue with build command --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fb86d0..12edc6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,5 @@ jobs: run: | image_name="ghcr.io/${{ github.repository }}" - docker manifest inspect $image_name:$IMAGE_TAG - docker build -t $image_name:$IMAGE_TAG . docker push $image_name:$IMAGE_TAG From 69d2f2f4ce5b55bedb6f7a5cf6ec6dc21c9b7225 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 6 Feb 2024 17:09:36 +0530 Subject: [PATCH 6/9] :bug: Fixed issue with name match --- handler/handler_execute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handler/handler_execute.go b/handler/handler_execute.go index 75aeb73..63e5087 100644 --- a/handler/handler_execute.go +++ b/handler/handler_execute.go @@ -133,7 +133,7 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { if q.BinSource != "" { //filter by bin source - if !strings.Contains(ga.Name[0:len(q.BinSource)], fmt.Sprint(q.BinSource, "-")) { + if !strings.Contains(ga.Name[0:len(q.BinSource)+1], fmt.Sprint(q.BinSource, "-")) { continue } } From bf0ecf3916ca313f3961cf04c1fdd61e89e6a5a7 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 6 Feb 2024 17:27:30 +0530 Subject: [PATCH 7/9] :bug: Fixed issue with bin name to local --- handler/handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/handler/handler.go b/handler/handler.go index 37e2935..2f136df 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -114,6 +114,11 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { AsProgram: r.URL.Query().Get("as"), BinSource: r.URL.Query().Get("source"), } + + if q.AsProgram == "" && q.BinSource != "" { + q.AsProgram = q.BinSource + } + // set query from route path := strings.TrimPrefix(r.URL.Path, "/") // move to path with ! From 8b5f8b73d7aa786c03e556bd1ab3edb1283ac5c3 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Wed, 14 Feb 2024 22:48:39 +0530 Subject: [PATCH 8/9] :sparkles: Added support of windows --- Taskfile.yaml | 12 ++++++ handler/handler.go | 34 +++++++++++++++-- handler/handler_execute.go | 5 +-- scripts/install.ps1.tmpl | 76 ++++++++++++++++++++++++++++++++++++++ scripts/scripts.go | 5 ++- 5 files changed, 125 insertions(+), 7 deletions(-) create mode 100644 Taskfile.yaml create mode 100644 scripts/install.ps1.tmpl diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..8581eaf --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,12 @@ +version: 3 + +tasks: + run: + cmds: + - go run main.go + dev: + cmds: + - nodemon -q -e 'go' --signal SIGTERM --exec "echo '# building' && task build && echo '# build success' && ./bin/installer || exit" + build: + cmds: + - go build -o ./bin/installer main.go diff --git a/handler/handler.go b/handler/handler.go index 2f136df..6c34fa2 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -26,6 +26,7 @@ const ( var ( isTermRe = regexp.MustCompile(`(?i)^(curl|wget)\/`) isHomebrewRe = regexp.MustCompile(`(?i)^homebrew`) + isPowershell = regexp.MustCompile(`(?i)windows`) errMsgRe = regexp.MustCompile(`[^A-Za-z0-9\ :\/\.]`) errNotFound = errors.New("not found") ) @@ -69,17 +70,22 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ext := "" script := "" qtype := r.URL.Query().Get("type") + if qtype == "" { ua := r.Header.Get("User-Agent") + switch { case isTermRe.MatchString(ua): qtype = "script" case isHomebrewRe.MatchString(ua): qtype = "ruby" + case isPowershell.MatchString(ua): + qtype = "powershell" default: qtype = "text" } } + // type specific error response showError := func(msg string, code int) { // prevent shell injection @@ -98,6 +104,10 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/ruby") ext = "rb" script = string(scripts.Homebrew) + case "powershell": + w.Header().Set("Content-Type", "text/plain") + ext = "ps1" + script = string(scripts.Powershell) case "text": w.Header().Set("Content-Type", "text/plain") ext = "txt" @@ -176,16 +186,34 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // load template - t, err := template.New("installer").Parse(script) - if err != nil { + + t := template.New("installer") + funcs := template.FuncMap{} + + funcs["getArchURL"] = func(res Result, os string, arch string) (string, error) { + for _, asset := range res.Assets { + if string(asset.OS) == os && string(asset.Arch) == arch { + return string(asset.URL), nil + } + } + return "", fmt.Errorf("no asset found for %s/%s", os, arch) + } + + t = t.Funcs(funcs) + + if _, err := t.Parse(script); err != nil { showError("installer BUG: "+err.Error(), http.StatusInternalServerError) return } + if result.BinSource == "" { + result.BinSource = result.Program + } + // execute template buff := bytes.Buffer{} if err := t.Execute(&buff, result); err != nil { - showError("Template error: "+err.Error(), http.StatusInternalServerError) + // showError("Template error: "+err.Error(), http.StatusInternalServerError) return } diff --git a/handler/handler_execute.go b/handler/handler_execute.go index 63e5087..e514e9b 100644 --- a/handler/handler_execute.go +++ b/handler/handler_execute.go @@ -27,7 +27,6 @@ func (h *Handler) execute(q Query) (Result, error) { ts := time.Now() release, assets, err := h.getAssetsNoCache(q) - // fmt.Printf("release: %s\n", assets) if err == nil { //didn't need search q.Search = false @@ -152,8 +151,8 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) { os := getOS(ga.Name) arch := getArch(ga.Name) //windows not supported yet - if os == "windows" { - log.Printf("fetched asset is for windows: %s", ga.Name) + if os == "windows" && fext != ".zip" { + // log.Printf("fetched asset is for windows: %s", ga.Name) //TODO: powershell // EG: iwr https://deno.land/x/install/install.ps1 -useb | iex continue diff --git a/scripts/install.ps1.tmpl b/scripts/install.ps1.tmpl new file mode 100644 index 0000000..bb048df --- /dev/null +++ b/scripts/install.ps1.tmpl @@ -0,0 +1,76 @@ +{{/* $appversion = "v1.0.3" */}} + +{{- $urlamd64 := getArchURL . "windows" "amd64" }} +{{- $urlarm64 := getArchURL . "windows" "arm64" }} + +$url = "--not-generated--" + +$urlamd64 = "{{$urlamd64}}" +$urlarm64 = "{{$urlarm64}}" +$destinationPath = "$env:USERPROFILE\Documents\kl" + +$arch = "$env:PROCESSOR_ARCHITECTURE" + +$filename = "kloudlite-windows-$arch.zip" + +$zipFilePath = "$env:TEMP\$filename" +$tempPath = "$env:TEMP\kl" + +$arch_lower=$arch.ToLower() + +Write-Host "" +Write-Host "Installing kloudlite binary {{.BinSource}} ($arch_lower) version {{.Release}} at path '$destinationPath'" + +if ($arch -eq "ARM64") { + $url = $urlarm64 +} else { + $url = $urlamd64 +} + +# Create the destination directory if it doesn't exist +if (-not (Test-Path $destinationPath)) { + New-Item -ItemType Directory -Force -Path $destinationPath +} + +# Use Invoke-WebRequest to download the file +Invoke-WebRequest -Uri $url -OutFile $zipFilePath + +# Expand the archive +Expand-Archive -Path $zipFilePath -DestinationPath $tempPath + +Get-ChildItem -Path $tempPath -Filter *.exe -Recurse | Move-Item -Destination $destinationPath -Force + +# Clean up the downloaded ZIP and temporary extracted folder +Remove-Item -Path $zipFilePath -Force +Remove-Item -Path $tempPath -Recurse -Force + +# Get the current user's PATH environment variable +$currentPath = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User) + +# Split the PATH variable into an array of individual paths +$pathArray = $currentPath -split ";" + +$hasPath = "false" +# Iterate over each path in the PATH variable +foreach ($path in $pathArray) { + # Check if the current path contains the specific directory + if ($path -eq $destinationPath) { + $hasPath = "true" + } +} + +if ($hasPath -eq "false") { +# Update the PATH environment variable + if (-not [string]::IsNullOrWhiteSpace($currentPath)) { + $updatedPath = $currentPath + ";" + $destinationPath + } else { + $updatedPath = $destinationPath + } +} + +# Set the updated PATH +[System.Environment]::SetEnvironmentVariable("PATH", $updatedPath, [System.EnvironmentVariableTarget]::User) + +Write-Host "" +Write-Host "[#] installation complete, use `{{.BinSource}} --help` to get started." +Write-Host "" diff --git a/scripts/scripts.go b/scripts/scripts.go index 1701816..c581770 100644 --- a/scripts/scripts.go +++ b/scripts/scripts.go @@ -2,7 +2,7 @@ package scripts import _ "embed" -//go:embed install.txt.tmpl +// go:embed install.txt.tmpl var Text []byte //go:embed install.sh.tmpl @@ -10,3 +10,6 @@ var Shell []byte //go:embed install.rb.tmpl var Homebrew []byte + +//go:embed install.ps1.tmpl +var Powershell []byte From f055686c741e934ed6abc39de33645f4ffa3e933 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Wed, 14 Feb 2024 23:35:05 +0530 Subject: [PATCH 9/9] removed extra files to pull on main repo --- .github/workflows/ci.yml | 47 ---------------------------------------- Dockerfile | 16 -------------- Taskfile.yaml | 12 ---------- scripts/install.ps1.tmpl | 4 ++-- 4 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 Dockerfile delete mode 100644 Taskfile.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12edc6b..0192195 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,50 +37,3 @@ jobs: args: release --rm-dist --config .github/goreleaser.yml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - docker-build: - runs-on: ubuntu-latest - name: Deploy to Docker Image - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Image Tag from branch name - if: startsWith(github.ref, 'refs/heads/release') - run: | - set +e - IMAGE_TAG=$(echo ${GITHUB_REF#refs/heads/} | sed 's/release-//g') - echo "$IMAGE_TAG" | grep -i '\-nightly$' - if [ $? -ne 0 ]; then - IMAGE_TAG="$IMAGE_TAG-nightly" - fi - set -e - - echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV - echo "OVERRIDE_PUSHED_IMAGE=true" >> $GITHUB_ENV - - - name: Create Image Tag from tag - if: startsWith(github.ref, 'refs/tags/') - run: | - IMAGE_TAG=$(echo ${GITHUB_REF#refs/tags/}) - - echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV - echo "OVERRIDE_PUSHED_IMAGE=false" >> $GITHUB_ENV - - - name: Build & Push Image - if: startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/') - run: | - image_name="ghcr.io/${{ github.repository }}" - - docker build -t $image_name:$IMAGE_TAG . - docker push $image_name:$IMAGE_TAG diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4cd1dee..0000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -# syntax=docker/dockerfile:1.4 -FROM golang:1.18.3-alpine3.16 AS base -USER 1001 -ENV GOPATH=/tmp/go -ENV GOCACHE=/tmp/go-cache -WORKDIR /tmp/app -COPY . . -RUN go mod download -x - -RUN CGO_ENABLED=0 go build -tags musl -o /tmp/bin/bin-installer ./main.go -RUN chmod +x /tmp/bin/bin-installer - -FROM gcr.io/distroless/static-debian11:nonroot -LABEL org.opencontainers.image.source=https://github.com/kloudlite/bin-installer -COPY --from=base /tmp/bin/bin-installer ./bin-installer -CMD ["./bin-installer"] diff --git a/Taskfile.yaml b/Taskfile.yaml deleted file mode 100644 index 8581eaf..0000000 --- a/Taskfile.yaml +++ /dev/null @@ -1,12 +0,0 @@ -version: 3 - -tasks: - run: - cmds: - - go run main.go - dev: - cmds: - - nodemon -q -e 'go' --signal SIGTERM --exec "echo '# building' && task build && echo '# build success' && ./bin/installer || exit" - build: - cmds: - - go build -o ./bin/installer main.go diff --git a/scripts/install.ps1.tmpl b/scripts/install.ps1.tmpl index bb048df..8f3f594 100644 --- a/scripts/install.ps1.tmpl +++ b/scripts/install.ps1.tmpl @@ -11,7 +11,7 @@ $destinationPath = "$env:USERPROFILE\Documents\kl" $arch = "$env:PROCESSOR_ARCHITECTURE" -$filename = "kloudlite-windows-$arch.zip" +$filename = "app-windows-$arch.zip" $zipFilePath = "$env:TEMP\$filename" $tempPath = "$env:TEMP\kl" @@ -19,7 +19,7 @@ $tempPath = "$env:TEMP\kl" $arch_lower=$arch.ToLower() Write-Host "" -Write-Host "Installing kloudlite binary {{.BinSource}} ($arch_lower) version {{.Release}} at path '$destinationPath'" +Write-Host "Installing binary {{.BinSource}} ($arch_lower) version {{.Release}} at path '$destinationPath'" if ($arch -eq "ARM64") { $url = $urlarm64