forked from Azure/communication-ui-library
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (101 loc) · 5.08 KB
/
create-release-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
# create release branch from pre-release branch
name: Create release branch from pre-release branch
on:
workflow_dispatch:
inputs:
branch:
description: 'Pre-release branch to release from'
type: string
required: true
# 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_release:
if: ${{ startsWith(github.event.inputs.branch, 'prerelease') }}
name: Create release branch
runs-on: ubuntu-latest
steps:
# Check-out repo
- uses: actions/checkout@v2
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: |
echo "running generation of release branch from ${{github.event.inputs.branch}}"
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 v14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
# Make sure that Rush is installed in run
- name: Add rush to run
run: npm i -g @microsoft/rush
# Ensure that node modules are installed
- name: Update rush to use node_modules
run: rush update
# get version number from communication react folder
- name: Retrieve new version from package.json
id: version
run: |
ver=$(jq -r .version packages/communication-react/package.json)
echo version: $ver
echo "::set-output name=version::$ver"
# Create new release branch
- name: Hop into new branch
id: releasebranch
run: |
git checkout -b release/${{ steps.version.outputs.version }}
echo "::set-output name=releasebranch::release/${{ steps.version.outputs.version }}"
- name: Force build flavor to `stable`
if: ${{ startsWith(github.event.inputs.branch, 'prerelease-stable-minor') || startsWith(github.event.inputs.branch, 'prerelease-stable-patch')}}
run: node ./common/scripts/force-build-flavor.mjs stable
- name: Force build flavor to `beta`
if: ${{ startsWith(github.event.inputs.branch, 'prerelease-beta' )}}
run: node ./common/scripts/force-build-flavor.mjs beta
# Synchronize the telemetry package versions.
- name: Synchronize package version reported to telemetry
run: node common/scripts/sync-telemetry-package-version
# we will want to run rush changelog with type none make sure that all packlets have change files
- name: Add beachball changelog
run: node ./common/config/node_modules/beachball/bin/beachball.js change -m Create release branch and update SDK versions --type none
# Commit new dependencies
- name: Commit changes
run: |
git add .
git commit -m "Selected stable sdk's for release branch"
git push -u origin ${{ steps.releasebranch.outputs.releasebranch }}
# Checkout back to pre-release branch
- name: Hop back to pre-release branch
run: git checkout ${{ github.event.inputs.branch }}
- name: Create pull request for pre-release back to main
run: |
curl \
-X POST \
-H 'Accept: application/vnd.github.v3+json' \
-H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
https://api.github.com/repos/Azure/communication-ui-library/pulls \
-d '{ "title":"${{ steps.version.outputs.version }} pre-release branch", "head":"${{ github.event.inputs.branch }}", "base":"main", "body":"Merge prerelease branch back into main. Version: ${{ steps.version.outputs.version }}. Created by the `Create release branch - create` GitHub action. Please review." }'
# if a stable release bump the package versions to beta.0 numbers for next beta release
- name: Bump versions for pre-release branch if stable release
if: ${{ startsWith(github.event.inputs.branch, 'prerelease-stable') }}
run: |
node common/scripts/bump-beta-version.js
rush update
git add .
git commit -m "Bump package versions to beta.0 for next release"
git push