build: Add building

Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
Tim Hårek Andreassen 2024-10-03 19:32:53 +02:00
parent a0ff16465d
commit 6b22e870a1
No known key found for this signature in database
GPG key ID: E59C7734F0E10EB5
2 changed files with 52 additions and 3 deletions

29
.build.yml Normal file
View file

@ -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 <tim@harek.no>
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

View file

@ -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