diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93734aa..d3114a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,8 @@ jobs: run: | dnf update -y dnf install -y golang make tar diffutils bzip2 gzip curl git which + - name: Mark repo as safe for git + run: git config --global --add safe.directory $GITHUB_WORKSPACE - name: Check out repository uses: actions/checkout@v6 - name: Build and test diff --git a/Makefile b/Makefile index f357a38..43419e0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,8 @@ -.PHONY: all build clean fmt install lint test tools unit-test integration-test validate .install.golangci-lint +PROJECT := tar-diff +VERSION := $(shell grep -oP 'VERSION\s*=\s*"\K[^"]+' pkg/common/version.go) +PROJ_TARBALL := $(PROJECT)_$(VERSION).tar.gz + +.PHONY: all build clean fmt install lint test tools dist unit-test integration-test validate .install.golangci-lint export GOPROXY=https://proxy.golang.org @@ -17,13 +21,16 @@ endif PACKAGES := $(shell go list $(GOFLAGS) ./...) SOURCE_DIRS = $(shell echo $(PACKAGES) | awk 'BEGIN{FS="/"; RS=" "}{print $$4}' | uniq) -PREFIX ?= ${DESTDIR}/usr -INSTALLDIR=${PREFIX}/bin +PREFIX ?= /usr +INSTALLDIR=${DESTDIR}${PREFIX}/bin export PATH := $(PATH):${GOBIN} all: tools tar-diff tar-patch test validate +$(PROJ_TARBALL): + git archive --prefix=tar-diff_$(VERSION)/ --format=tar.gz HEAD --output $(PROJ_TARBALL) + build: go build $(GOFLAGS) ./... @@ -47,6 +54,7 @@ tools: .install.golangci-lint clean: rm -f tar-diff tar-patch + rm -rf $(PROJECT)_$(VERSION) $(PROJ_TARBALL) integration-test: tar-diff tar-patch tests/test.sh @@ -65,3 +73,7 @@ validate: lint lint: GOFLAGS=$(GOFLAGS) $(GOBIN)/golangci-lint run + +dist: $(PROJ_TARBALL) + @echo "Created $(PROJ_TARBALL)" +