diff --git a/.build.yml b/.build.yml new file mode 100644 index 0000000..b333392 --- /dev/null +++ b/.build.yml @@ -0,0 +1,29 @@ +image: alpine/edge +packages: + - go + - just + - hut +sources: + - git@git.sr.ht:~timharek/yr +triggers: + - action: email + condition: failure + to: Tim HĂ„rek Andreassen +tasks: + - setup: | + echo 'cd yr' >> ~/.buildenv + - test: | + just test + - build: | + tag=$(git describe --exact-match 2>/dev/null || true) + if [ -z "$tag" ]; then + echo "Current commit is not a tag; not building anything" + exit 0 + fi + + version=$(echo "$tag" | tr -d 'v') + + just build-release $tag $version darwin amd64 + just build-release $tag $version darwin arm64 + just build-release $tag $version linux amd64 + just build-release $tag $version windows amd64 diff --git a/justfile b/justfile index c53eafa..c02cbde 100644 --- a/justfile +++ b/justfile @@ -1,9 +1,8 @@ +builddir := "./build" + default: just --list -build: - echo "not implemented yet" - dev +args='--help': go run main.go {{args}} @@ -15,3 +14,24 @@ tidy: vet: go vet ./... + +clean: + rm -f build/* + rm -rf yr-* + rm -f yr-*.tar.gz + +build: + go build -o {{builddir}}/ + +build-release tag version os arch: + GOOS="{{os}}" GOARCH="{{arch}}" just build + + mkdir -p yr-{{version}} + cp {{builddir}}/yr yr-{{version}}/ + + if [ {{os}} = windows ]; then \ + mv yr-{{version}}/yr{,.exe}; \ + fi + + tar czf yr-{{version}}-{{os}}-{{arch}}.tar.gz yr-{{version}} + hut git artifact upload --rev {{tag}} yr-{{version}}-{{os}}-{{arch}}.tar.gz