Thanks Kevin Kreiser.
My version of his solution without jq & only current commits from last tag.
TL;DR
instead
curl https://api.github.com/repos/user_org/project/pulls/${pr} 2>/dev/null | jq '.title';
use
curl https://api.github.com/repos/user_org/project/pulls/${pr} | grep title | cut -d'"' -f4
For CocoaHeadsRu repository example:
git clone https://github.com/cocoaheadsru/application.git // clone the repository
cd application // go to the application folder
touch getTitles.sh // create file getTitles.sh
chmod a+x getTitles.sh // make the file executable
vi getTitles.sh // open the file in the vim text editor
add the following code to the getTitles.sh:
for pr in $(git log $(git describe --tags --abbrev=0)..HEAD --pretty="%s" --merges | cut -d' ' -f4 | cut -d'#' -f2 | tr '\n' ' ')
do
curl https://api.github.com/repos/cocoaheadsru/application/pulls/${pr} | grep title | cut -d'"' -f4
done
save the code and exit the vim
:wq
Now we can create a release notes file using our script:
./getTitles.sh > ReleaseNotes.txt
cat ReleaseNotes.txt
// [qXUdCQay] Changed app build number, deleted MARKETING_VERSION and CU…
// Feature/kn vl5 eaw/add bluetooth always key
// [CQoos82f] Updated Realm, increment app version
// upgraded travis configuration
// Открытие места проведения митапа в 2ГИС
// Автокапитализация и технические улучшения
// Интеграция Travis-CI
// Postpone fetchEvents for main view after view appearing
Description script code:
1
git describe --tags --abbrev=0 // get the last tag
git log $(git describe --tags --abbrev=0)..HEAD // get all commit from last tag to HEAD
[--//--] --pretty="%s" // all commits in one line
[--//--] --merges // merged commits only
2
break the string into parts using the space character and get 4th value
ex Merge pull request #347 from antonsergeev88/swipeToPop_crash
[--//--] cut -d' ' -f4 // get '#347'
3
break the string into parts using the '#' character and get 2nd value
ex #347
[--//--] cut -d'#' -f2 // get '347'
4
tr '\n' ' ' // replaced '/n' with a space character
we get something like 355 354 353 352 350 349 348 347
5
In the loop using github api:
curl https://api.github.com/repos/cocoaheadsru/application/pulls/347
we get all pull requests in json-format. One of them:
{
"url": "https://api.github.com/repos/cocoaheadsru/application/pulls/347",
"id": 215781239,
"number": 347,
"state": "closed",
...
"title": "Postpone fetchEvents for main view after view appearing",
...
"user": {...},
"merged_at": "2018-09-30T17:26:47Z",
"merge_commit_sha": "553d8ea6f189882a22d424d0770785b53ddc4ab4",
"commits": 1,
...
}
6
using grep
[--//--] | grep title
get a line with the word title:
"title": "Postpone fetchEvents for main view after view appearing",
7
using cut:
[--//--] | cut -d'"' -f4
finally we get only title value:
Postpone fetchEvents for main view after view appearing