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