-
Notifications
You must be signed in to change notification settings - Fork 71
/
bump-version.sh
executable file
·51 lines (44 loc) · 1.69 KB
/
bump-version.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
#!/usr/bin/env bash
set -eu
old_version=$(< package.json jq -r '.version')
include_readme=true
ver_arg="${1:-unstable}"
if [ "$ver_arg" = "patch" ] || [ "$ver_arg" = "minor" ] || [ "$ver_arg" = "major" ]; then
new_version=$(semver "$old_version" -i "$ver_arg")
elif [ "$ver_arg" = "unstable" ]; then
new_version=$(semver "$old_version" -i prerelease --preid unstable)
include_readme=false
elif [ "$ver_arg" = "set" ]; then
new_version="$2"
else
echo "Invalid version parameter: $ver_arg"
echo "Usage:"
echo " $0 <patch|minor|major|unstable>"
echo " $0 set <version>"
exit 1
fi
echo "Updating version from $old_version to $new_version"
echo -n " - package.json... "
npm version "$new_version" --no-git-tag-version > /dev/null
echo "done"
echo -n " - FABLO_VERSION... "
perl -i -pe "s/FABLO_VERSION=.*\\n/FABLO_VERSION=${new_version}\\n/g" fablo.sh
perl -i -pe "s/FABLO_VERSION=.*\\n/FABLO_VERSION=${new_version}\\n/g" e2e/__snapshots__/*
echo "done"
echo -n " - JSON schema URL... "
schema_update_pattern="s/download\/[0-9-.a-zA-Z]*\/schema.json/download\/${new_version}\/schema.json/g"
if [ "$include_readme" = true ]; then
perl -i -pe "$schema_update_pattern" README.md
fi
perl -i -pe "$schema_update_pattern" docs/sample.json
perl -i -pe "$schema_update_pattern" docs/schema.json
perl -i -pe "$schema_update_pattern" samples/*.json
perl -i -pe "$schema_update_pattern" samples/*.yaml
perl -i -pe "$schema_update_pattern" e2e/__snapshots__/*
echo "done"
if [ "$include_readme" = true ]; then
echo -n " - download URL... "
download_update_pattern="s/download\/[0-9-.a-zA-Z]*\/fablo.sh/download\/${new_version}\/fablo.sh/g"
perl -i -pe "$download_update_pattern" README.md
echo "done"
fi