[ios, build] Populate GitHub releases with templated notes
Replicates our existing release notes format as an EJS template and Node JS script, then uploads the formatted notes during the deployment process.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
"pixelmatch": "^4.0.2",
|
||||
"pngjs": "^3.0.0",
|
||||
"request": "^2.72.0",
|
||||
"semver": "^5.5.0",
|
||||
"tape": "^4.5.1"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -102,10 +102,12 @@ if [[ "${GITHUB_RELEASE}" == true ]]; then
|
||||
if [[ $( echo ${PUBLISH_VERSION} | awk '/[0-9]-/' ) ]]; then
|
||||
PUBLISH_PRE_FLAG='--pre-release'
|
||||
fi
|
||||
RELEASE_NOTES=$( ./platform/ios/scripts/release-notes.js )
|
||||
github-release release \
|
||||
--tag "ios-v${PUBLISH_VERSION}" \
|
||||
--name "ios-v${PUBLISH_VERSION}" \
|
||||
--draft ${PUBLISH_PRE_FLAG}
|
||||
--draft ${PUBLISH_PRE_FLAG} \
|
||||
--description "${RELEASE_NOTES}"
|
||||
fi
|
||||
|
||||
buildPackageStyle "ipackage" "symbols"
|
||||
|
||||
37
platform/ios/scripts/release-notes.js
Executable file
37
platform/ios/scripts/release-notes.js
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const ejs = require('ejs');
|
||||
const _ = require('lodash');
|
||||
const semver = require('semver');
|
||||
|
||||
const changelog = fs.readFileSync('platform/ios/CHANGELOG.md', 'utf8');
|
||||
|
||||
// This regular expression parses the changelog for individual releases:
|
||||
// - Matches lines starting with "## ".
|
||||
// - Groups the version number.
|
||||
// - Skips the (optional) release date.
|
||||
// - Groups the changelog content.
|
||||
// - Ends when another "## " is found.
|
||||
const regex = /^## (\d+\.\d+\.\d+).*?\n(.+?)(?=\n^## )/gms;
|
||||
|
||||
let releases = [];
|
||||
while (match = regex.exec(changelog)) {
|
||||
releases.push({
|
||||
'version': match[1],
|
||||
'changelog': match[2].trim(),
|
||||
});
|
||||
}
|
||||
|
||||
const currentRelease = releases[0];
|
||||
|
||||
const versions = _.map(releases, 'version');
|
||||
const previousVersion = semver.maxSatisfying(versions, "<" + currentRelease.version);
|
||||
|
||||
const releaseNotes = ejs.render(fs.readFileSync('platform/ios/scripts/release-notes.md.ejs', 'utf8'), {
|
||||
'currentVersion': currentRelease.version,
|
||||
'previousVersion': previousVersion,
|
||||
'changelog': currentRelease.changelog,
|
||||
});
|
||||
|
||||
process.stdout.write(releaseNotes);
|
||||
10
platform/ios/scripts/release-notes.md.ejs
Normal file
10
platform/ios/scripts/release-notes.md.ejs
Normal file
@@ -0,0 +1,10 @@
|
||||
<%
|
||||
const CURRENTVERSION = locals.currentVersion;
|
||||
const PREVIOUSVERSION = locals.previousVersion;
|
||||
const CHANGELOG = locals.changelog;
|
||||
-%>
|
||||
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/ios-v<%-PREVIOUSVERSION%>...ios-v<%-CURRENTVERSION%>) since [Mapbox Maps SDK for iOS v<%-PREVIOUSVERSION%>](https://github.com/mapbox/mapbox-gl-native/releases/tag/ios-v<%-PREVIOUSVERSION%>):
|
||||
|
||||
<%-CHANGELOG%>
|
||||
|
||||
Documentation is [available online](https://www.mapbox.com/ios-sdk/api/<%-CURRENTVERSION%>/) or as part of the download.
|
||||
Reference in New Issue
Block a user