From 6b22e870a10ad8940d4df5839d045db99221eb28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20H=C3=A5rek=20Andreassen?= Date: Thu, 3 Oct 2024 19:32:53 +0200 Subject: [PATCH] build: Add building MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Hårek Andreassen --- .build.yml | 29 +++++++++++++++++++++++++++++ justfile | 26 +++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .build.yml 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