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