-
Notifications
You must be signed in to change notification settings - Fork 16
209 lines (191 loc) · 9.19 KB
/
next-release-minor.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# Preamble
name: Create next minor release
on:
release:
types: [released]
# enable worflow to be run manually
workflow_dispatch:
jobs:
get-environment-variables:
outputs:
release-version: ${{ steps.job-outputs-step.outputs.release-version }}
new-release-version: ${{ steps.job-outputs-step.outputs.new-release-version }}
minor-version: ${{ steps.job-outputs-step.outputs.minor-version }}
milestone-number: ${{ steps.job-outputs-step.outputs.milestone-number }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Get most recent release version
run: |
echo "RELEASE_VERSION=$(gh api repos/${{ github.repository }}/tags --jq '.[0] | .name')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Increment minor version
run: |
IFS='.' read -ra arr <<< ${{ env.RELEASE_VERSION }}
MINOR_VERSION=$((${arr[1]}+1))
arr[1]=$MINOR_VERSION
NEW_RELEASE_VERSION="${arr[0]}.${arr[1]}.${arr[2]}"
echo "MINOR_VERSION="$MINOR_VERSION >> $GITHUB_ENV
echo "NEW_RELEASE_VERSION="$NEW_RELEASE_VERSION >> $GITHUB_ENV
- name: "Check for existing ${{ env.NEW_RELEASE_VERSION }} draft release"
run: |
RELEASES=$(gh api repos/${{ github.repository }}/releases \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .name')
if [[ $RELEASES =~ ${{ env.NEW_RELEASE_VERSION }} ]]
then
echo "Release exists"
else
gh api repos/${{ github.repository }}/releases \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
-F name=${{ env.NEW_RELEASE_VERSION }} \
-F tag_name=${{ env.NEW_RELEASE_VERSION }} \
-F draft=true
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Check for existing ${{ env.NEW_RELEASE_VERSION }} milestone"
run: |
MILESTONES=$(gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .title')
if [[ $MILESTONES =~ ${{ env.NEW_RELEASE_VERSION }} ]]
then
echo "Milestone exists"
else
gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
-F title=${{ env.NEW_RELEASE_VERSION }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Get milestone number for ${{ env.NEW_RELEASE_VERSION }}"
run: |
mapfile -t MILESTONE_NAMES < <(gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .title')
mapfile -t MILESTONE_NUMBERS < <(gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .number')
for i in ${!MILESTONE_NAMES[@]}
do
if [[ ${MILESTONE_NAMES[$i]} == ${{ env.NEW_RELEASE_VERSION }} ]]
then
INDEX=$i
fi
done
echo "MILESTONE_NUMBER="${MILESTONE_NUMBERS[$INDEX]} >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get job outputs
id: job-outputs-step
run: |
echo "::set-output name=release-version::${{ env.RELEASE_VERSION }}"
echo "::set-output name=minor-version::${{ env.MINOR_VERSION }}"
echo "::set-output name=new-release-version::${{ env.NEW_RELEASE_VERSION }}"
echo "::set-output name=milestone-number::${{ env.MILESTONE_NUMBER }}"
make-next-version-inital-pr:
needs: get-environment-variables
env:
RELEASE_VERSION: ${{ needs.get-environment-variables.outputs.release-version }}
NEW_RELEASE_VERSION: ${{ needs.get-environment-variables.outputs.new-release-version }}
MINOR_VERSION: ${{ needs.get-environment-variables.outputs.minor-version }}
MILESTONE_NUMBER: ${{ needs.get-environment-variables.outputs.milestone-number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: master
- name: "Make initial changes for ${{ env.NEW_RELEASE_VERSION }}"
run: |
echo "Update version.py"
sed -i "s/_version_micro = '*[0-9]*'*/_version_micro = ''/g" saltproc/version.py
sed -i "s/_version_minor = [0-9]*/_version_minor = ${{ env.MINOR_VERSION }}/g" saltproc/version.py
sed -i "s/^# _version_extra = 'dev'/_version_extra = 'dev'/g" saltproc/version.py
sed -i "s/^_version_extra = '0'/# _version_extra = '0'/g" saltproc/version.py
echo "Create new release notes"
cp doc/releasenotes/template.rst doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
sed -i "s/vx.x.x/${{ env.NEW_RELEASE_VERSION }}/g" doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
sed -i "s/${{ env.RELEASE_VERSION }}/${{ env.NEW_RELEASE_VERSION }}\n ${{ env.RELEASE_VERSION }}/g" doc/releasenotes/index.rst
- name: "Create PR containing inital changes for ${{ env.NEW_RELEASE_VERSION }}"
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: master
add-paths: |
saltproc/version.py
doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
doc/releasenotes/index.rst
branch: "${{ env.NEW_RELEASE_VERSION }}-init"
delete-branch: true
commit-message: "inital changes for ${{ env.NEW_RELEASE_VERSION }}"
title: "[INIT] Update `version.py` and create release notes for version ${{ env.NEW_RELEASE_VERSION }}"
body: "This is an automated PR that updates the version number and creates the release notes file for version ${{ env.NEW_RELEASE_VERSION }}. This should be the first PR merged during development of version ${{ env.NEW_RELEASE_VERSION }}"
reviewers: yardasol
milestone: ${{ env.MILESTONE_NUMBER }}
labels: |
Priority:1-Critical
Status:5-In Review
Type:Style
Type:Docs
Difficulty:1-Beginner
Comp:Build
make-next-version-final-pr:
needs: [get-environment-variables, make-next-version-inital-pr]
env:
NEW_RELEASE_VERSION: ${{ needs.get-environment-variables.outputs.new-release-version }}
MILESTONE_NUMBER: ${{ needs.get-environment-variables.outputs.milestone-number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: master
- name: Get changes from the INIT PR
run: |
git pull origin ${{ env.NEW_RELEASE_VERSION }}-init
- name: "Make changes necessary for publishing ${{ env.NEW_RELEASE_VERSION }} in advance"
run: |
echo "Prepare for full release"
sed -i "s/\.\. note:: These release notes are currently in production\.//g" doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
sed -i "s/^_version_extra = 'dev'/# _version_extra = 'dev'/g" saltproc/version.py
sed -i "s/# _version_extra = '0'/_version_extra = '0'/g" saltproc/version.py
- name: "Create PR containing changes necessary for publishing ${{ env.NEW_RELEASE_VERSION }}"
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: master
add-paths: |
saltproc/version.py
doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
doc/releasenotes/index.rst
branch: "${{ env.NEW_RELEASE_VERSION }}-final"
delete-branch: true
commit-message: "final changes before publishing ${{ env.NEW_RELEASE_VERSION }}"
title: "[REQUIRED FOR PUBLISHING] Finishing touches for version ${{ env.NEW_RELEASE_VERSION }}"
body: "This is an automated PR that updates the version number and release notes in preparation for the full release of version ${{ env.NEW_RELEASE_VERSION }}. This should be last PR merged before publishing version ${{ env.NEW_RELEASE_VERSION }}. Rebasing this PR on top of the most recent commit in `master` is a prequisite of publishing version ${{ env.NEW_RELEASE_VERSION }}. We rebase becasue the commits in this PR were created around the same time development on ${{ env.NEW_RELEASE_VERSION }} began."
reviewers: yardasol
milestone: ${{ env.MILESTONE_NUMBER }}
labels: |
Priority:2-Normal
Status:1-New
Type:Style
Type:Docs
Difficulty:1-Beginner
Comp:Build