Create new release diffs #317
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | |
RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }} | |
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: 20 | |
- 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: Create branch for release ${VERSION} | |
if: steps.check_branch.outputs.skip_create_diff == 'false' | |
run: | | |
git checkout -b release/${VERSION} | |
git add . | |
git reset $BACKSTAGE_APP_NAME | |
git commit -m "Release ${VERSION}" | |
git push origin release/${VERSION} | |
- id: check_yarn_plugin_branch | |
name: Check if yarn plugin branch already exists | |
run: | | |
SKIP_DIFF="true" && [[ -z "$(git ls-remote --heads origin release/yarn-plugin/${RELEASE_VERSION})" ]] && SKIP_DIFF="false" | |
echo "::set-output name=skip_create_diff::${SKIP_DIFF}" | |
- name: Install yarn plugin | |
run: | | |
yarn plugin import https://versions.backstage.io/v1/tags/next/yarn-plugin | |
- name: Run versions:bump to migrate to backstage:^ versions | |
run: | | |
npx @backstage/cli@latest versions:bump --release $RELEASE_VERSION | |
env: | |
YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
- name: Create branch for release ${RELEASE_VERSION} with yarn plugin installed | |
if: steps.check_yarn_plugin_branch.outputs.skip_create_diff == 'false' | |
run: | | |
git checkout -b release/yarn-plugin/${RELEASE_VERSION} | |
git add . | |
git reset $BACKSTAGE_APP_NAME yarn.lock | |
git commit -m "Release ${RELEASE_VERSION}" | |
git push origin release/yarn-plugin/${RELEASE_VERSION} | |
- 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: Create new diffs for yarn plugin | |
run: | | |
for version in $(jq -r 'to_entries |.[] | .key' < releases-yarn-plugin.json); do | |
echo "Creating yarn-plugin diffs between version $version and $RELEASE_VERSION" | |
git diff -U1 origin/release/yarn-plugin/$version..origin/release/yarn-plugin/$RELEASE_VERSION > diffs-yarn-plugin/$version..$RELEASE_VERSION.diff | |
done | |
- name: Add new version to releases-yarn-plugin.json | |
run: | | |
jq ".\"$RELEASE_VERSION\" = { createApp: \"$NEW_VERSION\" }" < releases-yarn-plugin.json > _releases-yarn-plugin.json | |
mv _releases-yarn-plugin.json releases-yarn-plugin.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 |