]> jfr.im git - yt-dlp.git/blob - devscripts/release.sh
Completely change project name to yt-dlp (#85)
[yt-dlp.git] / devscripts / release.sh
1 # Unused
2 #!/bin/bash
3
4 # IMPORTANT: the following assumptions are made
5 # * the GH repo is on the origin remote
6 # * the gh-pages branch is named so locally
7 # * the git config user.signingkey is properly set
8
9 # You will need
10 # pip install coverage nose rsa wheel
11
12 # TODO
13 # release notes
14 # make hash on local files
15
16 set -e
17
18 skip_tests=true
19 gpg_sign_commits=""
20 buildserver='localhost:8142'
21
22 while true
23 do
24 case "$1" in
25 --run-tests)
26 skip_tests=false
27 shift
28 ;;
29 --gpg-sign-commits|-S)
30 gpg_sign_commits="-S"
31 shift
32 ;;
33 --buildserver)
34 buildserver="$2"
35 shift 2
36 ;;
37 --*)
38 echo "ERROR: unknown option $1"
39 exit 1
40 ;;
41 *)
42 break
43 ;;
44 esac
45 done
46
47 if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi
48 version="$1"
49 major_version=$(echo "$version" | sed -n 's#^\([0-9]*\.[0-9]*\.[0-9]*\).*#\1#p')
50 if test "$major_version" '!=' "$(date '+%Y.%m.%d')"; then
51 echo "$version does not start with today's date!"
52 exit 1
53 fi
54
55 if [ ! -z "`git tag | grep "$version"`" ]; then echo 'ERROR: version already present'; exit 1; fi
56 if [ ! -z "`git status --porcelain | grep -v CHANGELOG`" ]; then echo 'ERROR: the working directory is not clean; commit or stash changes'; exit 1; fi
57 useless_files=$(find yt_dlp -type f -not -name '*.py')
58 if [ ! -z "$useless_files" ]; then echo "ERROR: Non-.py files in yt_dlp: $useless_files"; exit 1; fi
59 if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi
60 if ! type pandoc >/dev/null 2>/dev/null; then echo 'ERROR: pandoc is missing'; exit 1; fi
61 if ! python3 -c 'import rsa' 2>/dev/null; then echo 'ERROR: python3-rsa is missing'; exit 1; fi
62 if ! python3 -c 'import wheel' 2>/dev/null; then echo 'ERROR: wheel is missing'; exit 1; fi
63
64 read -p "Is ChangeLog up to date? (y/n) " -n 1
65 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
66
67 /bin/echo -e "\n### First of all, testing..."
68 make clean
69 if $skip_tests ; then
70 echo 'SKIPPING TESTS'
71 else
72 nosetests --verbose --with-coverage --cover-package=yt_dlp --cover-html test --stop || exit 1
73 fi
74
75 /bin/echo -e "\n### Changing version in version.py..."
76 sed -i "s/__version__ = '.*'/__version__ = '$version'/" yt_dlp/version.py
77
78 /bin/echo -e "\n### Changing version in ChangeLog..."
79 sed -i "s/<unreleased>/$version/" ChangeLog
80
81 /bin/echo -e "\n### Committing documentation, templates and yt_dlp/version.py..."
82 make README.md CONTRIBUTING.md issuetemplates supportedsites
83 git add README.md CONTRIBUTING.md .github/ISSUE_TEMPLATE/1_broken_site.md .github/ISSUE_TEMPLATE/2_site_support_request.md .github/ISSUE_TEMPLATE/3_site_feature_request.md .github/ISSUE_TEMPLATE/4_bug_report.md .github/ISSUE_TEMPLATE/5_feature_request.md .github/ISSUE_TEMPLATE/6_question.md docs/supportedsites.md yt_dlp/version.py ChangeLog
84 git commit $gpg_sign_commits -m "release $version"
85
86 /bin/echo -e "\n### Now tagging, signing and pushing..."
87 git tag -s -m "Release $version" "$version"
88 git show "$version"
89 read -p "Is it good, can I push? (y/n) " -n 1
90 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
91 echo
92 MASTER=$(git rev-parse --abbrev-ref HEAD)
93 git push origin $MASTER:master
94 git push origin "$version"
95
96 /bin/echo -e "\n### OK, now it is time to build the binaries..."
97 REV=$(git rev-parse HEAD)
98 make yt-dlp yt-dlp.tar.gz
99 read -p "VM running? (y/n) " -n 1
100 wget "http://$buildserver/build/ytdl-org/youtube-dl/yt-dlp.exe?rev=$REV" -O yt-dlp.exe
101 mkdir -p "build/$version"
102 mv yt-dlp yt-dlp.exe "build/$version"
103 mv yt-dlp.tar.gz "build/$version/yt-dlp-$version.tar.gz"
104 RELEASE_FILES="yt-dlp yt-dlp.exe yt-dlp-$version.tar.gz"
105 (cd build/$version/ && md5sum $RELEASE_FILES > MD5SUMS)
106 (cd build/$version/ && sha1sum $RELEASE_FILES > SHA1SUMS)
107 (cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS)
108 (cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS)
109
110 /bin/echo -e "\n### Signing and uploading the new binaries to GitHub..."
111 for f in $RELEASE_FILES; do gpg --passphrase-repeat 5 --detach-sig "build/$version/$f"; done
112
113 ROOT=$(pwd)
114 python devscripts/create-github-release.py ChangeLog $version "$ROOT/build/$version"
115
116 ssh ytdl@yt-dl.org "sh html/update_latest.sh $version"
117
118 /bin/echo -e "\n### Now switching to gh-pages..."
119 git clone --branch gh-pages --single-branch . build/gh-pages
120 (
121 set -e
122 ORIGIN_URL=$(git config --get remote.origin.url)
123 cd build/gh-pages
124 "$ROOT/devscripts/gh-pages/add-version.py" $version
125 "$ROOT/devscripts/gh-pages/update-feed.py"
126 "$ROOT/devscripts/gh-pages/sign-versions.py" < "$ROOT/updates_key.pem"
127 "$ROOT/devscripts/gh-pages/generate-download.py"
128 "$ROOT/devscripts/gh-pages/update-copyright.py"
129 "$ROOT/devscripts/gh-pages/update-sites.py"
130 git add *.html *.html.in update
131 git commit $gpg_sign_commits -m "release $version"
132 git push "$ROOT" gh-pages
133 git push "$ORIGIN_URL" gh-pages
134 )
135 rm -rf build
136
137 make pypi-files
138 echo "Uploading to PyPi ..."
139 python setup.py sdist bdist_wheel upload
140 make clean
141
142 /bin/echo -e "\n### DONE!"