2017-10-27 21:51:10 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-10-06 22:24:46 -07:00
|
|
|
projects_token=${1:-}
|
|
|
|
github_token=${2:-}
|
2018-10-06 15:18:21 -07:00
|
|
|
|
|
|
|
if [[ -z $github_token ]]; then
|
2018-10-06 22:24:46 -07:00
|
|
|
echo "Usage: $0 [projects-token] [github-token]"
|
2018-10-06 15:18:21 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [[ ! -f NEWS ]]; then
|
|
|
|
echo "Missing NEWS file. Try running from root of repository."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-01-17 20:27:09 -08:00
|
|
|
version=$(head --lines=1 NEWS)
|
2020-11-21 14:03:39 -08:00
|
|
|
|
|
|
|
if [[ $version =~ .*dev* ]]; then
|
|
|
|
echo "Refusing to release a dev version: $version"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-06-25 09:42:05 -07:00
|
|
|
if ! git diff-index --quiet HEAD -- ; then
|
|
|
|
echo "Refusing to release with local changes:"
|
|
|
|
git status --porcelain
|
2022-06-30 22:14:41 -07:00
|
|
|
exit 1
|
2022-06-25 09:42:05 -07:00
|
|
|
fi
|
|
|
|
|
2018-01-17 20:27:09 -08:00
|
|
|
git tag $version
|
|
|
|
git push origin $version
|
|
|
|
git push github $version
|
|
|
|
|
2018-10-06 22:24:46 -07:00
|
|
|
# Build borgmatic and publish to pypi.
|
2017-10-27 21:51:10 -07:00
|
|
|
rm -fr dist
|
|
|
|
python3 setup.py bdist_wheel
|
|
|
|
python3 setup.py sdist
|
2020-02-03 09:57:34 -08:00
|
|
|
gpg --detach-sign --armor dist/borgmatic-*.tar.gz
|
|
|
|
gpg --detach-sign --armor dist/borgmatic-*-py3-none-any.whl
|
2022-03-14 14:00:03 -07:00
|
|
|
twine upload -r pypi --username __token__ dist/borgmatic-*.tar.gz dist/borgmatic-*.tar.gz.asc
|
|
|
|
twine upload -r pypi --username __token__ dist/borgmatic-*-py3-none-any.whl dist/borgmatic-*-py3-none-any.whl.asc
|
2018-10-06 15:18:21 -07:00
|
|
|
|
2019-12-17 20:06:25 -08:00
|
|
|
# Set release changelogs on projects.torsion.org and GitHub.
|
2018-10-14 12:14:29 -07:00
|
|
|
release_changelog="$(cat NEWS | sed '/^$/q' | grep -v '^\S')"
|
|
|
|
escaped_release_changelog="$(echo "$release_changelog" | sed -z 's/\n/\\n/g' | sed -z 's/\"/\\"/g')"
|
2018-10-15 22:32:13 -07:00
|
|
|
curl --silent --request POST \
|
2021-09-14 11:32:01 -07:00
|
|
|
"https://projects.torsion.org/api/v1/repos/borgmatic-collective/borgmatic/releases" \
|
2021-04-24 20:27:53 -07:00
|
|
|
--header "Authorization: token $projects_token" \
|
2018-10-06 22:24:46 -07:00
|
|
|
--header "Accept: application/json" \
|
|
|
|
--header "Content-Type: application/json" \
|
|
|
|
--data "{\"body\": \"$escaped_release_changelog\", \"draft\": false, \"name\": \"borgmatic $version\", \"prerelease\": false, \"tag_name\": \"$version\"}"
|
|
|
|
|
2018-10-06 15:18:21 -07:00
|
|
|
github-release create --token="$github_token" --owner=witten --repo=borgmatic --tag="$version" \
|
2018-10-06 22:24:46 -07:00
|
|
|
--name="borgmatic $version" --body="$release_changelog"
|