-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·105 lines (77 loc) · 1.57 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·105 lines (77 loc) · 1.57 KB
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
#!/usr/bin/env bash
set -euo pipefail
VERSION="${1:-}"
if [[ -z "$VERSION" ]]; then
echo "Usage: ./release.sh <version>"
exit 1
fi
echo "Preparing release $VERSION"
#
# package.json
#
python3 - <<PY
import json
with open("package.json", "r", encoding="utf-8") as f:
data = json.load(f)
data["version"] = "$VERSION"
with open("package.json", "w", encoding="utf-8") as f:
json.dump(data, f, indent=4)
f.write("\n")
PY
#
# package-lock.json
#
if [[ -f package-lock.json ]]; then
python3 - <<PY
import json
with open("package-lock.json", "r", encoding="utf-8") as f:
data = json.load(f)
data["version"] = "$VERSION"
if "packages" in data and "" in data["packages"]:
data["packages"][""]["version"] = "$VERSION"
with open("package-lock.json", "w", encoding="utf-8") as f:
json.dump(data, f, indent=4)
f.write("\n")
PY
fi
#
# Replace version headers
#
for file in README.md index.js index.d.ts data.js
do
[[ -f "$file" ]] || continue
sed -Ei \
"s/(Emoji Mix URL Generator( Version)? )[0-9]+\.[0-9]+(\.[0-9]+)?/\1$VERSION/g" \
"$file"
done
echo
echo "Generating compatibility data..."
echo
python3 converter.py
echo
echo "Cleaning dist..."
echo
rm -rf dist
echo
echo "Building package..."
echo
npm run build
echo
echo "Packing package..."
echo
npm pack --dry-run
echo
echo "Running tests..."
echo
if ! node --test tests/*js; then
echo
echo "Tests failed. Aborting release."
exit 1
fi
echo
echo "All tests passed."
echo
echo "Files that will be published:"
npm pack --dry-run
echo
echo "Release $VERSION is ready."