Skip to content

Commit

Permalink
Add Beeper release flow scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Mar 25, 2024
1 parent 62b41c7 commit 2af3786
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
31 changes: 31 additions & 0 deletions beeper/complete_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -euo pipefail
source $(realpath $(dirname $0))/utils.sh

BEEPER_REMOTE=$(get_beeper_remote)

VERSION=${1:-}

if [ -z "$VERSION" ]; then
echo >&2 "Must specify version!"
exit 1
fi

echo "Completing Synapse: Beeper Edition version $VERSION"
echo "WARNING: this script will DELETE the branch called: beeper"
read -p "Press enter to continue"

UPSTREAM_BRANCH=upstream-$VERSION
BEEPER_BRANCH=beeper-$VERSION

git checkout $BEEPER_BRANCH
git branch -D beeper
git checkout -b beeper
git push --force $BEEPER_REMOTE beeper

# Cleanup
git branch -D $BEEPER_BRANCH
git push $BEEPER_REMOTE --delete $BEEPER_BRANCH
git branch -D $UPSTREAM_BRANCH
git push $BEEPER_REMOTE --delete $UPSTREAM_BRANCH
43 changes: 43 additions & 0 deletions beeper/prepare_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -euo pipefail
source $(realpath $(dirname $0))/utils.sh

BEEPER_REMOTE=$(get_beeper_remote)

VERSION=${1:-}

if [ -z "$VERSION" ]; then
echo >&2 "Must specify version!"
exit 1
fi

STARTING_BRANCH=$(git branch --show-current)

echo "Preparing Synapse: Beeper Edition version $VERSION"
echo "WARNING: this script will rebase on top of the CURRENT BRANCH: $STARTING_BRANCH"
read -p "Press enter to continue"

TAG=v$VERSION
UPSTREAM_BRANCH=upstream-$VERSION
BEEPER_BRANCH=beeper-$VERSION

# Checkout the tag, create upstream branch, push it
echo "Setup branch $UPSTREAM_BRANCH"
git checkout -f $TAG
git checkout -b $UPSTREAM_BRANCH
git push -u $BEEPER_REMOTE $UPSTREAM_BRANCH

# Switch back to our starting branch, create new version branch from it
echo "Setup branch $BEEPER_BRANCH"
git checkout $STARTING_BRANCH
git checkout -b $BEEPER_BRANCH

# And rebase against upstream, applying only our Beeper commits
echo "Initiate rebase..."
git rebase $UPSTREAM_BRANCH || read -p "Rebase was a mess, press enter once you fix it"

git push -u $BEEPER_REMOTE $BEEPER_BRANCH

echo "OK we done!"
echo "Go HERE and make the PR: https://github.com/beeper/synapse/compare/upstream-$VERSION...beeper-$VERSION?expand=1"
23 changes: 23 additions & 0 deletions beeper/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function get_upstream_remote() {
for remote in $(git remote); do
url=$(git remote get-url $remote)
if [ "$url" = "[email protected]:element-hq/synapse.git" ]; then
echo $remote
return 0
fi
done
echo >&2 "No upstream remote found (looking for URL: [email protected]:element-hq/synapse.git)"
return 1
}

function get_beeper_remote() {
for remote in $(git remote); do
url=$(git remote get-url $remote)
if [ "$url" = "[email protected]:beeper/synapse.git" ]; then
echo $remote
return 0
fi
done
echo >&2 "No upstream remote found (looking for URL: [email protected]:beeper/synapse.git)"
return 1
}

0 comments on commit 2af3786

Please sign in to comment.