-
Notifications
You must be signed in to change notification settings - Fork 21
176 lines (157 loc) · 7.68 KB
/
prepare-for-minor-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
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
166
167
168
169
170
171
172
173
174
175
176
name: Prepare repository for new minor release
run-name: Update az_quickstart repository for new `${{ inputs.release_branch_name }}` minor release branch.
on:
workflow_dispatch:
inputs:
release_branch_name:
description: The name of the new release branch (e.g. 2.8.x) to create.
required: true
jobs:
print_inputs:
runs-on: ubuntu-latest
steps:
- name: Print inputs
run: |
echo "release_branch_name: ${{ inputs.release_branch_name }}"
branch_name_prep:
timeout-minutes: 10
runs-on: ubuntu-latest
outputs:
next_minor_release: ${{ steps.define-version-variables.outputs.NEXT_MINOR_RELEASE }}
next_release_branch_alias_constraint: ${{ steps.define-version-variables.outputs.NEXT_RELEASE_VERSION_CONSTRAINT }}
this_release_branch_alias_constraint: ${{ steps.define-version-variables.outputs.THIS_RELEASE_VERSION_CONSTRAINT }}
main_branch_alias: ${{ steps.define-version-variables.outputs.MAIN_BRANCH_ALIAS }}
steps:
- name: Define version variables
id: define-version-variables
run: |
delimiter=.
version_parts=($(echo ${{ inputs.release_branch_name }} | tr $delimiter '\n'))
version_parts[1]=$((version_parts[1]+1))
NEXT_MINOR_RELEASE=$(IFS=$delimiter ; echo "${version_parts[*]}" | sed 's/\(.*\)\.x/\1/')
NEXT_RELEASE_VERSION_CONSTRAINT="~${NEXT_MINOR_RELEASE}"
echo "NEXT_MINOR_RELEASE=${NEXT_MINOR_RELEASE}" >> $GITHUB_OUTPUT
echo "NEXT_RELEASE_VERSION_CONSTRAINT=${NEXT_RELEASE_VERSION_CONSTRAINT}" >> $GITHUB_OUTPUT
echo "Next minor release: $NEXT_MINOR_RELEASE" >> $GITHUB_STEP_SUMMARY
echo "Next release version constraint: $NEXT_RELEASE_VERSION_CONSTRAINT" >> $GITHUB_STEP_SUMMARY
THIS_RELEASE_VERSION_CONSTRAINT=$(echo ${{ inputs.release_branch_name }} | sed 's/\(.*\)\.x/~\1/')
echo "THIS_RELEASE_VERSION_CONSTRAINT=${THIS_RELEASE_VERSION_CONSTRAINT}" >> $GITHUB_OUTPUT
echo "This release version constraint: $THIS_RELEASE_VERSION_CONSTRAINT" >> $GITHUB_STEP_SUMMARY
MAIN_BRANCH_ALIAS="${NEXT_MINOR_RELEASE}.x-dev"
echo "MAIN_BRANCH_ALIAS=${MAIN_BRANCH_ALIAS}" >> $GITHUB_OUTPUT
echo "Main branch alias: $MAIN_BRANCH_ALIAS" >> $GITHUB_STEP_SUMMARY
dispatch:
needs: branch_name_prep
strategy:
matrix:
repo:
- az-digital/az-quickstart-scaffolding
runs-on: ubuntu-latest
steps:
- name: Notify dependencies
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: ${{ matrix.repo }}
event-type: az_quickstart_prep_for_minor_release
client-payload: '{"release_branch_name": "${{ inputs.release_branch_name }}" , "this_release_branch_alias_constraint": "${{needs.branch_name_prep.outputs.this_release_branch_alias_constraint}}", "main_branch_alias": "${{needs.branch_name_prep.outputs.main_branch_alias}}", "next_release_branch_alias_constraint": "${{needs.branch_name_prep.outputs.next_release_branch_alias_constraint}}"}'
prepare_for_new_minor_release:
name: Prepare for a new minor release
runs-on: ubuntu-latest
needs: branch_name_prep
steps:
- name: Checkout az_quickstart
uses: actions/checkout@v4
with:
repository: az-digital/az_quickstart
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create and check out release branch
run: |
git checkout -b ${{ inputs.release_branch_name }}
- name: Set up git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Push new release branch to GitHub
run: |
git commit --allow-empty -m "Prepare for new minor release ${{ inputs.release_branch_name }}"
git push origin -u ${{ inputs.release_branch_name }}
- name: Update DDev config in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "0,/main/s//$NEW_VERSION/" .ddev/commands/web/install
- name: Update Security workflow yml in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "s/SCAFFOLD_BRANCH=main/SCAFFOLD_BRANCH=$NEW_VERSION/g" .github/workflows/security.yml
- name: Update Create Release workflow yml in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "s|git clone https://github.com/az-digital/az-quickstart-scaffolding.git az_quickstart|git clone -b $NEW_VERSION https://github.com/az-digital/az-quickstart-scaffolding.git az_quickstart|" .github/workflows/create-release.yml
- name: Update Lando config in release branch
run: |
sed -i 's|SCAFFOLD_BRANCH="main"|SCAFFOLD_BRANCH="${{ inputs.release_branch_name }}"|g' .lando.yml
- name: Update Probo config in release branch
run: |
NEW_VERSION=${{ inputs.release_branch_name }}
sed -i "s/SCAFFOLD_BRANCH=main/SCAFFOLD_BRANCH=$NEW_VERSION/g" .probo.yaml
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2
- name: Update dev branch alias via Composer
run: |
composer config extra.branch-alias.dev-main ${{ needs.branch_name_prep.outputs.next_minor_release }}.x-dev
- name: Create pull request for new release branch updates
uses: peter-evans/create-pull-request@v5
with:
title: Prepare repository for new minor release branch ${{ inputs.release_branch_name }}
commit-message: Prepare repository for new minor release branch ${{ inputs.release_branch_name }}
branch: ${{ inputs.release_branch_name }}-prepare-for-minor-release
base: ${{ inputs.release_branch_name }}
delete-branch: true
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
labels: |
${{ inputs.release_branch_name }} only
add-paths: |
.ddev/commands/web/install
.github/workflows/security.yml
.github/workflows/create-release.yml
.lando.yml
.probo.yaml
composer.json
update_previous_release_branches:
needs: [prepare_for_new_minor_release, branch_name_prep]
runs-on: ubuntu-latest
name: Update `${{ matrix.previous_version }}` release branch.
strategy:
matrix:
previous_version: [2.7.x, 2.6.x, 2.5.x, 2.4.x, 2.3.x, 2.2.x, 2.1.x, 2.0.x]
steps:
- name: Update previous release branch `${{ matrix.previous_version }}`
uses: actions/checkout@v4
with:
ref: ${{ matrix.previous_version }}
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
- name: Set up Git
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
- name: Update dev branch alias via Composer
run: |
composer config extra.branch-alias.dev-main ${{ needs.branch_name_prep.outputs.next_minor_release }}.x-dev
- name: Create pull request for previous release branch updates
uses: peter-evans/create-pull-request@v5
with:
title: Prepare ${{ matrix.previous_version }} branch for new minor release branch ${{ inputs.release_branch_name }}
commit-message: Prepare ${{ matrix.previous_version }} branch for new minor release branch ${{ inputs.release_branch_name }}
branch: update-${{ matrix.previous_version }}-for-${{ inputs.release_branch_name }}
base: ${{ matrix.previous_version }}
delete-branch: true
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
labels: |
${{ matrix.previous_version }} only
add-paths: |
composer.json