-
Notifications
You must be signed in to change notification settings - Fork 3
130 lines (128 loc) · 5.58 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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