Skip to content

Instantly share code, notes, and snippets.

@devinivy
Last active May 25, 2021 14:44
Show Gist options
  • Save devinivy/d0d403c85ba8e2b1eb59f01a6b497a24 to your computer and use it in GitHub Desktop.
Save devinivy/d0d403c85ba8e2b1eb59f01a6b497a24 to your computer and use it in GitHub Desktop.
Publish a hapi pal flavor
#!/usr/bin/env bash
branch=$(git symbolic-ref --short HEAD)
version=$1
if ! [[ $branch =~ ^flavor- ]]; then
echo "Not on a flavor branch" >&2
exit 1
fi
if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Not a valid version" >&2
exit 1
fi
flavor="${branch/flavor-/}";
echo $branch;
echo $flavor;
echo $version;
rm package-lock.json
git reset origin/pal # See the changes as they appear on top of the main pal branch
git checkout --detach # Leave the current branch– at this point we dont need to update any branch
git add . # List updated files
git reset $0 # Ignore this script file
git commit -m "(flavor) $flavor v$version" # Create the squashed commit
git tag -a "$flavor-v$version" -m "(flavor) $flavor v$version" # Tag it with its version
git tag --force -a $flavor -m "(flavor) $flavor v$version" # Tag it for convenience, overriding the previous
git push origin "$flavor-v$version" # Push versioned tag
git push --delete origin $flavor # Remove single tagged commit on the pal repo—we're about to replace it!
git push origin $flavor # Push the single tagged commit up to the pal repo
# Ensure flavor and pal branch are up-to-date locally
git checkout flavor-<name> # Go to the flavor branch
git merge pal/pal # Ensure we're not squashing irrelevant changes, e.g. to the readme
git push pal flavor-<name> # Push the updated flavor branch

git reset pal/pal # See the changes as they appear on top of the main pal branch
git checkout --detach # Leave the current branch– at this point we dont need to update any branch
git add ... # List updated files
git commit -m "(flavor) <name> v<major>.<minor>.<patch>" # Create the squashed commit

git tag -a <name>-v<major>.<minor>.<patch> -m "(flavor) <name> v<major>.<minor>.<patch>" # Tag it with its version
git tag --force -a <name> -m "(flavor) <name> v<major>.<minor>.<patch>" # Tag it for convenience, overridding the previous

git push pal <name>-v<major>.<minor>.<patch> # Push versioned tag
git push --delete pal <name> # Remove single tagged commit on the pal repo—we're about to replace it!
git push pal <name> # Push the single tagged commit up to the pal repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment