Skip to content

Commit

Permalink
re-adapt for nibiru
Browse files Browse the repository at this point in the history
  • Loading branch information
helder-moreira committed Feb 21, 2024
1 parent fa45bc1 commit ca5c757
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 85 deletions.
32 changes: 0 additions & 32 deletions .github/goreleaser.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/ci.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build docker image

on:
push:
tags:
- "*"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get version
id: get_version
uses: battila7/get-version-action@v2

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
platforms: linux/amd64
tags: ghcr.io/nibiruchain/installer:latest,ghcr.io/nibiruchain/installer:${{ steps.get_version.outputs.version-without-v }}
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test
on:
pull_request: {}
push: {}
workflow_dispatch:
inputs: {}
jobs:
ci:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.18'
check-latest: true
cache: true
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: go build -v .
- name: Test
run: go test -v ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
tmp/
test.sh
.idea
.envrc
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:alpine AS builder
WORKDIR /src/app/
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o=/usr/local/bin/installer main.go

FROM gcr.io/distroless/base
COPY --from=builder /usr/local/bin /usr/local/bin
USER nonroot:nonroot
ENTRYPOINT [ "/usr/local/bin/installer" ]
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ curl https://i.jpillora.com/<query>! | bash
* https://i.jpillora.com/mholt/caddy
* https://i.jpillora.com/caddy
* https://i.jpillora.com/rclone
* https://i.jpillora.com/ripgrep?as=rg

```sh
$ curl -s i.jpillora.com/mholt/caddy! | bash
Expand Down Expand Up @@ -79,13 +80,13 @@ See https://github.com/jpillora/installer/issues/31 for how this could improved
go get github.com/jpillora/installer
```
* Install on Heroku
* Install on [Fly.io](https://fly.io)
Click this button to deploy for free on [Heroku](https://heroku.com)
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
*You can optionally add your own domain as a app custom domain.*
* Clone this repo
* Setup the `fly` CLI tool
* Create a new app
* Replace `app = "installer"` in `fly.toml` with your app name
* Run `fly deploy`
## Force a particular `user/repo`
Expand All @@ -97,7 +98,7 @@ export FORCE_REPO=micro
./installer
```
Then calls to `curl 'localhost:3000` will return the install script for `zyedidia/micro`
Then calls to `curl localhost:3000` will return the install script for `zyedidia/micro`
### Homebrew
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/jpillora/installer
module github.com/nibiruchain/installer

go 1.18

Expand Down
4 changes: 2 additions & 2 deletions handler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package handler
type Config struct {
Host string `opts:"help=host, env=HTTP_HOST"`
Port int `opts:"help=port, env"`
User string `opts:"help=default user when not provided in URL, env"`
User string `opts:"help=default user when not provided in URL"`
Token string `opts:"help=github api token, env=GITHUB_TOKEN"`
ForceUser string `opts:"help=lock installer to a single user, env=FORCE_USER"`
ForceRepo string `opts:"help=lock installer to a single repo, env=FORCE_REPO"`
Expand All @@ -13,5 +13,5 @@ type Config struct {
// DefaultConfig for an installer handler
var DefaultConfig = Config{
Port: 3000,
User: "jpillora",
User: "NibiruChain",
}
15 changes: 10 additions & 5 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"text/template"
"time"

"github.com/jpillora/installer/scripts"
"github.com/nibiruchain/installer/scripts"
)

const (
Expand Down Expand Up @@ -132,9 +132,14 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if q.Release == "" {
q.Release = "latest"
}
// micro > nano!
if q.User == "" && q.Program == "micro" {
q.User = "zyedidia"
if q.User == "" {
q.User = "NibiruChain"
}
if q.Program == "" {
q.Program = "nibiru"
}
if q.Program == "nibiru" {
q.AsProgram = "nibid"
}
// force user/repo
if h.Config.ForceUser != "" {
Expand All @@ -146,7 +151,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// validate query
valid := q.Program != ""
if !valid && path == "" {
http.Redirect(w, r, "https://github.com/jpillora/installer", http.StatusMovedPermanently)
http.Redirect(w, r, "https://github.com/NibiruChain/installer", http.StatusMovedPermanently)
return
}
if !valid {
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
"os"
"time"

"github.com/jpillora/installer/handler"
"github.com/jpillora/opts"
"github.com/jpillora/requestlog"
"github.com/nibiruchain/installer/handler"
)

var version = "0.0.0-src"

func main() {
c := handler.DefaultConfig
opts.New(&c).Repo("github.com/jpillora/installer").Version(version).Parse()
opts.New(&c).Repo("github.com/NibiruChain/installer").Version(version).Parse()
log.Printf("default user is '%s'", c.User)
if c.Token == "" && os.Getenv("GH_TOKEN") != "" {
c.Token = os.Getenv("GH_TOKEN") // GH_TOKEN was renamed
Expand Down
2 changes: 1 addition & 1 deletion scripts/install.rb.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class Installer < Formula
end

def caveats
"{{ .Program }} was installed using https://github.com/jpillora/installer"
"{{ .Program }} was installed using https://github.com/NibiruChain/installer"
end
end
2 changes: 1 addition & 1 deletion scripts/install.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ has-m1-asset: {{ .M1Asset }}

to see shell script, append ?type=script
for more information on this server, visit:
github.com/jpillora/installer
github.com/NibiruChain/installer


0 comments on commit ca5c757

Please sign in to comment.