-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (52 loc) · 2.27 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
.PHONY: deps history prod serve sign test
OS_KERNEL := $(shell uname -s)
PWD := $(shell pwd)
YEAR := $(shell date +%Y)
MONTH := $(shell date +%m)
DAY := $(shell date +%d)
DATESTAMP := $(shell date +%Y-%m-%d)
RUBY_BLOG := $(shell docker images --filter=reference=ruby-blog:latest -q )
UID := $(shell id -u)
GID := $(shell id -g)
ifndef RUBY_BLOG
ADDITIONAL_TARGETS := deps
endif
ifneq ($(DRAFT),)
DRAFT := $(DRAFT)
endif
serve: $(ADDITIONAL_TARGETS)
docker run -it --rm -v '$(PWD)':/mnt -w /mnt --init --user $(UID):$(GID) --rm -p 4000:4000 -- ruby-blog \
bundle exec jekyll serve --watch --config _config.yml,_config_local.yml,_config_dev.yml --drafts --unpublished --host=0.0.0.0
prod:
docker run -it --rm -v '$(PWD)':/mnt -w /mnt --init --user $(UID):$(GID) --rm -p 4000:4000 -- ruby-blog \
bundle exec jekyll serve --watch --config _config.yml,_config_local.yml --host=0.0.0.0
deps:
docker build -t ruby-blog .
# bundle install --jobs=3 --retry=3
test: $(ADDITIONAL_TARGETS) history
git diff --exit-code
docker run -t --rm -v '$(PWD)':/mnt -w /mnt --init --rm -- ruby-blog \
./make/verify_signatures.sh
docker run -t --rm -v '$(PWD)':/mnt -w /mnt --init --user $(UID):$(GID) --rm -- ruby-blog \
bundle exec jekyll build
# ./make/test_grammar_based_on_commit.sh
update-gemfile: deps
\rm -f Gemfile.lock
docker run -t --rm -v '$(PWD)':/mnt -w /mnt --init --user $(UID):$(GID) --rm -- ruby-blog \
bundle install --jobs=3 --retry=3
history:
docker run -t --rm -v '$(PWD)':/mnt -w /mnt --init --user $(UID):$(GID) --rm -- ruby-blog \
bundle exec ruby ./make/update_post_history.rb
promote:
set -ex; \
if [ '$(DRAFT)' = '' ]; then echo 'ERROR: must run "make promote DRAFT=draft.md" for posts in the _drafts folder'; exit 1; fi; \
if [ ! -f ./_drafts/'$(DRAFT)' ]; then echo 'ERROR: draft post "./_drafts/$(DRAFT)" does not exist'; exit 1; fi; \
sed -i.bak -e '/---/,/---/s/^year:.*/year: $(YEAR)/' ./_drafts/'$(DRAFT)'; \
sed -i.bak -e '/---/,/---/s/^month:.*/month: $(MONTH)/' ./_drafts/'$(DRAFT)'; \
sed -i.bak -e '/---/,/---/s/^day:.*/day: $(DAY)/' ./_drafts/'$(DRAFT)'; \
\rm ./_drafts/'$(DRAFT)'.bak; \
mv ./_drafts/'$(DRAFT)' _posts/$(DATESTAMP)-$(DRAFT)
sign:
./make/gpg_sign_posts.sh $(FILES)
clean:
docker run -it --rm -v '$(PWD)':/mnt -w /mnt --init --rm -- ruby-blog rm -rf _site