Skip to content

Create new release diffs #280

Create new release diffs

Create new release diffs #280

Workflow file for this run

name: Create new release diffs
on:
workflow_dispatch:
inputs:
version:
description: "The version of @backstage/create-app to release. If missing, the latest version will be used"
required: false
default: ""
releaseVersion:
description: "The version of Backstage to release."
required: false
jobs:
release:
name: Create release branch
runs-on: ubuntu-latest
env:
BACKSTAGE_APP_NAME: backstagediffapp
VERSION: ${{ github.event.inputs.version }}
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
# First check out master and run the script that figures out which version of create-app we should use
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Check out release base
uses: actions/checkout@v2
with:
ref: "release-base"
- name: Setup global git bot user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Run @backstage/create-app
run: printf "$BACKSTAGE_APP_NAME\n\t" | npx @backstage/create-app@${VERSION} --skip-install
- name: Remove git repository in app
run: rm -rf "$(pwd)/$BACKSTAGE_APP_NAME/.git"
- name: Check current directory
run: pwd
- name: Move all the files into the root directory
run: cp -ar $(pwd)/$BACKSTAGE_APP_NAME/. $(pwd)
- name: Setup git bot user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- id: check_branch
name: Check if branch already exists
run: |
SKIP_DIFF="true" && [[ -z "$(git ls-remote --heads origin release/${VERSION})" ]] && SKIP_DIFF="false"
echo "::set-output name=skip_create_diff::${SKIP_DIFF}"
- name: Add release
run: |
git checkout -b release/${VERSION}
git add .
git reset $BACKSTAGE_APP_NAME
git commit -m "Release ${VERSION}"
git push origin release/${VERSION}
if: steps.check_branch.outputs.skip_create_diff == 'false'
- run: echo "🍏 This job's status is ${{ job.status }}."
diff:
name: Create new diffs
runs-on: ubuntu-latest
needs: release
env:
RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }}
NEW_VERSION: ${{ github.event.inputs.version }}
steps:
- name: Check out diffs branch
uses: actions/checkout@v2
with:
ref: "master"
fetch-depth: 0
- name: Create new diffs
run: |
for version in $(jq -r 'to_entries |.[] | .value.createApp // .key' < releases.json); do
echo "Creating diffs between version $version and $NEW_VERSION"
git diff -U1 origin/release/$version..origin/release/$NEW_VERSION > diffs/$version..$NEW_VERSION.diff
done
- name: Add new version to release.json
run: |
if [ -z "$RELEASE_VERSION" ]; then
jq ".\"$NEW_VERSION\" = {}" < releases.json > _releases.json
else
jq ".\"$RELEASE_VERSION\" = { createApp: \"$NEW_VERSION\"}" < releases.json > _releases.json
fi
mv _releases.json releases.json
- name: Setup git bot user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Push the changes
run: |
git add .
git commit -m "Add release ${NEW_VERSION}"
git push