#!/bin/sh { set -ex version=$1 repository_owner=fish-shell remote=origin if [ -n "$2" ]; then set -u repository_owner=$2 remote=$3 set +u [ $# -eq 3 ] fi [ -n "$version" ] for tool in \ cmake \ bundle \ diff \ gh \ gpg \ jq \ ninja \ ruby \ tar \ timeout \ uv \ xz \ ; do if ! command -v "$tool" >/dev/null; then echo >&2 "$0: missing command: $1" exit 1 fi done committer=$(git var GIT_AUTHOR_IDENT) committer=${committer% *} # strip timezone committer=${committer% *} # strip timestamp gpg --local-user="$committer" --sign /dev/null repo_root="$(dirname "$0")/.." fish_site=$repo_root/../fish-site fish_site_repo=git@github.com:$repository_owner/fish-site for path in . "$fish_site" do if ! git -C "$path" diff HEAD --quiet || git ls-files --others --exclude-standard | grep .; then echo >&2 "$0: index and worktree must be clean" exit 1 fi done ( cd "$fish_site" [ "$(git rev-parse HEAD)" = \ "$(git ls-remote "$fish_site_repo" refs/heads/master | awk '{print $1}')" ] ) if git tag | grep -qxF "$version"; then echo >&2 "$0: tag $version already exists" exit 1 fi integration_branch=$( git for-each-ref --points-at=HEAD 'refs/heads/Integration_*' \ --format='%(refname:strip=2)' ) [ -n "$integration_branch" ] || git merge-base --is-ancestor "$remote"/master HEAD sed -n 1p CHANGELOG.rst | grep -q '^fish .*(released .*)$' sed -n 2p CHANGELOG.rst | grep -q '^===*$' changelog_title="fish $version (released $(date +'%B %d, %Y'))" sed -i \ -e "1c$changelog_title" \ -e "2c$(printf %s "$changelog_title" | sed s/./=/g)" \ CHANGELOG.rst CreateCommit() { git commit -m "$1 Created by ./build_tools/release.sh $version" } sed -i "s/^version = \".*\"/version = \"$1\"/g" Cargo.toml cargo fetch --offline # bumps the version in Cargo.lock if [ "$1" = "$version" ]; then # debchange is a Debian script to manage the Debian changelog, but # it's too annoying to install everywhere. Just do it by hand. cat - contrib/debian/changelog > contrib/debian/changelog.new <CHANGELOG.rst git add CHANGELOG.rst CreateCommit "start new cycle" git push "$remote" HEAD:master } fi exit }