You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
router/Taskfile.yml

115 lines
3.5 KiB
YAML

version: '3'
vars:
GIT_TAG:
sh: git tag --points-at HEAD
GIT_COMMIT:
sh: git rev-parse --short HEAD
GIT_DIRTY:
sh: git status -s
VERSION:
sh: if test "{{.GIT_DIRTY}}" != ""; then echo "{{.GIT_COMMIT}}-dirty"; elif test "{{.GIT_TAG}}" != ""; then echo "{{.GIT_TAG}}"; else echo "{{.GIT_COMMIT}}"; fi
tasks:
default:
cmds:
- task: volume
- task: podman
version:
cmds:
- echo "{{.VERSION}}"
volume:
run: "once"
cmds:
- podman volume inspect micro_router_go 1>/dev/null 2>&1 || podman volume create micro_router_go
build:builder:
deps:
- volume
cmds:
- podman build -v "{{.VOLUME_PATH}}:/go:rw" -t docker.io/pcdummy/go-micro-router-builder:latest -f ./docker/builder/Dockerfile .
sources:
- ./docker/builder/Dockerfile
vars:
VOLUME_PATH:
sh: podman volume inspect micro_router_go --format "{{"{{"}}.Mountpoint{{"}}"}}"
builder:
desc: Run something in the builder container for example "task builder -- go get -u ./..."
deps:
- build:builder
cmds:
- podman run --rm -v "$PWD:/code:rw" -v "{{.VOLUME_PATH}}:/go:rw" docker.io/pcdummy/go-micro-router-builder:latest {{.CLI_ARGS}}
vars:
VOLUME_PATH:
sh: podman volume inspect micro_router_go --format "{{"{{"}}.Mountpoint{{"}}"}}"
protoc:
desc: Generate protobruf go files
sources:
- ./proto/**/*.proto
cmds:
- task: builder
vars:
CLI_ARGS: /bin/sh -c 'cd ./internal/proto/routerclientpb; protoc --proto_path=/go/bin:. --micro_out=paths=source_relative:. --go_out=paths=source_relative:. routerclientpb.proto'
- task: builder
vars:
CLI_ARGS: /bin/sh -c 'cd ./internal/proto/routerserverpb; protoc --proto_path=/go/bin:. --micro_out=paths=source_relative:. --go_out=paths=source_relative:. routerserverpb.proto'
build:podman:
deps:
- protoc
cmds:
- podman build -v "$PWD:/code:rw" -v "{{.VOLUME_PATH}}:/go:rw" --build-arg CACHEBUST={{.DATE}} --build-arg VERSION={{.VERSION}} -t docker.io/pcdummy/go-micro-router:latest -f ./docker/go-micro-router/Dockerfile .
vars:
DATE:
sh: date +%s
VOLUME_PATH:
sh: podman volume inspect micro_router_go --format "{{"{{"}}.Mountpoint{{"}}"}}"
tag:podman:
cmds:
- podman tag docker.io/pcdummy/go-micro-router:latest docker.io/pcdummy/go-micro-router:{{.GIT_TAG}}
status:
- test "{{.VERSION}}" != "{{.GIT_TAG}}"
podman:
desc: Generate docker container for go-micro-router tagged as docker.io/pcdummy/go-micro-router:latest and :GIT_TAG if theres a tag
cmds:
- task: build:podman
- task: tag:podman
release:
desc: Release images to docker.io, this requires the current commit to be a git tag
deps:
- podman
cmds:
- podman push docker.io/pcdummy/go-micro-router:latest
- podman push docker.io/pcdummy/go-micro-router:{{.GIT_TAG}}
status:
- test "{{.VERSION}}" != "{{.GIT_TAG}}"
tidy:
desc: Run "go mod tidy" in a container
cmds:
- task: builder
vars:
CLI_ARGS: go mod tidy
update:
desc: Run "go get -u ./..." in a container
cmds:
- task: builder
vars:
CLI_ARGS: go get -u ./...
rm:
desc: Remove all persistent data
cmds:
- podman image rm docker.io/pcdummy/go-micro-router-builder:latest || exit 0
# Don't delete the result
# - podman image rm docker.io/pcdummy/go-micro-router:latest || exit 0
- podman volume rm micro_router_go || exit 0
- rm -rf $PWD/.task