summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2018-08-01 20:48:57 -0400
committerJason Wray <friedbunny@users.noreply.github.com>2018-08-06 12:31:21 -0400
commit1a94eb47c011b13cef0f412aafa2eb9ae75e418a (patch)
treefd49f0b76d3e5909677132d433aa20704273a55f
parent66f5be386432e4b9b4755c54c1e5a51138b7acd1 (diff)
downloadqtlocation-mapboxgl-1a94eb47c011b13cef0f412aafa2eb9ae75e418a.tar.gz
[ios, build] Support prereleases in templated release notes
-rwxr-xr-xplatform/ios/scripts/release-notes.js62
-rw-r--r--platform/ios/scripts/release-notes.md.ejs14
2 files changed, 53 insertions, 23 deletions
diff --git a/platform/ios/scripts/release-notes.js b/platform/ios/scripts/release-notes.js
index f47242d997..6e4d520f14 100755
--- a/platform/ios/scripts/release-notes.js
+++ b/platform/ios/scripts/release-notes.js
@@ -1,37 +1,65 @@
#!/usr/bin/env node
const fs = require('fs');
+const child_process = require('child_process');
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.
+/*
+ Find current and immediately previous releases by parsing git tags.
+*/
+let currentVersion = child_process.execSync('git describe --tags --match=ios-v*.*.* --abbrev=0')
+ .toString()
+ .trim()
+ .replace('ios-v', '');
+
+let gitTags = child_process.execSync('git tag --list ios-v*.*.*')
+ .toString()
+ .split('\n')
+ .map(function (tag) {
+ tag = tag.replace('ios-v', '').trim();
+ return semver.clean(tag);
+ });
+let previousVersion = semver.maxSatisfying(gitTags, "<" + currentVersion);
+
+/*
+ Parse the raw changelog text and split it into individual releases.
+
+ This regular expression:
+ - 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 = [];
+let releaseNotes = [];
while (match = regex.exec(changelog)) {
- releases.push({
+ releaseNotes.push({
'version': match[1],
'changelog': match[2].trim(),
});
}
-const currentRelease = releases[0];
-
-const versions = _.map(releases, 'version');
-const previousVersion = semver.maxSatisfying(versions, "<" + currentRelease.version);
+/*
+ Match the current tag with the most appropriate release notes.
+*/
+const versionsInReleaseNotes = _.map(releaseNotes, 'version');
+const bestReleaseNotesForCurrentVersion = semver.minSatisfying(versionsInReleaseNotes, ">=" + currentVersion);
+const currentReleaseNotes = _.find(releaseNotes, { version: bestReleaseNotesForCurrentVersion });
-const releaseNotes = ejs.render(fs.readFileSync('platform/ios/scripts/release-notes.md.ejs', 'utf8'), {
- 'currentVersion': currentRelease.version,
- 'previousVersion': previousVersion,
- 'changelog': currentRelease.changelog,
+/*
+ Fill and print the release notes template.
+*/
+const templatedReleaseNotes = ejs.render(fs.readFileSync('platform/ios/scripts/release-notes.md.ejs', 'utf8'), {
+ 'CURRENTVERSION': currentVersion,
+ 'PREVIOUSVERSION': previousVersion,
+ 'CHANGELOG': currentReleaseNotes.changelog,
+ 'isPrerelease': semver.prerelease(currentVersion)
});
-process.stdout.write(releaseNotes);
+process.stdout.write(templatedReleaseNotes);
diff --git a/platform/ios/scripts/release-notes.md.ejs b/platform/ios/scripts/release-notes.md.ejs
index eedf9a0afa..91115225e9 100644
--- a/platform/ios/scripts/release-notes.md.ejs
+++ b/platform/ios/scripts/release-notes.md.ejs
@@ -1,10 +1,12 @@
-<%
- 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%>
+<%-CHANGELOG-%>
+
+<% if (isPrerelease) { %>
+To install this prerelease via CocoaPods, point your Podfile to either of these URLs:
+
+* https://raw.githubusercontent.com/mapbox/mapbox-gl-native/ios-v<%-CURRENTVERSION%>/platform/ios/Mapbox-iOS-SDK.podspec
+* https://raw.githubusercontent.com/mapbox/mapbox-gl-native/ios-v<%-CURRENTVERSION%>/platform/ios/Mapbox-iOS-SDK-symbols.podspec
+<% } -%>
Documentation is [available online](https://www.mapbox.com/ios-sdk/api/<%-CURRENTVERSION%>/) or as part of the download.