Compare commits

..

13 Commits

Author SHA1 Message Date
719e24eb80 chore: mark next point release
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build is passing
2021-09-07 15:25:29 +02:00
c441a1ab52 Merge branch 'abra-upgrade' into main 2021-09-07 15:24:48 +02:00
b0460bd923 docs: mark abra upgrade as done 2021-09-07 15:23:33 +02:00
f1659b3bda feat: support abra upgrading 2021-09-07 15:23:10 +02:00
eb4a2b3339 build: fix arch download on installer script
Only support x86_64 for now as I'm moving fast.
2021-09-07 15:22:42 +02:00
265bfe92fd Merge pull request 'feat: bash and (fi)zsh completion along with docs' (#83) from knoflook/abra:bash-completion into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: coop-cloud/abra#83
2021-09-07 13:22:28 +00:00
1757fabb89 feat: bash and (fi)zsh completion along with docs
All checks were successful
continuous-integration/drone/pr Build is passing
2021-09-07 13:18:21 +02:00
abf0ebf41d docs: process for releasing
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-07 13:01:36 +02:00
45f1692c99 build: add installer script 2021-09-07 13:01:22 +02:00
48bc03db51 Merge pull request 'build: generate binaries directly' (#81) from binary-builds into main
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Reviewed-on: coop-cloud/abra#81
2021-09-07 08:56:23 +00:00
f0e966afc3 docs: explain further our understanding of versioning
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-09-07 10:55:30 +02:00
a1d1166308 docs: unwrap text like the rest 2021-09-07 10:53:37 +02:00
1438fdf3c2 build: generate binaries directly
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
Closes coop-cloud/abra#80.
2021-09-07 10:49:51 +02:00
14 changed files with 267 additions and 6 deletions

View File

@ -22,6 +22,7 @@ archives:
linux: Linux linux: Linux
386: i386 386: i386
amd64: x86_64 amd64: x86_64
format: binary
checksum: checksum:
name_template: "checksums.txt" name_template: "checksums.txt"
snapshot: snapshot:

View File

@ -38,6 +38,27 @@ make install
The abra binary will be in `$GOPATH/bin`. The abra binary will be in `$GOPATH/bin`.
## Autocompletion
**bash**
Copy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename
it to abra.
```
sudo cp autocomplete/bash_autocomplete /etc/bash_completion.d/abra
source /etc/bash_completion.d/abra
```
**(fi)zsh**
(fi)zsh doesn't have an autocompletion folder by default but you can create one, then copy `zsh_autocomplete` into it and add a couple lines to your `~/.zshrc` or `~/.fizsh/.fizshrc`
```
sudo mkdir /etc/zsh/completion.d/
sudo cp autocomplete/zsh_autocomplete /etc/zsh/completion.d/abra
echo "PROG=abra\n_CLI_ZSH_AUTOCOMPLETE_HACK=1\nsource /etc/zsh/completion.d/abra" >> ~/.zshrc
```
(replace .zshrc with ~/.fizsh/.fizshrc if you use fizsh)
## Hacking ## Hacking
Install direnv, run `cp .envrc.sample .envrc`, then run `direnv allow` in this directory. This will set coopcloud repos as private due to [this bug.](https://git.coopcloud.tech/coop-cloud/coopcloud.tech/issues/20#issuecomment-8201). Or you can run `go env -w GOPRIVATE=coopcloud.tech` but I'm not sure how persistent this is. Install direnv, run `cp .envrc.sample .envrc`, then run `direnv allow` in this directory. This will set coopcloud repos as private due to [this bug.](https://git.coopcloud.tech/coop-cloud/coopcloud.tech/issues/20#issuecomment-8201). Or you can run `go env -w GOPRIVATE=coopcloud.tech` but I'm not sure how persistent this is.
@ -54,11 +75,18 @@ Please use the [conventional commit format](https://www.conventionalcommits.org/
## Versioning ## Versioning
We use [goreleaser](https://goreleaser.com) to help us automate releases. We We use [goreleaser](https://goreleaser.com) to help us automate releases. We use [semver](https://semver.org) for versioning all releases of the tool. While we are still in the public alpha release phase, we will maintain a `0.y.z-alpha` format. Change logs are generated from our commit logs. We are still working this out and aim to refine our release praxis as we go.
use [semver](https://semver.org) for versioning all releases of the tool. While
we are still in the public alpha release phase, we will maintain a For developers, while using this `-alpha` format, the `y` part is the "major" version part. So, if you make breaking changes, you increment that and _not_ the `x` part. So, if you're on `0.1.0-alpha`, then you'd go to `0.1.1-alpha` for a backwards compatible change and `0.2.0-alpha` for a backwards incompatible change.
`0.y.z-alpha` format. Change logs are generated from our commit logs. We are
still working this out and aim to refine our release praxis as we go. ## Making a new release
- Change `ABRA_VERSION` to match the new tag in [`scripts`](./scripts/installer/installer) (use [semver](https://semver.org))
- Commit that change (e.g. `git commit -m 'chore: publish next tag 0.3.1-alpha'`)
- Make a new tag (e.g. `git tag 0.y.z-alpha`)
- Push the new tag (e.g. `git push && git push --tags`)
- Wait until the build finishes on [build.coopcloud.tech](https://build.coopcloud.tech/coop-cloud/abra)
- Check the release worked, (e.g. `abra upgrade; abra version`)
## Fork maintenance ## Fork maintenance

View File

@ -42,7 +42,7 @@
- [x] `sync` - [x] `sync`
- [x] `versions` - [x] `versions`
- [x] `lint` - [x] `lint`
- [ ] `upgrade` - [x] `upgrade`
- [x] `version` - [x] `version`
## Next phase ## Next phase

21
autocomplete/bash_autocomplete Executable file
View File

@ -0,0 +1,21 @@
#! /bin/bash
: ${PROG:=$(basename ${BASH_SOURCE})}
_cli_bash_autocomplete() {
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ "$cur" == "-"* ]]; then
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
else
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG
unset PROG

View File

@ -0,0 +1,9 @@
$fn = $($MyInvocation.MyCommand.Name)
$name = $fn -replace "(.*)\.ps1$", '$1'
Register-ArgumentCompleter -Native -CommandName $name -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$other = "$wordToComplete --generate-bash-completion"
Invoke-Expression $other | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}

View File

@ -0,0 +1,23 @@
#compdef $PROG
_cli_zsh_autocomplete() {
local -a opts
local cur
cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi
if [[ "${opts[1]}" != "" ]]; then
_describe 'values' opts
else
_files
fi
return
}
compdef _cli_zsh_autocomplete $PROG

View File

@ -55,6 +55,7 @@ func RunApp(version, commit string) {
server.ServerCommand, server.ServerCommand,
recipe.RecipeCommand, recipe.RecipeCommand,
VersionCommand, VersionCommand,
UpgradeCommand,
}, },
Flags: []cli.Flag{ Flags: []cli.Flag{
VerboseFlag, VerboseFlag,
@ -67,6 +68,7 @@ func RunApp(version, commit string) {
}, },
}, },
} }
app.EnableBashCompletion = true
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
logrus.Fatal(err) logrus.Fatal(err)

38
cli/internal/command.go Normal file
View File

@ -0,0 +1,38 @@
package internal
import (
"bufio"
"fmt"
"os/exec"
)
func RunCmd(cmd *exec.Cmd) error {
r, err := cmd.StdoutPipe()
if err != nil {
return err
}
cmd.Stderr = cmd.Stdout
done := make(chan struct{})
scanner := bufio.NewScanner(r)
go func() {
for scanner.Scan() {
line := scanner.Text()
fmt.Println(line)
}
done <- struct{}{}
}()
if err := cmd.Start(); err != nil {
return err
}
<-done
if err := cmd.Wait(); err != nil {
return err
}
return nil
}

22
cli/upgrade.go Normal file
View File

@ -0,0 +1,22 @@
package cli
import (
"os/exec"
"coopcloud.tech/abra/cli/internal"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
// UpgradeCommand upgrades abra in-place.
var UpgradeCommand = &cli.Command{
Name: "upgrade",
Usage: "Upgrade abra",
Action: func(c *cli.Context) error {
cmd := exec.Command("bash", "-c", "curl -s https://install.abra.coopcloud.tech | bash")
if err := internal.RunCmd(cmd); err != nil {
logrus.Fatal(err)
}
return nil
},
}

View File

@ -0,0 +1,5 @@
# install.abra.coopcloud.tech
To deploy, run `make`.
You have to be an [Autonomic](https://autonomic.zone) member to do this.

View File

@ -0,0 +1,38 @@
---
version: "3.8"
services:
app:
image: "nginx:stable"
configs:
- source: abra_conf
target: /etc/nginx/conf.d/abra.conf
- source: abra_installer
target: /var/www/abra-installer/installer
volumes:
- "public:/var/www/abra-installer"
networks:
- proxy
deploy:
update_config:
failure_action: rollback
order: start-first
labels:
- "traefik.enable=true"
- "traefik.http.services.abra-installer.loadbalancer.server.port=80"
- "traefik.http.routers.abra-installer.rule=Host(`install.abra.autonomic.zone`,`install.abra.coopcloud.tech`)"
- "traefik.http.routers.abra-installer.entrypoints=web-secure"
- "traefik.http.routers.abra-installer.tls.certresolver=production"
configs:
abra_installer:
file: installer
abra_conf:
file: nginx.conf
networks:
proxy:
external: true
volumes:
public:

57
scripts/installer/installer Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
ABRA_VERSION="0.1.2-alpha"
ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION"
function show_banner {
echo ""
echo " ____ ____ _ _ "
echo " / ___|___ ___ _ __ / ___| | ___ _ _ __| |"
echo " | | / _ \ _____ / _ \| '_ \ | | | |/ _ \| | | |/ _' |"
echo " | |__| (_) |_____| (_) | |_) | | |___| | (_) | |_| | (_| |"
echo " \____\___/ \___/| .__/ \____|_|\___/ \__,_|\__,_|"
echo " |_|"
echo ""
echo ""
echo " === Public interest infrastructure === "
echo ""
echo ""
}
function install_abra_release {
mkdir -p "$HOME/.local/bin"
if ! type "curl" > /dev/null 2>&1; then
echo "'curl' is not installed, cannot proceed..."
echo "perhaps try installing manually via the releases URL?"
echo "https://git.coopcloud.tech/coop-cloud/abra/releases"
exit 1
fi
if ! type "curl" > /dev/null 2>&1; then
error "'python3' is not installed, cannot proceed..."
echo "perhaps try installing manually via the releases URL?"
echo "https://git.coopcloud.tech/coop-cloud/abra/releases"
fi
# FIXME: support different architectures
release_url=$(curl -s "$ABRA_RELEASE_URL" |
python3 -c "import sys, json; \
payload = json.load(sys.stdin); \
url = [a['browser_download_url'] for a in payload['assets'] if 'x86_64' in a['name']][0]; \
print(url)")
echo "downloading $ABRA_VERSION x86_64 binary release for abra..."
curl --progress-bar "$release_url" --output "$HOME/.local/bin/abra"
chmod +x "$HOME/.local/bin/abra"
echo "abra installed to $HOME/.local/bin/abra"
}
function run_installation {
show_banner
install_abra_release
}
run_installation "$@"
exit 0

View File

@ -0,0 +1,7 @@
STACK := abra_installer_script
default: deploy
deploy:
@docker stack rm $(STACK) && \
docker stack deploy -c compose.yml $(STACK)

View File

@ -0,0 +1,10 @@
server {
listen 80 default_server;
server_name install.abra.autonomic.zone install.abra.coopcloud.tech;
location / {
root /var/www/abra-installer;
add_header Content-Type text/plain;
index installer;
}
}