A couple of updates

Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2026-05-06 22:18:08 +02:00
parent c52c3d1046
commit e5465f08ea
9 changed files with 84 additions and 4 deletions

View File

@@ -2,6 +2,11 @@
version: "3"
vars:
LOCALBIN:
sh: echo "$(pwd)/bin"
MIGRATE: "{{.LOCALBIN}}/migrate"
tasks:
build:
desc: Build go code
@@ -51,3 +56,49 @@ tasks:
- go get gitea.badhouseplants.net/softplayer/softplayer-go-proto@$(git -C '{{ .WORKDIR }}' rev-parse HEAD)
- rm -rf '{{ .WORKDIR }}'
- go mod tidy
add-migration:
desc: Add a new database migration
silent: true
cmd: "{{.MIGRATE}} create -dir migrations -ext sql {{.CLI_ARGS}}"
# Install required tools
localbin:
desc: Create local bin directory
silent: true
cmds:
- mkdir -p "{{.LOCALBIN}}"
migrate:
desc: Download migrate if necessary
silent: true
deps:
- localbin
cmds:
- task: go-install-tool
vars:
TARGET: "{{.MIGRATE}}"
PACKAGE: github.com/golang-migrate/migrate/v4/cmd/migrate
VERSION: latest
go-install-tool:
internal: true
silent: true
cmd: |-
set -e
TARGET="{{.TARGET}}"
PACKAGE="{{.PACKAGE}}@{{.VERSION}}"
VERSIONED="${TARGET}-{{.VERSION}}"
if [ -f "$VERSIONED" ] && [ "$(readlink -- "$TARGET" 2>/dev/null)" = "$VERSIONED" ]; then
echo "$PACKAGE already installed"
exit 0
fi
echo "Downloading $PACKAGE"
rm -f "$TARGET"
GOBIN="{{.LOCALBIN}}" go install "$PACKAGE"
mv "{{.LOCALBIN}}/$(basename "$TARGET")" "$VERSIONED"
ln -sf "$(realpath "$VERSIONED")" "$TARGET"