-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
prep.sh
executable file
·112 lines (80 loc) · 3.27 KB
/
prep.sh
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
#!/bin/bash
set -Eeuxo pipefail
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
source "$HOME/.bashrc" || true
source "$HOME/.cargo/env" || true
if [ -z "${FORCE_VERSION+x}" ]; then
if [ -z "$(git log -1 --pretty=%B | grep "Add spec for")" ]; then
echo "This commit does not appear to be related to a spec update, skipping chain."
exit 0
fi
version=$(git log -1 --pretty=%B | head -n 1 | sed -E 's/Add spec for (.+):(.+)$/\2/')
else
version=${FORCE_VERSION}
fi
####################################
if [ -z "${FORCE_PROJECT+x}" ]; then
if [ -z "$(git log -1 --pretty=%B | grep "Add spec for")" ]; then
echo "This commit does not appear to be related to a spec update, skipping chain."
exit 0
fi
## Extract project and version from git commit ##
project=$(git log -1 --pretty=%B | head -n 1 | sed -E 's/Add spec for (.+):(.+)$/\1/')
else
project=${FORCE_PROJECT}
fi
if [ -z "${project}" ]; then
echo "Variable project can not be empty. Expected commit message to be 'Add spec for <project>:<version>' but got: $(git log -1 --pretty=%B | head -n 1 )"
exit 1
fi
if [ -z "${version}" ]; then
echo "Variable version can not be empty. Expected commit message to be 'Add spec for <project>:<version>' but got: $(git log -1 --pretty=%B | head -n 1 )"
exit 1
fi
echo "Generating SDKs for $project:$version"
## end ##
####################################
spec_file="spec/${project}/${version}.json"
jq -c ".info.version = \"${version}\"" "${spec_file}" > tmp.$$.json && mv tmp.$$.json "${spec_file}"
## end ##
####################################
gem_version=$(echo "${version}" | sed -E 's/v([0-9]+\.[0-9]+\.[0-9]+)-([a-z]+)\.([0-9]+)/\1.\2\3/' | sed -E 's/v([0-9]+\.[0-9]+\.[0-9]+)-([a-z]+)/\1.\2/' | sed 's/^v//')
## Set up env vars ##
export PROJECT=${project}
export VERSION=${version}
export RAW_VERSION=$(echo "${VERSION}" | sed "s/^v//")
export GEM_VERSION=${gem_version}
export SPEC_FILE=${spec_file}
# shellcheck disable=SC2155
export PROJECT_UCF="$(tr '[:lower:]' '[:upper:]' <<< "${project:0:1}")${project:1}"
export GPG_OPTS='--pinentry-mode loopback'
export DOTNET_PACKAGE_NAME="Ory.$PROJECT_UCF.Client"
export DART_PUB_NAME="ory_${PROJECT}_client"
export JAVA_GROUP_ID=sh.ory.$PROJECT
export JAVA_ARTIFACT_ID=$PROJECT-client
export PHP_PACKAGE_NAME="ory/${PROJECT}-client"
export PHP_INVOKER_PACKAGE="Ory\\${PROJECT_UCF}\\Client"
export PYTHON_PROJECT_NAME="ory-${PROJECT}-client"
export PYTHON_PACKAGE_NAME="ory_${PROJECT}_client"
export RUBY_PROJECT_NAME="ory-${PROJECT}-client"
export RUBY_MODULE_NAME="Ory${PROJECT_UCF}Client"
export RUST_PACKAGE_NAME="ory-${PROJECT}-client"
export NPM_NAME="@ory/$PROJECT-client"
export ELIXIR_PACKAGE_NAME="ory_${PROJECT}"
export GIT_REPO="${PROJECT}-client"
if [ $project == "client" ]; then
export DART_PUB_NAME=ory_client
export DOTNET_PACKAGE_NAME="Ory.Client"
export JAVA_GROUP_ID=sh.ory
export JAVA_ARTIFACT_ID=client
export PHP_PACKAGE_NAME="ory/client"
export PHP_INVOKER_PACKAGE="Ory\\Client"
export PYTHON_PROJECT_NAME="ory-client"
export PYTHON_PACKAGE_NAME="ory_client"
export RUBY_PROJECT_NAME="ory-client"
export RUBY_MODULE_NAME="OryClient"
export RUST_PACKAGE_NAME="ory-client"
export NPM_NAME="@ory/client"
export ELIXIR_PACKAGE_NAME="ory_client"
export GIT_REPO="client"
fi