6 # Get our process group id
7 # shellcheck disable=SC2009
8 PGID
=$(ps -o pgid= $$ | grep -o "[0-9]*")
10 # Kill it in a new new process group
11 setsid
kill -- -"$PGID"
15 trap "shutdown" SIGINT SIGTERM
18 echo "Need version as argument"
22 if [ -z "$GITHUB_TOKEN" ]; then
23 echo "Need GITHUB_TOKEN env set."
27 maintainer_public_key
=${MAINTAINER_GPG:-"583A612D890159BE"}
29 peertube_directory
=$(basename $(pwd))
31 branch
=$(git symbolic-ref --short -q HEAD)
32 if [ "$branch" != "develop" ] && [[ "$branch" != release
/* ]]; then
33 echo "Need to be on develop or release branch."
38 github_prerelease_option
=""
39 if [[ "$version" = *"-alpha."* ]] || [[ "$version" = *"-beta."* ]] || [[ "$version" = *"-rc."* ]]; then
40 echo -e "This is a pre-release.\n"
41 github_prerelease_option
="--pre-release"
44 directory_name
="peertube-$version"
45 zip_name
="peertube-$version.zip"
46 tar_name
="peertube-$version.tar.xz"
48 changelog
=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "## $version" | sed '1{/^$/d}')
50 printf "Changelog will be:\\n\\n%s\\n\\n" "$changelog"
52 read -p "Are you sure to release? " -n 1 -r
54 if [[ ! $REPLY =~ ^
[Yy
]$
]]; then
60 npm version
--no-git-tag-version --no-commit-hooks "$1"
63 npm version
-f --no-git-tag-version --no-commit-hooks "$1"
65 git commit package.json client
/package.json .
/support
/doc
/api
/openapi.yaml
-m "Bumped to version $version"
66 git tag
-s -a "$version" -m "$version"
68 npm run build
-- --source-map
69 rm -f "./client/dist/en-US/stats.json"
70 rm -f "./client/dist/embed-stats.json"
72 # Creating the archives
75 directories_to_archive
=("$directory_name/CREDITS.md" "$directory_name/FAQ.md" \
76 "$directory_name/LICENSE" "$directory_name/README.md" \
77 "$directory_name/client/dist/" "$directory_name/client/yarn.lock" \
78 "$directory_name/client/package.json" "$directory_name/config" \
79 "$directory_name/dist" "$directory_name/package.json" \
80 "$directory_name/scripts" "$directory_name/support" \
81 "$directory_name/yarn.lock")
85 ln -s "$peertube_directory" "$directory_name"
87 # archive creation + signing
88 zip -9 -r "$peertube_directory/$zip_name" "${directories_to_archive[@]}"
89 gpg
--armor --detach-sign -u "$maintainer_public_key" "$peertube_directory/$zip_name"
90 XZ_OPT
="-e9 -T0" tar cfJ
"$peertube_directory/$tar_name" "${directories_to_archive[@]}"
91 gpg
--armor --detach-sign -u "$maintainer_public_key" "$peertube_directory/$tar_name"
93 # temporary setup destruction
97 # Creating the release on GitHub, with the created archives
101 if [ -z "$github_prerelease_option" ]; then
102 github
-release release
--user chocobozzz
--repo peertube
--tag "$version" --name "$version" --description "$changelog"
104 github
-release release
--user chocobozzz
--repo peertube
--tag "$version" --name "$version" --description "$changelog" "$github_prerelease_option"
107 # Wait for the release to be published, we had some issues when the files were not uploaded because of "unknown release" error
110 github
-release upload
--user chocobozzz
--repo peertube
--tag "$version" --name "$zip_name" --file "$zip_name"
111 github
-release upload
--user chocobozzz
--repo peertube
--tag "$version" --name "$zip_name.asc" --file "$zip_name.asc"
112 github
-release upload
--user chocobozzz
--repo peertube
--tag "$version" --name "$tar_name" --file "$tar_name"
113 github
-release upload
--user chocobozzz
--repo peertube
--tag "$version" --name "$tar_name.asc" --file "$tar_name.asc"
115 git push origin
"$branch"
117 # Only update master if it is not a pre release
118 if [ -z "$github_prerelease_option" ]; then
119 # Update master branch
122 git push origin master
123 git checkout
"$branch"
125 # Release types package
126 npm run generate
-types-package "$version"
127 cd packages
/types
/dist
128 npm publish
--access public