Skip to content

Instantly share code, notes, and snippets.

@ksuderman
Created August 15, 2022 18:11
Show Gist options
  • Save ksuderman/c937d0e6804d39aa71ffda46e715c972 to your computer and use it in GitHub Desktop.
Save ksuderman/c937d0e6804d39aa71ffda46e715c972 to your computer and use it in GitHub Desktop.
Updates the GalaxyKubeman versions in Leo
#!/usr/bin/env bash
# Use this script to update the GalaxyKubeman Helm chart versions in Leo
#
# Put this script on your path and run from the root Leonardo source directory.
# > cd /home/user/leonardo
#
# USAGE
# > bumpleo <new version>
#
# EXAMPLE
# > bumpleo 2.0.0
#
# REQUIRED
# This script assumes that you have the GitHub CLI (gh) installed to create
# the pull request.
# See: https://github.com/cli/cli#installation
# The new version number
TO=$1
# Files to be updated
DOCKERFILE=Dockerfile
REFERENCE=http/src/main/resources/reference.conf
TEST=http/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/KubernetesTestData.scala
# The Git branches
BASE=develop
BRANCH=GalaxyKubeman-$TO
set -eu
# Get the current version from the Dockerfile.
FROM=$(cat $DOCKERFILE | awk '/ENV GALAXY_VERSION/{print $3}')
if [[ $FROM == $TO ]] ; then
echo "Already at version $TO"
exit 1
fi
TMP_FILE=$(mktemp -q)
function update_file() {
path=$1
pattern=$2
cat $path | sed "$pattern" > $TMP_FILE
mv $TMP_FILE $path
}
echo "Bumping GalaxyKubeman version from $FROM to $TO"
git checkout -b $BRANCH
update_file $DOCKERFILE "s/ENV GALAXY_VERSION $FROM/ENV GALAXY_VERSION $TO/"
update_file $REFERENCE "s/chartVersion = \"$FROM\"/chartVersion = \"$TO\"/"
update_file $TEST "s/val galaxyChartVersion = ChartVersion(\"$FROM\")/val galaxyChartVersion = ChartVersion(\"$TO\")/"
git add $DOCKERFILE $REFERENCE $TEST
git commit -m "Update GalaxyKubeman chart to version $TO"
# We need to push manually until `gh` supports pushing to a remote as part of
# the `gh pr create` process.
# See https://github.com/cli/cli/issues/1718
git push -u origin $BRANCH
gh pr create --base $BASE --title "Update GalaxyKubeman $FROM -> $TO" --body "Update GalaxyKubeman Helm chart to version $TO" --head $BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment