forked from martinthomson/i-d-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.mk
45 lines (39 loc) · 1.78 KB
/
upload.mk
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
# This only works for tags that are created with `git tag -a`. Using an
# annotated tag associates an email address, which this uses in the upload.
ifneq (,$(CIRCLE_TAG)$(TRAVIS_TAG))
draft_releases := $(CIRCLE_TAG)$(TRAVIS_TAG)
else
draft_releases := $(shell git tag --list --points-at HEAD --format '%(tag),%(taggeremail)' | grep '^draft-.*,<.*>$$' | cut -f 1 -d , -)
endif
ifneq ($(foreach tag,$(draft_releases),$(shell git tag --list --format='%(tag)' $(tag))),$(draft_releases))
$(warning Attempting upload for a lightweight tag: $(draft_releases))
$(error Only annotated tags \(created with `git tag -a`\) are supported)
endif
uploads := $(addprefix .,$(addsuffix .upload,$(draft_releases)))
ifneq (,$(TRAVIS))
# Ensure that we build the XML files needed for upload during the main build.
latest:: $(addsuffix .xml,$(draft_releases))
endif
.PHONY: upload publish
publish: upload
upload: $(uploads)
@[ -n "$^" ] || ! echo "error: No files to upload. Did you use \`git tag -a\`?"
.%.upload: %.xml
$(curl) -D $@ -F "user=$(shell git tag --list --format '%(taggeremail)' $(basename $<) | \
sed -e 's/^<//;s/>$$//')" -F "xml=@$<" \
"$(DATATRACKER_UPLOAD_URL)" && echo && \
(grep -q ' 200 OK' $@ >/dev/null 2>&1 || ! cat $@ 1>&2)
# This ignomonious hack ensures that we can catch missing files properly.
.%.upload:
@if $(MAKE) "$*".xml; then \
$(MAKE) "$@"; \
else \
echo "============================================================================"; \
echo "Warning: A source file for '$*' does not exist."; \
echo; \
echo "If you applied this tag in error, remove it before adding another tag:"; \
echo " git tag -d '$*'"; \
echo " git push -f $(GIT_REMOTE) ':$*'"; \
echo "============================================================================"; \
false; \
fi