ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

release.sh 5.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/bin/bash
  2. set -eu
  3. shutdown() {
  4. # Get our process group id
  5. # shellcheck disable=SC2009
  6. PGID=$(ps -o pgid= $$ | grep -o "[0-9]*")
  7. # Kill it in a new new process group
  8. setsid kill -- -"$PGID"
  9. exit 0
  10. }
  11. trap "shutdown" SIGINT SIGTERM
  12. if [ -z "$1" ]; then
  13. echo "Need version as argument"
  14. exit -1
  15. fi
  16. if [ -z "$GITHUB_TOKEN" ]; then
  17. echo "Need GITHUB_TOKEN env set."
  18. exit -1
  19. fi
  20. maintainer_public_key=${MAINTAINER_GPG:-"583A612D890159BE"}
  21. peertube_directory=$(basename $(pwd))
  22. branch=$(git symbolic-ref --short -q HEAD)
  23. if [ "$branch" != "develop" ] && [[ "$branch" != release/* ]]; then
  24. echo "Need to be on develop or release branch."
  25. exit -1
  26. fi
  27. yarn check --integrity --verify-tree
  28. (cd client && yarn check --integrity --verify-tree)
  29. version="v$1"
  30. github_prerelease_option=""
  31. if [[ "$version" = *"-alpha."* ]] || [[ "$version" = *"-beta."* ]] || [[ "$version" = *"-rc."* ]]; then
  32. echo -e "This is a pre-release.\n"
  33. github_prerelease_option="--pre-release"
  34. fi
  35. directory_name="peertube-$version"
  36. zip_name="peertube-$version.zip"
  37. tar_name="peertube-$version.tar.xz"
  38. changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "## $version" | sed '1{/^$/d}')
  39. printf "Changelog will be:\\n\\n%s\\n\\n" "$changelog"
  40. read -p "Are you sure to release? " -n 1 -r
  41. echo
  42. if [[ ! $REPLY =~ ^[Yy]$ ]]; then
  43. exit 0
  44. fi
  45. (
  46. cd client
  47. npm version --no-git-tag-version --no-commit-hooks "$1"
  48. )
  49. npm version -f --no-git-tag-version --no-commit-hooks "$1"
  50. git commit package.json client/package.json ./support/doc/api/openapi.yaml -m "Bumped to version $version"
  51. git tag -s -a "$version" -m "$version"
  52. npm run build -- --source-map
  53. rm -f "./client/dist/en-US/stats.json"
  54. rm -f "./client/dist/embed-stats.json"
  55. # Clean up declaration files
  56. find dist/ packages/core-utils/dist/ \
  57. packages/ffmpeg/dist/ \
  58. packages/node-utils/dist/ \
  59. packages/models/dist/ \
  60. \( -name '*.d.ts' -o -name '*.d.ts.map' \) -type f -delete
  61. # Creating the archives
  62. (
  63. # local variables
  64. directories_to_archive=("$directory_name/CREDITS.md" "$directory_name/FAQ.md" \
  65. "$directory_name/LICENSE" "$directory_name/README.md" \
  66. "$directory_name/packages/core-utils/dist/" "$directory_name/packages/core-utils/package.json" \
  67. "$directory_name/packages/ffmpeg/dist/" "$directory_name/packages/ffmpeg/package.json" \
  68. "$directory_name/packages/node-utils/dist/" "$directory_name/packages/node-utils/package.json" \
  69. "$directory_name/packages/models/dist/" "$directory_name/packages/models/package.json" \
  70. "$directory_name/packages/transcription/dist/" "$directory_name/packages/transcription/package.json" \
  71. "$directory_name/client/dist/" "$directory_name/client/yarn.lock" \
  72. "$directory_name/client/package.json" "$directory_name/config" \
  73. "$directory_name/dist" "$directory_name/package.json" \
  74. "$directory_name/scripts/upgrade.sh" "$directory_name/support" \
  75. "$directory_name/yarn.lock")
  76. # temporary setup
  77. cd ..
  78. ln -s "$peertube_directory" "$directory_name"
  79. # archive creation + signing
  80. zip -9 -r "$peertube_directory/$zip_name" "${directories_to_archive[@]}"
  81. gpg --armor --detach-sign -u "$maintainer_public_key" "$peertube_directory/$zip_name"
  82. XZ_OPT="-e9 -T0" tar cfJ "$peertube_directory/$tar_name" "${directories_to_archive[@]}"
  83. gpg --armor --detach-sign -u "$maintainer_public_key" "$peertube_directory/$tar_name"
  84. # temporary setup destruction
  85. rm "$directory_name"
  86. )
  87. # Creating the release on GitHub, with the created archives
  88. (
  89. git push origin --tag
  90. if [ -z "$github_prerelease_option" ]; then
  91. github-release release --user chocobozzz --repo peertube --tag "$version" --name "$version" --description "$changelog"
  92. else
  93. github-release release --user chocobozzz --repo peertube --tag "$version" --name "$version" --description "$changelog" "$github_prerelease_option"
  94. fi
  95. # Wait for the release to be published, we had some issues when the files were not uploaded because of "unknown release" error
  96. sleep 2
  97. github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name" --file "$zip_name"
  98. github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$zip_name.asc" --file "$zip_name.asc"
  99. github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name" --file "$tar_name"
  100. github-release upload --user chocobozzz --repo peertube --tag "$version" --name "$tar_name.asc" --file "$tar_name.asc"
  101. git push origin "$branch"
  102. # Only update master if it is not a pre release
  103. if [ -z "$github_prerelease_option" ]; then
  104. # Update master branch
  105. git checkout master
  106. git merge "$branch"
  107. git push origin master
  108. git checkout "$branch"
  109. # Rebuild properly the server, with the declaration files
  110. npm run build:server
  111. # Release types package
  112. npm run generate-types-package "$version"
  113. cd packages/types-generator/dist
  114. npm publish --access public
  115. fi
  116. )