diff --git a/contrib/scripts/upgrade-backstage-app/README.md b/contrib/scripts/upgrade-backstage-app/README.md new file mode 100644 index 0000000000..ea8b0a0e2f --- /dev/null +++ b/contrib/scripts/upgrade-backstage-app/README.md @@ -0,0 +1,30 @@ +# Upgrade Backstage App + +## Overview + +The script upgrades the version of Backstage created via the create-app plugin. It lets you resolve conflicts iteratively with your own merge [tool](https://www.git-scm.com/docs/git-mergetool). + +## Requirements + +You will need to have the following tools in your shell environment: + +- git +- curl +- jq + +## Usage + +Here's how to use the script: + +1. download the script +2. copy it in the root of your app +3. bootstrap a git repository (you may already have done so): + +```bash +git init +git add . +git commit -m "initial commit" +``` + +4. run `sh upgrade-backstage-app.sh [optional-backstage-version]` +5. resolve any conflicts iteratively diff --git a/contrib/scripts/upgrade-backstage-app/upgrade-backstage-app.sh b/contrib/scripts/upgrade-backstage-app/upgrade-backstage-app.sh new file mode 100755 index 0000000000..d68d9e31c4 --- /dev/null +++ b/contrib/scripts/upgrade-backstage-app/upgrade-backstage-app.sh @@ -0,0 +1,15 @@ +#!/bin/sh +CURRENT_VERSION="v$(cat backstage.json | jq -r '.version')" +TARGET_VERSION=${1:-"$(curl -s https://api.github.com/repos/backstage/backstage/releases/latest | jq -r '.tag_name')"} +CREATE_APP_CURRENT_VERSION=$(curl -s https://raw.githubusercontent.com/backstage/backstage/$CURRENT_VERSION/packages/create-app/package.json | jq -r '.version') +CREATE_APP_TARGET_VERSION=$(curl -s https://raw.githubusercontent.com/backstage/backstage/$TARGET_VERSION/packages/create-app/package.json | jq -r '.version') + +if [ "$CURRENT_VERSION" == "$TARGET_VERSION" ]; then + echo "Already up to date" +else + echo "Attempting upgrade from Backstage $CURRENT_VERSION (create-app $CREATE_APP_CURRENT_VERSION) to $TARGET_VERSION ($CREATE_APP_TARGET_VERSION)" + rm -rf .upgrade && mkdir .upgrade + curl -s https://raw.githubusercontent.com/backstage/upgrade-helper-diff/master/diffs/$CREATE_APP_CURRENT_VERSION..$CREATE_APP_TARGET_VERSION.diff > .upgrade/upgrade.diff + git apply -3 .upgrade/upgrade.diff + git mergetool +fi