-
Notifications
You must be signed in to change notification settings - Fork 289
/
Makefile
74 lines (63 loc) · 4.07 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
# SPDX-License-Identifier: CC0-1.0
TOOL_VERSION = 3.0.1
TEST_DATA = test/simpleTestForGenerator
FULL_TEST_DATA = test/fullTestForGenerator
GIT_AUTHOR = License Publisher (maintained by Gary O'Neall) <[email protected]>
GIT_AUTHOR_EMAIL = [email protected]
LICENSE_DATA_REPO_NO_SCHEME = github.com/spdx/license-list-data.git
LICENSE_DATA_REPO = https://$(LICENSE_DATA_REPO_NO_SCHEME)
LICENSE_DATA_URL = https://$(LICENSE_LIST_GITHUB_TOKEN)@$(LICENSE_DATA_REPO_NO_SCHEME)
LICENSE_OUTPUT_DIR = .tmp
GITVERSION = $(shell git describe --always --tags || echo 'UNKNOWN')
# Remove leading 'v' or 'V'
VERSION = $(subst V,,$(subst v,,$(GITVERSION)))
RELEASE_DATE = $(shell date '+%Y-%m-%d')
COMMIT_MSG = License list build $(VERSION) using license list publisher $(TOOL_VERSION)
RELEASE_MSG = Adding release matching the license list XML tag $(VERSION)
NUM_FILES_CHANGED = $(shell git diff --name-only $(INPUT_BASE_REF) $(GITHUB_SHA) | wc -l)
SOURCE_FILE_CHANGED = $(strip $(shell git diff --name-only $(INPUT_BASE_REF) $(GITHUB_SHA) | grep 'src/'))
NUM_SOURCE_FILE_CHANGED = $(shell git diff --name-only $(INPUT_BASE_REF) $(GITHUB_SHA) | grep 'src/' | wc -l)
LICENSE_SOURCE_DIR = src
LICENSE_SOURCE = $(strip $(if $(and $(or $(filter $(NUM_FILES_CHANGED),1), $(filter $(NUM_FILES_CHANGED),2)), $(filter $(NUM_SOURCE_FILE_CHANGED),1)), $(SOURCE_FILE_CHANGED), $(LICENSE_SOURCE_DIR)));
# these files are copied directly into the website directory
STATIC_FILES = equivalentwords.txt
STATIC_FILES_DEST = $(LICENSE_OUTPUT_DIR)/website/
.PHONY: validate-canonical-match
validate-canonical-match: licenseListPublisher-$(TOOL_VERSION).jar-valid $(TEST_DATA) $(FULL_TEST_DATA) $(LICENSE_OUTPUT_DIR)
echo Validating source files from $(LICENSE_SOURCE)
java -jar -DLocalFsfFreeJson=true -DlistedLicenseSchema="schema/ListedLicense.xsd" licenseListPublisher-$(TOOL_VERSION).jar LicenseRDFAGenerator '$(LICENSE_SOURCE:;=)' '$(LICENSE_OUTPUT_DIR)' 1.0 2000-01-01 $(TEST_DATA) expected-warnings $(FULL_TEST_DATA)
.PHONY: deploy-license-data
deploy-license-data: licenseListPublisher-$(TOOL_VERSION).jar-valid $(TEST_DATA) $(FULL_TEST_DATA)
rm -rf '$(LICENSE_OUTPUT_DIR)'
git clone --quiet --depth 1 $(LICENSE_DATA_URL) '$(LICENSE_OUTPUT_DIR)'
# Clean out the old data directories
find '$(LICENSE_OUTPUT_DIR)' -mindepth 1 -maxdepth 1 -name .git -prune -o -name .github -prune -o -type d -exec rm -rf {} \+
rm -f $(LICENSE_OUTPUT_DIR)/licenses.md
java -jar -DLocalFsfFreeJson=true -DlistedLicenseSchema="schema/ListedLicense.xsd" licenseListPublisher-$(TOOL_VERSION).jar LicenseRDFAGenerator '$(LICENSE_SOURCE_DIR)' '$(LICENSE_OUTPUT_DIR)' $(VERSION) $(RELEASE_DATE) $(TEST_DATA) expected-warnings $(FULL_TEST_DATA)
$(foreach f, $(STATIC_FILES), cp ${f} $(STATIC_FILES_DEST);)
git -C '$(LICENSE_OUTPUT_DIR)' add -A .
git config user.email "$(GIT_AUTHOR_EMAIL)"
git -C '$(LICENSE_OUTPUT_DIR)' commit --author "$(GIT_AUTHOR)" -m "$(COMMIT_MSG)"
git -C '$(LICENSE_OUTPUT_DIR)' push origin
.PHONY: release-license-data
release-license-data: deploy-license-data
if [[ $(VERSION) =~ .+-g[a-f0-9]{7} ]] ; then echo Can not release license data - license list version $(VERSION) does not match a release pattern ; exit 1 ; else ; git -C '$(LICENSE_OUTPUT_DIR)' tag -a $(VERSION) -m "$(RELEASE_MESSAGE)" ; git -C '$(LICENSE_OUTPUT_DIR)' push --tags --quiet origin ; fi
.PRECIOUS: licenseListPublisher-%.jar
licenseListPublisher-%.jar:
curl -L https://repo1.maven.org/maven2/org/spdx/licenseListPublisher/$*/licenseListPublisher-$*-jar-with-dependencies.jar >$@
.PRECIOUS: licenseListPublisher-%.jar.asc
licenseListPublisher-%.jar.asc:
curl -L https://repo1.maven.org/maven2/org/spdx/licenseListPublisher/$*/licenseListPublisher-$*-jar-with-dependencies.jar.asc >$@
.PHONY: licenseListPublisher-%.jar-valid
licenseListPublisher-%.jar-valid: licenseListPublisher-%.jar.asc licenseListPublisher-%.jar goneall.gpg
gpg --verify --no-default-keyring --keyring ./goneall.gpg $<
$(LICENSE_OUTPUT_DIR):
mkdir -p $@
resources:
mkdir -p $@
.PHONY: clean
clean:
rm -rf $(LICENSE_OUTPUT_DIR)
.PHONY: full-clean
full-clean: clean
rm -rf resources licenseListPublisher-*.jar*