Merge pull request #13888 from matteosilv/upgrade-backstage-script

add upgrade-backstage-app.sh script to contrib
This commit is contained in:
Johan Haals
2022-09-29 09:39:37 +02:00
committed by GitHub
2 changed files with 45 additions and 0 deletions
@@ -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
@@ -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