-
Notifications
You must be signed in to change notification settings - Fork 234
119 lines (114 loc) · 5.17 KB
/
version-bump.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
name: 'Version Bump'
on:
workflow_dispatch:
inputs:
release_line:
description: 'Release Line'
required: true
default: next
type: choice
options:
- next
- main
# Run Weekly on Wednesday at 10:00 UTC time
schedule:
- cron: "0 10 * * 3"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
version-bump:
runs-on: ubuntu-latest
steps:
- name: 'Checkout backstage'
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
fetch-depth: 1
# Beginning of yarn setup
- name: use node.js 20.x
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org/ # Needed for auth
- name: cache all node_modules
id: cache-modules
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}
- name: find location of global yarn cache
id: yarn-cache
if: steps.cache-modules.outputs.cache-hit != 'true'
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: cache global yarn cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
if: steps.cache-modules.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
run: yarn install --immutable
# End of yarn setup
- name: 'Set release name'
id: set_release_name
run: node scripts/set-release-name.js
- name: 'Configure git'
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: 'Create topic branch'
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
BRANCH=$(git branch --list topic/v${{ steps.set_release_name.outputs.release_version }})
if [ ! -z "$BRANCH" ]; then
git branch -D topic/v${{ steps.set_release_name.outputs.release_version }}
fi
git checkout -b topic/v${{ steps.set_release_name.outputs.release_version }}
- name: Run backstage-cli versions:bump --release ${{ inputs.release_line || 'next' }} command
run: yarn backstage-cli versions:bump --release ${{ inputs.release_line || 'next' }}
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: 'Check for changes'
id: check_for_changes
run: |
CHANGES=$(git status --porcelain)
if [ -z "$CHANGES" ]; then
echo "No changes"
echo "HAS_CHANGES=0" >> $GITHUB_OUTPUT
else
echo "Has changes"
echo "HAS_CHANGES=1" >> $GITHUB_OUTPUT
fi
- name: 'Commit changes'
if: ${{ steps.check_for_changes.outputs.HAS_CHANGES == 1 }}
run: |
git status
git add -A -- :!.npmrc
git commit -m "v${{ steps.set_release_name.outputs.release_version }} version bump"
git push origin topic/v${{ steps.set_release_name.outputs.release_version }}
- name: 'Create Pull Request'
if: ${{ steps.check_for_changes.outputs.HAS_CHANGES == 1 }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
github-token: ${{secrets.GH_SERVICE_ACCOUNT_TOKEN}}
script: |
await github.rest.pulls.create({
title: 'v${{ steps.set_release_name.outputs.release_version }} version bump',
owner: context.repo.owner,
repo: context.repo.repo,
head: 'topic/v${{ steps.set_release_name.outputs.release_version }}',
base: 'master',
body: [
'Backstage release v${{ steps.set_release_name.outputs.release_version }} has been published, this Pull Request contains the changes to upgrade to this new release',
' ',
'Please review the changelog before approving, there may be manual changes needed to enable new features:',
' ',
'- Changelog: [v${{ steps.set_release_name.outputs.release_version }}](https://github.com/backstage/backstage/blob/master/docs/releases/v${{ steps.set_release_name.outputs.release_version }}-changelog.md)',
'- Upgrade Helper: [From ${{ steps.set_release_name.outputs.current_version }} to ${{ steps.set_release_name.outputs.release_version }}](https://backstage.github.io/upgrade-helper/?from=${{ steps.set_release_name.outputs.current_version }}&to=${{ steps.set_release_name.outputs.release_version }})',
' ',
'Created by [Version Bump ${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})',
' '
].join('\n')
});