-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
99 lines (80 loc) · 3.61 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
PACKAGE=$(shell awk '/^Package: / { print $$2 }' DESCRIPTION)
VERSION=$(shell awk '/^Version: / { print $$2 }' DESCRIPTION)
TARBALL=$(PACKAGE)_$(VERSION).tar.gz
all: check
install:
R CMD INSTALL --install-tests --html --example .
# Some things aren't installed by "make install", vignettes for example.
# This is slower, but more accurate.
full-install: build
R CMD INSTALL --install-tests --html --example "$(TARBALL)"
build:
R CMD build .
check: build
R CMD check "$(TARBALL)"
check-as-cran: build
R CMD check --as-cran "$(TARBALL)"
wincheck: build
# See https://win-builder.r-project.org/ for more information
curl -# -T "$(TARBALL)" ftp://win-builder.r-project.org/R-devel/
# https://www.mail-archive.com/r-package-devel@r-project.org/msg05040.html
curl -s ftp://win-builder.r-project.org/R-devel/ | sed -E 's/(AM|PM)/\t\1/g' | sort -k 1 -k 3 -k 2
examples: install
Rscript -e 'devtools::run_examples(run_donttest = FALSE, run_dontrun = FALSE, document = FALSE)'
vignettes: install
Rscript -e 'tools::buildVignettes(dir=".")'
serve-docs:
[ -d docs ] && rm -r docs || true
Rscript --vanilla -e "pkgdown::build_site() ; servr::httd(dir='docs', host='0.0.0.0', port='8000')"
test: install
for f in tests/test*.R; do echo "=== $$f ============="; Rscript $$f || exit 1; done
inttest: install
for f in inttest/*/run.R; do echo "=== $$f ============="; Rscript $$f || exit 1; done
coverage:
R --vanilla -e 'covr::package_coverage(type = "all", line_exclusions = list())'
release: release-description $(if $(wildcard ChangeLog),release-changelog) release-news
git commit -m "Release version $(NEW_VERSION)" $(wildcard DESCRIPTION ChangeLog NEWS.md)
git tag -am "Release version $(NEW_VERSION)" v$(NEW_VERSION)
#
R CMD build .
#
sed -i 's/^Version: .*/Version: '"$(NEW_VERSION)-999"'/' DESCRIPTION
mv NEWS.md NEWS.md.o
/bin/echo -e "# $(PACKAGE) $(NEW_VERSION)-999:\n" > NEWS.md
cat NEWS.md.o >> NEWS.md
rm NEWS.md.o
git commit -m "Development version $(NEW_VERSION)-999" $(wildcard DESCRIPTION ChangeLog NEWS.md)
release-description:
[ -n "$(NEW_VERSION)" ] # NEW_VERSION variable should be set
sed -i 's/^Version: .*/Version: $(NEW_VERSION)/' DESCRIPTION
sed -i "s/^Date: .*/Date: $$(date +%Y-%m-%d)/" DESCRIPTION
sed -i 's/^Depends: R .*/Depends: R (>= $(shell curl -s https://api.r-hub.io/rversions/r-oldrel/4 | grep -oiE '"version":"[0-9.]+"' | grep -oE '[0-9]+\.[0-9]+\.')0)/' DESCRIPTION
release-changelog:
[ -n "$(NEW_VERSION)" ] # NEW_VERSION variable should be set
mv ChangeLog ChangeLog.o || touch ChangeLog.o
echo "$$(date +%Y-%m-%d) $$(git config user.name) <$$(git config user.email)>" > ChangeLog
echo "" >> ChangeLog
echo " Version $(NEW_VERSION)" >> ChangeLog
echo "" >> ChangeLog
git log --pretty=format:' * %d %s (%h)' $(shell git describe --tags --abbrev=0)..HEAD -- ./R >> ChangeLog
echo "" >> ChangeLog
echo "" >> ChangeLog
cat ChangeLog.o >> ChangeLog
rm ChangeLog.o
release-news:
[ -n "$(NEW_VERSION)" ] # NEW_VERSION variable should be set
# Remove any -999 header
mv NEWS.md NEWS.md.o
head -1 NEWS.md.o | grep -qE '^\# $(PACKAGE).*-999:?$$' || head -2 NEWS.md.o > NEWS.md
tail -n +3 NEWS.md.o >> NEWS.md
rm NEWS.md.o
# Any news? Add new header if so
mv NEWS.md NEWS.md.o
head -1 NEWS.md.o | grep -qE '^\# $(PACKAGE) ' || /bin/echo -e "# $(PACKAGE) $(NEW_VERSION):\n" > NEWS.md
cat NEWS.md.o >> NEWS.md
rm NEWS.md.o
# Release steps
# make release NEW_VERSION=1.3-0
# Upload to CRAN
# git push && git push --tags
.PHONY: all install full-install build check check-as-cran wincheck examples vignettes serve-docs test inttest coverage release release-description release-changelog release-news