]>
Commit | Line | Data |
---|---|---|
08535e56 C |
1 | #!/bin/bash |
2 | ||
0e4ffb4b LA |
3 | set -eu |
4 | ||
6b2ef589 C |
5 | shutdown() { |
6 | # Get our process group id | |
6c42d96e | 7 | # shellcheck disable=SC2009 |
0e4ffb4b | 8 | PGID=$(ps -o pgid= $$ | grep -o "[0-9]*") |
6b2ef589 C |
9 | |
10 | # Kill it in a new new process group | |
0e4ffb4b | 11 | setsid kill -- -"$PGID" |
6b2ef589 C |
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 | ||
0e4ffb4b | 22 | if [ -z "$GITHUB_TOKEN" ]; then |
1e5c707b C |
23 | echo "Need GITHUB_TOKEN env set." |
24 | exit -1 | |
25 | fi | |
26 | ||
f6dd7f7d RK |
27 | maintainer_public_key=${MAINTAINER_GPG:-"583A612D890159BE"} |
28 | ||
f05a1c30 | 29 | branch=$(git symbolic-ref --short -q HEAD) |
107c5fcd | 30 | if [ "$branch" != "develop" ] && [[ "$branch" != release/* ]]; then |
5e319fb7 | 31 | echo "Need to be on develop or release branch." |
f05a1c30 C |
32 | exit -1 |
33 | fi | |
34 | ||
1e5c707b | 35 | version="v$1" |
87bec105 | 36 | github_prerelease_option="" |
225553a0 C |
37 | if [[ "$version" = *"-alpha."* ]] || [[ "$version" = *"-beta."* ]] || [[ "$version" = *"-rc."* ]]; then |
38 | echo -e "This is a pre-release.\n" | |
87bec105 C |
39 | github_prerelease_option="--pre-release" |
40 | fi | |
41 | ||
1e5c707b C |
42 | directory_name="peertube-$version" |
43 | zip_name="peertube-$version.zip" | |
6c42d96e | 44 | tar_name="peertube-$version.tar.xz" |
1e5c707b | 45 | |
b73ddc8a | 46 | changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "## $version" | sed '1{/^$/d}') |
e33b53ab | 47 | |
225553a0 | 48 | printf "Changelog will be:\\n\\n%s\\n\\n" "$changelog" |
e33b53ab C |
49 | |
50 | read -p "Are you sure to release? " -n 1 -r | |
51 | echo | |
fc96e83d | 52 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
0e4ffb4b | 53 | exit 0 |
e33b53ab C |
54 | fi |
55 | ||
e82afde9 | 56 | ( |
6c42d96e | 57 | cd client |
0e4ffb4b LA |
58 | npm version --no-git-tag-version --no-commit-hooks "$1" |
59 | ) | |
6b2ef589 | 60 | |
0e4ffb4b | 61 | npm version -f --no-git-tag-version --no-commit-hooks "$1" |
6b2ef589 | 62 | |
6cc98dff C |
63 | ./scripts/openapi-peertube-version.sh |
64 | ||
65 | git commit package.json client/package.json ./support/doc/api/openapi.yaml -m "Bumped to version $version" | |
1e5c707b | 66 | git tag -s -a "$version" -m "$version" |
6b2ef589 | 67 | |
0e4ffb4b | 68 | npm run build |
50a04125 | 69 | rm -f "./client/dist/en-US/stats.json" |
2a068a15 | 70 | rm -f "./client/dist/embed-stats.json" |
08535e56 | 71 | |
6c42d96e R |
72 | # Creating the archives |
73 | ( | |
d788291d | 74 | # local variables |
e82afde9 C |
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/tsconfig.json" "$directory_name/yarn.lock") | |
d788291d R |
82 | |
83 | # temporary setup | |
6c42d96e R |
84 | cd .. |
85 | ln -s "PeerTube" "$directory_name" | |
6c42d96e | 86 | |
d788291d R |
87 | # archive creation + signing |
88 | zip -r "PeerTube/$zip_name" "${directories_to_archive[@]}" | |
e82afde9 | 89 | gpg --armor --detach-sign -u "$maintainer_public_key" "PeerTube/$zip_name" |
0f4f2ab0 | 90 | XZ_OPT="-e9 -T0" tar cfJ "PeerTube/$tar_name" "${directories_to_archive[@]}" |
e82afde9 | 91 | gpg --armor --detach-sign -u "$maintainer_public_key" "PeerTube/$tar_name" |
d788291d R |
92 | |
93 | # temporary setup destruction | |
6c42d96e R |
94 | rm "$directory_name" |
95 | ) | |
1e5c707b | 96 | |
6c42d96e R |
97 | # Creating the release on GitHub, with the created archives |
98 | ( | |
6c42d96e | 99 | git push origin --tag |
f05a1c30 | 100 | |
fc96e83d C |
101 | if [ -z "$github_prerelease_option" ]; then |
102 | github-release release --user chocobozzz --repo peertube --tag "$version" --name "$version" --description "$changelog" | |
103 | else | |
104 | github-release release --user chocobozzz --repo peertube --tag "$version" --name "$version" --description "$changelog" "$github_prerelease_option" | |
105 | fi | |
106 | ||
6c42d96e R |
107 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name" --file "$zip_name" |
108 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name.asc" --file "$zip_name.asc" | |
109 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name" --file "$tar_name" | |
110 | github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name.asc" --file "$tar_name.asc" | |
0edf0581 | 111 | |
5e319fb7 | 112 | git push origin "$branch" |
f05a1c30 | 113 | |
87bec105 C |
114 | # Only update master if it is not a pre release |
115 | if [ -z "$github_prerelease_option" ]; then | |
116 | # Update master branch | |
117 | git checkout master | |
5e319fb7 | 118 | git merge "$branch" |
87bec105 | 119 | git push origin master |
5e319fb7 | 120 | git checkout "$branch" |
87bec105 | 121 | fi |
6c42d96e | 122 | ) |