-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
125 lines (90 loc) · 4.03 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
VERSION := ${versionNumber}
PACK := nuage
PROJECT := github.com/pulumi/pulumi-${PACK}
PROVIDER := pulumi-resource-${PACK}
CODEGEN := pulumi-gen-${PACK}
VERSION_PATH := provider/pkg/version.Version
WORKING_DIR := $(shell pwd)
SCHEMA_PATH := ${WORKING_DIR}/schema.json
SRC := provider/cmd/pulumi-resource-${PACK}
generate:: gen_go_sdk gen_nodejs_sdk gen_python_sdk # gen_dotnet_sdk
build:: build_provider build_nodejs_sdk build_python_sdk # build_dotnet_sdk
install:: install_nodejs_sdk # install_dotnet_sdk
# Provider
PROVIDER_FILES = bin/PulumiPlugin.yaml bin/requirements.txt bin/run-provider.py
PROVIDER_FILES += bin/pulumi-resource-${PACK}.cmd bin/pulumi-resource-${PACK}
build_provider:: bin/venv bin/${PACK}_provider ${PROVIDER_FILES}
bin/venv: ${SRC}/requirements.txt
rm -rf $@
python3 -m venv $@
./bin/venv/bin/python -m pip install -r $<
bin/${PACK}_provider: ${SRC}/ ${SRC}/${PACK}_provider/VERSION
rm -rf $@
cp ${WORKING_DIR}/schema.json ${SRC}/${PACK}_provider/schema.json
./bin/venv/bin/python -m pip install --no-deps provider/cmd/pulumi-resource-${PACK}/ -t bin/
bin/PulumiPlugin.yaml: ${SRC}/PulumiPlugin.yaml
bin/requirements.txt: ${SRC}/requirements.txt
bin/pulumi-resource-${PACK}.cmd: ${SRC}/pulumi-resource-${PACK}.cmd
bin/pulumi-resource-${PACK}: ${SRC}/pulumi-resource-${PACK}
bin/run-provider.py: ${SRC}/run-provider.py
bin/%:
cp -f $< $@
${SRC}/${PACK}_provider/VERSION:
echo "${VERSION}" > ${SRC}/${PACK}_provider/VERSION
# Go SDK
gen_go_sdk::
rm -rf sdk/go
cd provider/cmd/${CODEGEN} && go run . go ../../../sdk/go ${SCHEMA_PATH}
# .NET SDK
gen_dotnet_sdk::
rm -rf sdk/dotnet
cd provider/cmd/${CODEGEN} && go run . dotnet ../../../sdk/dotnet ${SCHEMA_PATH}
build_dotnet_sdk:: DOTNET_VERSION := ${VERSION}
build_dotnet_sdk:: gen_dotnet_sdk
cd sdk/dotnet/ && \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
install_dotnet_sdk:: build_dotnet_sdk
rm -rf ${WORKING_DIR}/nuget
mkdir -p ${WORKING_DIR}/nuget
find . -name '*.nupkg' -print -exec cp -p {} ${WORKING_DIR}/nuget \;
# Node.js SDK
gen_nodejs_sdk::
rm -rf sdk/nodejs
cd provider/cmd/${CODEGEN} && go run . nodejs ../../../sdk/nodejs ${SCHEMA_PATH}
build_nodejs_sdk:: gen_nodejs_sdk
cd sdk/nodejs/ && \
yarn install && \
yarn run tsc --version && \
yarn run tsc && \
cp -R scripts/ bin && \
cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json && \
rm ./bin/package.json.bak
install_nodejs_sdk:: build_nodejs_sdk
yarn link --cwd ${WORKING_DIR}/sdk/nodejs/bin
# Python SDK
gen_python_sdk::
rm -rf sdk/python
cd provider/cmd/${CODEGEN} && go run . python ../../../sdk/python ${SCHEMA_PATH}
cp ${WORKING_DIR}/README.md sdk/python
build_python_sdk:: PYPI_VERSION := ${VERSION}
build_python_sdk:: gen_python_sdk
cd sdk/python/ && \
python3 setup.py clean --all 2>/dev/null && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e "s/\$${VERSION}/${PYPI_VERSION}/g" -e "s/\$${PLUGIN_VERSION}/${VERSION}/g" ./bin/setup.py && \
rm ./bin/setup.py.bak && \
cd ./bin && python3 setup.py build sdist
# Output tarballs for plugin distribution. Example use:
#
# pulumi plugin install resource nuage 0.0.1 --file pulumi-resource-nuage-v0.0.1-linux-amd64.tar.gz
dist:: build_provider
rm -rf dist
mkdir -p dist
(cd bin && tar --gzip --exclude venv --exclude pulumi-resource-${PACK}.cmd -cf ../dist/pulumi-resource-${PACK}-v${VERSION}-linux-amd64.tar.gz .)
cp dist/pulumi-resource-${PACK}-v${VERSION}-linux-amd64.tar.gz dist/pulumi-resource-${PACK}-v${VERSION}-darwin-amd64.tar.gz
cp dist/pulumi-resource-${PACK}-v${VERSION}-linux-amd64.tar.gz dist/pulumi-resource-${PACK}-v${VERSION}-darwin-arm64.tar.gz
(cd bin && tar --gzip --exclude venv --exclude pulumi-resource-${PACK} -cf ../dist/pulumi-resource-${PACK}-v${VERSION}-windows-amd64.tar.gz .)
run_tests::
python3 -m unittest discover provider/cmd/pulumi-resource-nuage/tests/