]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - scripts/release.sh
Only duplicate public videos
[github/Chocobozzz/PeerTube.git] / scripts / release.sh
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" ] && [[ "$branch" != feature/* ]]; then
29 echo "Need to be on develop or release branch."
30 exit -1
31 fi
32
33 version="v$1"
34 github_prerelease_option=""
35 if [[ "$version" = *".pre."* ]]; then
36 echo "This is a pre-release."
37 github_prerelease_option="--pre-release"
38 fi
39
40 directory_name="peertube-$version"
41 zip_name="peertube-$version.zip"
42 tar_name="peertube-$version.tar.xz"
43
44 changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "$version" | sed '1{/^$/d}')
45
46 printf "Changelog will be:\\n%s\\n" "$changelog"
47
48 read -p "Are you sure to release? " -n 1 -r
49 echo
50 if [[ ! $REPLY =~ ^[Yy]$ ]]; then
51 exit 0
52 fi
53
54 (
55 cd client
56 npm version --no-git-tag-version --no-commit-hooks "$1"
57 )
58
59 npm version -f --no-git-tag-version --no-commit-hooks "$1"
60
61 git commit package.json client/package.json -m "Bumped to version $version"
62 git tag -s -a "$version" -m "$version"
63
64 npm run build
65 rm "./client/dist/en_US/stats.json"
66 rm "./client/dist/embed-stats.json"
67
68 # Creating the archives
69 (
70 # local variables
71 directories_to_archive=("$directory_name/CREDITS.md" "$directory_name/FAQ.md" \
72 "$directory_name/LICENSE" "$directory_name/README.md" \
73 "$directory_name/client/dist/" "$directory_name/client/yarn.lock" \
74 "$directory_name/client/package.json" "$directory_name/config" \
75 "$directory_name/dist" "$directory_name/package.json" \
76 "$directory_name/scripts" "$directory_name/support" \
77 "$directory_name/tsconfig.json" "$directory_name/yarn.lock")
78 maintainer_public_key="583A612D890159BE"
79
80 # temporary setup
81 cd ..
82 ln -s "PeerTube" "$directory_name"
83
84 # archive creation + signing
85 zip -r "PeerTube/$zip_name" "${directories_to_archive[@]}"
86 gpg --armor --detach-sign -u "$maintainer_public_key" "PeerTube/$zip_name"
87 XZ_OPT=-e9 tar cfJ "PeerTube/$tar_name" "${directories_to_archive[@]}"
88 gpg --armor --detach-sign -u "$maintainer_public_key" "PeerTube/$tar_name"
89
90 # temporary setup destruction
91 rm "$directory_name"
92 )
93
94 # Creating the release on GitHub, with the created archives
95 (
96 git push origin --tag
97
98 if [ -z "$github_prerelease_option" ]; then
99 github-release release --user chocobozzz --repo peertube --tag "$version" --name "$version" --description "$changelog"
100 else
101 github-release release --user chocobozzz --repo peertube --tag "$version" --name "$version" --description "$changelog" "$github_prerelease_option"
102 fi
103
104 github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name" --file "$zip_name"
105 github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name.asc" --file "$zip_name.asc"
106 github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name" --file "$tar_name"
107 github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name.asc" --file "$tar_name.asc"
108
109 git push origin "$branch"
110
111 # Only update master if it is not a pre release
112 if [ -z "$github_prerelease_option" ]; then
113 # Update master branch
114 git checkout master
115 git merge "$branch"
116 git push origin master
117 git checkout "$branch"
118 fi
119 )