Skip to content

Commit 8215e30

Browse files
committed
Add rel-eng notebook
1 parent 1a4117e commit 8215e30

File tree

2 files changed

+367
-0
lines changed

2 files changed

+367
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Gemfile.local
1212
.ruby-gemset
1313

1414
.DS_Store
15+
rel-eng/.ipynb_checkpoints

rel-eng/gem_release.ipynb

Lines changed: 366 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,366 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## Release of apipie-rails gem\n",
8+
"\n",
9+
"### Requirements\n",
10+
"- push access to https://github.com/Apipie/apipie-rails\n",
11+
"- push access to rubygems.org for apipie-rails\n",
12+
"- sudo yum install python-slugify asciidoc\n",
13+
"- ensure neither the `git push` or `gem push` don't require interractive auth. If you can't use api key or ssh key to auth skip these steps and run them form the shell manually \n",
14+
"\n",
15+
"### Release process\n",
16+
"- Follow the steps with `<Shift>+<Enter>` or `<Ctrl>+<Enter>,<Down>`\n",
17+
"- If anything fails, fix it and re-run the step if applicable\n",
18+
"\n",
19+
"### Release settings"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"%cd .."
29+
]
30+
},
31+
{
32+
"cell_type": "markdown",
33+
"metadata": {},
34+
"source": [
35+
"### Update the following notebook settings"
36+
]
37+
},
38+
{
39+
"cell_type": "code",
40+
"execution_count": null,
41+
"metadata": {},
42+
"outputs": [],
43+
"source": [
44+
"NEW_VERSION = '0.5.19'\n",
45+
"LAST_VERSION = '0.5.18'\n",
46+
"GIT_REMOTE_UPSTREAM = 'origin'\n",
47+
"WORK_BRANCH = 'master'\n"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"### Ensure the repo is up to date"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {},
61+
"outputs": [],
62+
"source": [
63+
"! git checkout {WORK_BRANCH}"
64+
]
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": null,
69+
"metadata": {},
70+
"outputs": [],
71+
"source": [
72+
"! git fetch {GIT_REMOTE_UPSTREAM}"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": null,
78+
"metadata": {},
79+
"outputs": [],
80+
"source": [
81+
"! git rebase {GIT_REMOTE_UPSTREAM}/{WORK_BRANCH}"
82+
]
83+
},
84+
{
85+
"cell_type": "markdown",
86+
"metadata": {},
87+
"source": [
88+
"### Run tests localy"
89+
]
90+
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": null,
94+
"metadata": {},
95+
"outputs": [],
96+
"source": [
97+
"! bundle update"
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": null,
103+
"metadata": {
104+
"scrolled": true
105+
},
106+
"outputs": [],
107+
"source": [
108+
"! bundle exec rake"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"metadata": {},
114+
"source": [
115+
"### Update release related stuff"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": null,
121+
"metadata": {},
122+
"outputs": [],
123+
"source": [
124+
"! sed -i 's/VERSION = .*/VERSION = \"{NEW_VERSION}\"/' lib/apipie/version.rb"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": null,
130+
"metadata": {},
131+
"outputs": [],
132+
"source": [
133+
"# Parse git changelog\n",
134+
"from IPython.display import Markdown as md\n",
135+
"from subprocess import check_output\n",
136+
"from shlex import split\n",
137+
"import re\n",
138+
"\n",
139+
"def format_log_entry(entry):\n",
140+
" author = re.search(r'author:(.*)', entry).group(1)\n",
141+
" entry = re.sub(r'author:(.*)', '', entry)\n",
142+
" entry = re.sub(r'([fF]ixes|[rR]efs)[^-]*-\\s*(.*)', r'\\2', entry)\n",
143+
" entry = '* ' + entry.capitalize()\n",
144+
" entry = re.sub(r'\\(#([0-9]+)\\)', r'[#\\1](https://github.com/Apipie/apipie-rails/pull/\\1)', entry)\n",
145+
" entry = entry + f'({author})'\n",
146+
" return entry\n",
147+
"\n",
148+
"def skip(entry):\n",
149+
" if re.match(r'Merge pull', entry) or \\\n",
150+
" re.match(r'^i18n', entry) or \\\n",
151+
" re.match(r'^Bump to version', entry):\n",
152+
" return True\n",
153+
" else:\n",
154+
" return False \n",
155+
"git_log_cmd = 'git log --pretty=format:\"%%s author:%%an\" v%s..HEAD' % LAST_VERSION\n",
156+
"log = check_output(split(git_log_cmd)).decode('utf8').split('\\n')\n",
157+
"change_log = [format_log_entry(e) for e in log if not skip(e)]\n",
158+
"md('\\n'.join(change_log))\n"
159+
]
160+
},
161+
{
162+
"cell_type": "code",
163+
"execution_count": null,
164+
"metadata": {},
165+
"outputs": [],
166+
"source": [
167+
"# Write release notes\n",
168+
"from datetime import datetime\n",
169+
"import fileinput\n",
170+
"import sys\n",
171+
"\n",
172+
"fh = fileinput.input('CHANGELOG.md', inplace=True) \n",
173+
"for line in fh: \n",
174+
" print(line.rstrip())\n",
175+
" if re.match(r'========', line):\n",
176+
" print('## [v%s](https://github.com/Apipie/apipie-rails/tree/v%s) (%s)' % (NEW_VERSION, NEW_VERSION, datetime.today().strftime('%Y-%m-%d')))\n",
177+
" print('[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v%s...v%s)' % (LAST_VERSION, NEW_VERSION))\n",
178+
" for entry in change_log:\n",
179+
" print(entry)\n",
180+
" print('')\n",
181+
"fh.close() "
182+
]
183+
},
184+
{
185+
"cell_type": "markdown",
186+
"metadata": {},
187+
"source": [
188+
"#### Manual step: Update deps in the gemspec if neccessary"
189+
]
190+
},
191+
{
192+
"cell_type": "markdown",
193+
"metadata": {},
194+
"source": [
195+
"### Check what is going to be commited"
196+
]
197+
},
198+
{
199+
"cell_type": "code",
200+
"execution_count": null,
201+
"metadata": {
202+
"scrolled": false
203+
},
204+
"outputs": [],
205+
"source": [
206+
"! git add -u\n",
207+
"! git status"
208+
]
209+
},
210+
{
211+
"cell_type": "code",
212+
"execution_count": null,
213+
"metadata": {
214+
"scrolled": true
215+
},
216+
"outputs": [],
217+
"source": [
218+
"! git diff --cached"
219+
]
220+
},
221+
{
222+
"cell_type": "markdown",
223+
"metadata": {},
224+
"source": [
225+
"### Commit changes"
226+
]
227+
},
228+
{
229+
"cell_type": "code",
230+
"execution_count": null,
231+
"metadata": {
232+
"scrolled": true
233+
},
234+
"outputs": [],
235+
"source": [
236+
"! git commit -m \"Bump to {NEW_VERSION}\""
237+
]
238+
},
239+
{
240+
"cell_type": "markdown",
241+
"metadata": {},
242+
"source": [
243+
"### Tag new version"
244+
]
245+
},
246+
{
247+
"cell_type": "code",
248+
"execution_count": null,
249+
"metadata": {},
250+
"outputs": [],
251+
"source": [
252+
"! git tag v{NEW_VERSION}"
253+
]
254+
},
255+
{
256+
"cell_type": "markdown",
257+
"metadata": {},
258+
"source": [
259+
"### Build the gem"
260+
]
261+
},
262+
{
263+
"cell_type": "code",
264+
"execution_count": null,
265+
"metadata": {},
266+
"outputs": [],
267+
"source": [
268+
"! rake build"
269+
]
270+
},
271+
{
272+
"cell_type": "code",
273+
"execution_count": null,
274+
"metadata": {},
275+
"outputs": [],
276+
"source": [
277+
"! gem push pkg/apipie-rails-{NEW_VERSION}.gem"
278+
]
279+
},
280+
{
281+
"cell_type": "markdown",
282+
"metadata": {},
283+
"source": [
284+
"### PUSH the changes upstream If everything is correct"
285+
]
286+
},
287+
{
288+
"cell_type": "code",
289+
"execution_count": null,
290+
"metadata": {},
291+
"outputs": [],
292+
"source": [
293+
"! git push {GIT_REMOTE_UPSTREAM} {WORK_BRANCH}"
294+
]
295+
},
296+
{
297+
"cell_type": "code",
298+
"execution_count": null,
299+
"metadata": {},
300+
"outputs": [],
301+
"source": [
302+
"! git push --tags {GIT_REMOTE_UPSTREAM} {WORK_BRANCH}"
303+
]
304+
},
305+
{
306+
"cell_type": "markdown",
307+
"metadata": {},
308+
"source": [
309+
"#### Now the new release is in upstream repo"
310+
]
311+
},
312+
{
313+
"cell_type": "markdown",
314+
"metadata": {},
315+
"source": [
316+
"### Some manual steps follow to improve the UX\n",
317+
"\n",
318+
"#### New relase on GitHub\n",
319+
"\n",
320+
"Copy the following changelog lines to the description in form on link below\n",
321+
"The release title is the new version."
322+
]
323+
},
324+
{
325+
"cell_type": "code",
326+
"execution_count": null,
327+
"metadata": {},
328+
"outputs": [],
329+
"source": [
330+
"print('\\n')\n",
331+
"print('\\n'.join(change_log))\n",
332+
"print('\\n\\nhttps://github.com/Apipie/apipie-rails/releases/new?tag=%s' % NEW_VERSION)"
333+
]
334+
},
335+
{
336+
"cell_type": "markdown",
337+
"metadata": {},
338+
"source": [
339+
"## Congratulations\n",
340+
"\n",
341+
"Release is public now."
342+
]
343+
}
344+
],
345+
"metadata": {
346+
"kernelspec": {
347+
"display_name": "Python 3",
348+
"language": "python",
349+
"name": "python3"
350+
},
351+
"language_info": {
352+
"codemirror_mode": {
353+
"name": "ipython",
354+
"version": 3
355+
},
356+
"file_extension": ".py",
357+
"mimetype": "text/x-python",
358+
"name": "python",
359+
"nbconvert_exporter": "python",
360+
"pygments_lexer": "ipython3",
361+
"version": "3.6.8"
362+
}
363+
},
364+
"nbformat": 4,
365+
"nbformat_minor": 2
366+
}

0 commit comments

Comments
 (0)