Skip to content

Commit 3449ec1

Browse files
authored
Update workflow to push the diff in branches (#8)
* refactor worfklow to use the new diff branches Signed-off-by: Vincenzo Scamporlino <[email protected]> * bump setup-node action Signed-off-by: Vincenzo Scamporlino <[email protected]> * adjust yarn plugin filter Signed-off-by: Vincenzo Scamporlino <[email protected]> * fetch required branches Signed-off-by: Vincenzo Scamporlino <[email protected]> * creating missing diffs dir and optimize branch fetch Signed-off-by: Vincenzo Scamporlino <[email protected]> --------- Signed-off-by: Vincenzo Scamporlino <[email protected]>
1 parent 7202a3e commit 3449ec1

File tree

1 file changed

+43
-22
lines changed

1 file changed

+43
-22
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@ jobs:
1919
RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }}
2020
steps:
2121
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
22-
23-
# First check out master and run the script that figures out which version of create-app we should use
24-
- name: Check out repository code
25-
uses: actions/checkout@v5
26-
with:
27-
sparse-checkout: .
28-
- uses: actions/setup-node@v2
29-
with:
30-
node-version: 20
3122
- name: Check out release base
3223
uses: actions/checkout@v5
3324
with:
3425
ref: "release-base"
26+
- uses: actions/setup-node@v6
27+
with:
28+
node-version: 20
3529
- name: Setup global git bot user
3630
run: |
3731
git config --global user.name "github-actions[bot]"
@@ -95,14 +89,51 @@ jobs:
9589
- name: Check out diffs branch
9690
uses: actions/checkout@v5
9791
with:
98-
ref: "master"
99-
fetch-depth: 0
92+
ref: "release-diff-base"
93+
- name: Checkout new branch for release ${NEW_VERSION}
94+
run: git checkout -b release-diff/legacy/v${NEW_VERSION}
95+
- name: Setup git bot user
96+
run: |
97+
git config user.name "github-actions[bot]"
98+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
10099
- name: Create new diffs
101100
run: |
102-
for version in $(jq -r 'to_entries |.[] | .value.createApp // .key' < releases.json); do
101+
mkdir diffs
102+
git fetch origin release/$NEW_VERSION
103+
for version in $(curl -s https://raw.githubusercontent.com/backstage/upgrade-helper-diff/master/releases.json | jq -r 'to_entries | .[] | .value.createApp // .key'); do
103104
echo "Creating diffs between version $version and $NEW_VERSION"
105+
git fetch origin release/$version
104106
git diff -U1 origin/release/$version..origin/release/$NEW_VERSION > diffs/$version..$NEW_VERSION.diff
105107
done
108+
- name: Create new branch with diff files for release ${NEW_VERSION}
109+
run: |
110+
git add .
111+
git commit -m "Add release ${NEW_VERSION}"
112+
git push origin release-diff/legacy/v${NEW_VERSION}
113+
- name: Check out diffs branch again for yarn plugin
114+
uses: actions/checkout@v5
115+
with:
116+
ref: "release-diff-base"
117+
- name: Checkout new branch for release ${RELEASE_VERSION} with yarn plugin
118+
run: git checkout -b release-diff/v${RELEASE_VERSION}
119+
- name: Create new diffs for yarn plugin
120+
run: |
121+
mkdir diffs
122+
git fetch origin release/yarn-plugin/$RELEASE_VERSION
123+
for version in $(curl -s https://raw.githubusercontent.com/backstage/upgrade-helper-diff/master/releases-yarn-plugin.json | jq -r 'to_entries |.[] | .key'); do
124+
echo "Creating yarn-plugin diffs between version $version and $RELEASE_VERSION"
125+
git fetch origin release/yarn-plugin/$version
126+
git diff -U1 origin/release/yarn-plugin/$version..origin/release/yarn-plugin/$RELEASE_VERSION > diffs/$version..$RELEASE_VERSION.diff
127+
done
128+
- name: Push the changes
129+
run: |
130+
git add .
131+
git commit -m "Add release ${NEW_VERSION}"
132+
git push origin release-diff/v${RELEASE_VERSION}
133+
- name: Check out default branch
134+
uses: actions/checkout@v5
135+
with:
136+
ref: "master"
106137
- name: Add new version to release.json
107138
run: |
108139
if [ -z "$RELEASE_VERSION" ]; then
@@ -111,20 +142,10 @@ jobs:
111142
jq ".\"$RELEASE_VERSION\" = { createApp: \"$NEW_VERSION\" }" < releases.json > _releases.json
112143
fi
113144
mv _releases.json releases.json
114-
- name: Create new diffs for yarn plugin
115-
run: |
116-
for version in $(jq -r 'to_entries |.[] | .key' < releases-yarn-plugin.json); do
117-
echo "Creating yarn-plugin diffs between version $version and $RELEASE_VERSION"
118-
git diff -U1 origin/release/yarn-plugin/$version..origin/release/yarn-plugin/$RELEASE_VERSION > diffs-yarn-plugin/$version..$RELEASE_VERSION.diff
119-
done
120145
- name: Add new version to releases-yarn-plugin.json
121146
run: |
122147
jq ".\"$RELEASE_VERSION\" = { createApp: \"$NEW_VERSION\" }" < releases-yarn-plugin.json > _releases-yarn-plugin.json
123148
mv _releases-yarn-plugin.json releases-yarn-plugin.json
124-
- name: Setup git bot user
125-
run: |
126-
git config user.name "github-actions[bot]"
127-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
128149
- name: Push the changes
129150
run: |
130151
git add .

0 commit comments

Comments
 (0)