-
Notifications
You must be signed in to change notification settings - Fork 70
165 lines (147 loc) · 7.75 KB
/
create-prerelease-branch.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Bump package version numbers and bundle changelogs into changelog file
name: Create pre-release branch
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch or tag to create pre-release from'
required: true
default: 'main'
bump_type:
description: 'Bump type'
required: true
type: choice
options:
- stable-major
- stable-minor
- stable-patch
- stable-remove-beta-suffix
- beta-release-major
- beta-release-minor
- beta-release-patch
- beta-release-beta
# cancel workflow when a newer version of the workflow is triggered on the same github ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# create pre-release branch for beta releases
create_pre-release:
name: Bump versions and make changelog for release
runs-on: ${{ vars.RUNS_ON }}
permissions: read-all
steps:
# Check-out repo
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Use a machine account when checking out. This is to workaround the issue were GitHub
# actions, when using the default account, cannot trigger other actions. And we want this
# action to trigger the regular CI pipeline on the created branch.
# This machine account is only for this PAT, pwd was created and thrown away
# If any update needed, create a new account, add access to the repo and generate a new PAT
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
# Setup bot information for creating pull request
# Here we use the id from the github actions bot: https://api.github.com/users/better-informatics%5Bbot%5D
- name: Setup bot git information
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
# Check out onto desired branch or tag to create release from
- name: Checkout tag/branch
run: git checkout ${{ github.event.inputs.branch }}
# Ensure node version is great enough
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
# Try get node_modules from cache
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
# Install dependencies
- name: Install rush
run: npm install -g @microsoft/rush@$(jq -r '.rushVersion' "rush.json")
- name: Install dependencies
run: rush install --max-install-attempts 3
# ####################################################################
# Create pre-release branch
#
# Bump versions first so we can use the new version in the branch name.
- name: Bump beta release major package version
if: ${{ github.event.inputs.bump_type == 'beta-release-major' }}
run: node common/scripts/bump-beta-release-version.js major
- name: Bump beta release minor package version
if: ${{ github.event.inputs.bump_type == 'beta-release-minor' }}
run: node common/scripts/bump-beta-release-version.js minor
- name: Bump beta release patch package version
if: ${{ github.event.inputs.bump_type == 'beta-release-patch' }}
run: node common/scripts/bump-beta-release-version.js patch
- name: Bump beta release beta package version
if: ${{ github.event.inputs.bump_type == 'beta-release-beta' }}
run: node common/scripts/bump-beta-release-version.js beta
- name: Bump stable major package versions
if: ${{ github.event.inputs.bump_type == 'stable-major' }}
run: node common/scripts/bump-stable-version.js major
- name: Bump stable minor package versions
if: ${{ github.event.inputs.bump_type == 'stable-minor' }}
run: node common/scripts/bump-stable-version.js minor
- name: Bump stable patch package versions
if: ${{ github.event.inputs.bump_type == 'stable-patch' }}
run: node common/scripts/bump-stable-version.js patch
- name: Remove beta version from stable package versions
if: ${{ github.event.inputs.bump_type == 'stable-remove-beta-suffix' }}
run: node common/scripts/bump-stable-version.js remove-beta
# Retrieve new version so we can use it in the branch name.
- name: Retrieve new version from package.json
id: version
run: |
ver=$(jq -r .version packages/communication-react/package.json)
echo version: $ver
echo "version=$ver" >> $GITHUB_OUTPUT
- name: Hop into new branch before comitting changes
id: prereleasebranch
run: |
git checkout -b prerelease-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}
echo "prereleasebranch=prerelease-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
- name: Commit package version bump
run: |
git add .
git commit -m "${{github.event.inputs.bump_type}} version bump"
- name: Generate beta CHANGELOG
if: ${{ github.event.inputs.bump_type == 'beta-release-major' || github.event.inputs.bump_type == 'beta-release-minor' || github.event.inputs.bump_type == 'beta-release-patch' || github.event.inputs.bump_type == 'beta-release-beta' }}
run: node common/scripts/changelog/collect.mjs beta
- name: Generate stable CHANGELOG
if: ${{ github.event.inputs.bump_type == 'stable-major' || github.event.inputs.bump_type == 'stable-minor' || github.event.inputs.bump_type == 'stable-patch' || github.event.inputs.bump_type == 'stable-remove-beta-suffix' }}
run: node common/scripts/changelog/collect.mjs stable
- name: sanity check - ensure all package versions are consistent
run: rush ensure-consistent-versions
- name: Push new branch to remote
run: git push -u origin "${{ steps.prereleasebranch.outputs.prereleasebranch }}"
# ####################################################################
# Create a PR to groom the CHANGELOG
#
- name: Hop into new branch
id: groombranch
run: |
git checkout -b groom-changelog-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}
echo "groombranch=groom-changelog-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
- name: Add trivial changefile so CI does not complain about the CHANGELOG grooming PR
run: |
echo "Please create a changelog manually with message - Bumped versions for release"
echo "This is no longer possible due to changes to beachball. Use rushx changelog to create the file."
# Push groom changes
- name: Create groom file and push changes
run: |
echo 'Please groom the changelog and then delete me.' > GROOMME.md
git add .
git commit -m 'Create groom me file for groom changelog branch'
git push -u origin ${{ steps.groombranch.outputs.groombranch }}
- name: REMOVED - DO THIS MANUALLY! Create PR of changelog branch to pre-release branch
run: |
echo "Creating pull requests by GitHub Action is no longer supported per Microsoft Open Source Security Policy."
echo "Please create a pull request manually from ${{ steps.groombranch.outputs.groombranch }} to ${{ steps.prereleasebranch.outputs.prereleasebranch }}."
echo "In the PR description please include the following text: `Please groom CHANGELOG.md in this branch`."
echo "See example: https://github.com/Azure/communication-ui-library/pull/2694"