-
Notifications
You must be signed in to change notification settings - Fork 3
98 lines (96 loc) · 3.75 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
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