chore: Replace justfile with Makefile

Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
Tim Hårek Andreassen 2024-10-26 19:04:22 +02:00
parent 7388a1b893
commit 4c1a70e412
No known key found for this signature in database
GPG key ID: E59C7734F0E10EB5
3 changed files with 47 additions and 44 deletions

View file

@ -2,7 +2,7 @@ image: alpine/edge
oauth: git.sr.ht/OBJECTS:RW git.sr.ht/REPOSITORIES:RO git.sr.ht/PROFILE:RO oauth: git.sr.ht/OBJECTS:RW git.sr.ht/REPOSITORIES:RO git.sr.ht/PROFILE:RO
packages: packages:
- go - go
- just - make
- hut - hut
sources: sources:
- git@git.sr.ht:~timharek/yr - git@git.sr.ht:~timharek/yr
@ -14,7 +14,7 @@ tasks:
- setup: | - setup: |
echo 'cd yr' >> ~/.buildenv echo 'cd yr' >> ~/.buildenv
- test: | - test: |
just test make test
- build: | - build: |
tag=$(git describe --exact-match --tags HEAD 2>/dev/null || true) tag=$(git describe --exact-match --tags HEAD 2>/dev/null || true)
if [ -z "$tag" ]; then if [ -z "$tag" ]; then
@ -24,7 +24,7 @@ tasks:
version=$(echo "$tag" | tr -d 'v') version=$(echo "$tag" | tr -d 'v')
just build-release $tag $version darwin amd64 make GOOS="darwin" ARCH="amd64" build-release
just build-release $tag $version darwin arm64 make GOOS="dawrin" ARCH="aarch64" build-release
just build-release $tag $version linux amd64 make GOOS="linux" ARCH="amd64" build-release
just build-release $tag $version windows amd64 make GOOS="windows" ARCH="amd64" build-release

41
Makefile Normal file
View file

@ -0,0 +1,41 @@
prefix = /usr/local
# Support upper case PREFIX
ifneq ($(PREFIX),)
prefix := $(PREFIX)
endif
bindir = $(prefix)/bin
builddir = ./build
VERSION = 0.0.5
.PHONY: build
build:
go build -o $(builddir)
.PHONY: install
install: build
install -m 0755 $(builddir)/yr $(bindir)
.PHONY: clean
clean:
rm -f $(builddir)/*
rm -rf yr-*
rm -f yr-*.tar.gz
.PHONY: build-release
build-release: build
mkdir -p yr-$(VERSION)
cp $(builddir)/yr* yr-$(VERSION)/
tar czf yr-$(VERSION)-$(GOOS)-$(ARCH).tar.gz yr-$(VERSION)
hut git artifact upload --rev $(tag) yr-$(VERSION)-$(GOOS)-$(ARCH).tar.gz
.PHONY: test
test:
go test ./...
.PHONY: vet
vet:
go vet ./...

View file

@ -1,38 +0,0 @@
builddir := "./build"
prefix := env_var_or_default("PREFIX", "/usr/local")
bindir := prefix + "/bin"
default:
just --list
dev +args='--help':
go run main.go {{args}}
test:
go test ./...
tidy:
go mod 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}}/
tar czf yr-{{version}}-{{os}}-{{arch}}.tar.gz yr-{{version}}
hut git artifact upload --rev {{tag}} yr-{{version}}-{{os}}-{{arch}}.tar.gz
install: build
install -m 0755 {{builddir}}/yr {{bindir}}