]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ||
3 | set -eu | |
4 | ||
5 | shutdown() { | |
6 | # Get our process group id | |
7 | # shellcheck disable=SC2009 | |
8 | PGID=$(ps -o pgid= $$ | grep -o "[0-9]*") | |
9 | ||
10 | # Kill it in a new new process group | |
11 | setsid kill -- -"$PGID" | |
12 | exit 0 | |
13 | } | |
14 | ||
15 | trap "shutdown" SIGINT SIGTERM | |
16 | ||
17 | if [ -z "$1" ]; then | |
18 | echo "Need version as argument" | |
19 | exit -1 | |
20 | fi | |
21 | ||
22 | if [ -z "$GITHUB_TOKEN" ]; then | |
23 | echo "Need GITHUB_TOKEN env set." | |
24 | exit -1 | |
25 | fi | |
26 | ||
27 | branch=$(git symbolic-ref --short -q HEAD) | |
28 | if [ "$branch" != "develop" ]; then | |
29 | echo "Need to be on develop branch." | |
30 | exit -1 | |
31 | fi | |
32 | ||
33 | version="v$1" | |
34 | directory_name="peertube-$version" | |
35 | zip_name="peertube-$version.zip" | |
36 | tar_name="peertube-$version.tar.xz" | |
37 | ||
38 | changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "$version" | sed '1{/^$/d}') | |
39 | ||
40 | printf "Changelog will be:\\n%s\\n" "$changelog" | |
41 | ||
42 | read -p "Are you sure to release? " -n 1 -r | |
43 | echo | |
44 | if [[ ! $REPLY =~ ^[Yy]$ ]] | |
45 | then | |
46 | exit 0 | |
47 | fi | |
48 | ||
49 | ( | |
50 | cd client | |
51 | npm version --no-git-tag-version --no-commit-hooks "$1" | |
52 | ) | |
53 | ||
54 | npm version -f --no-git-tag-version --no-commit-hooks "$1" | |
55 | ||
56 | git commit package.json client/package.json -m "Bumped to version $version" | |
57 | git tag -s -a "$version" -m "$version" | |
58 | ||
59 | npm run build | |
60 | rm "./client/dist/en_US/stats.json" | |
61 | rm "./client/dist/embed-stats.json" | |
62 | ||
63 | # Creating the archives | |
64 | ( | |
65 | # local variables | |
66 | directories_to_archive=("$directory_name/CREDITS.md" "$directory_name/FAQ.md" \ | |
67 | "$directory_name/LICENSE" "$directory_name/README.md" \ | |
68 | "$directory_name/client/dist/" "$directory_name/client/yarn.lock" \ | |
69 | "$directory_name/client/package.json" "$directory_name/config" \ | |
70 | "$directory_name/dist" "$directory_name/package.json" \ | |
71 | "$directory_name/scripts" "$directory_name/support" \ | |
72 | "$directory_name/tsconfig.json" "$directory_name/yarn.lock") | |
73 | maintainer_public_key="583A612D890159BE" | |
74 | ||
75 | # temporary setup | |
76 | cd .. | |
77 | ln -s "PeerTube" "$directory_name" | |
78 | ||
79 | # archive creation + signing | |
80 | zip -r "PeerTube/$zip_name" "${directories_to_archive[@]}" | |
81 | gpg --armor --detach-sign -u "$maintainer_public_key" "PeerTube/$zip_name" | |
82 | XZ_OPT=-e9 tar cfJ "PeerTube/$tar_name" "${directories_to_archive[@]}" | |
83 | gpg --armor --detach-sign -u "$maintainer_public_key" "PeerTube/$tar_name" | |
84 | ||
85 | # temporary setup destruction | |
86 | rm "$directory_name" | |
87 | ) | |
88 | ||
89 | # Creating the release on GitHub, with the created archives | |
90 | ( | |
91 | git push origin --tag | |
92 | ||
93 | github-release release --user chocobozzz --repo peertube --tag "$version" --name "$version" --description "$changelog" | |
94 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name" --file "$zip_name" | |
95 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name.asc" --file "$zip_name.asc" | |
96 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name" --file "$tar_name" | |
97 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name.asc" --file "$tar_name.asc" | |
98 | ||
99 | git push origin develop | |
100 | ||
101 | # Update master branch | |
102 | git checkout master | |
103 | git rebase develop | |
104 | git push origin master | |
105 | git checkout develop | |
106 | ) |