diff options
author | Jason Wray <jason@mapbox.com> | 2018-04-26 12:34:56 -0400 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2018-05-24 13:27:26 -0400 |
commit | 6e0d6ef44a0c46484bb8e960a5aeb5e773f42680 (patch) | |
tree | fe5c97da3dfc3a9ee9bbdcc6c973361263e08b48 /platform | |
parent | 3c74bbb9d07bd202903e6bf542903f3b0657f9f3 (diff) | |
download | qtlocation-mapboxgl-6e0d6ef44a0c46484bb8e960a5aeb5e773f42680.tar.gz |
[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.
Diffstat (limited to 'platform')
-rwxr-xr-x | platform/ios/scripts/deploy-packages.sh | 4 | ||||
-rwxr-xr-x | platform/ios/scripts/release-notes.js | 37 | ||||
-rw-r--r-- | platform/ios/scripts/release-notes.md.ejs | 10 |
3 files changed, 50 insertions, 1 deletions
diff --git a/platform/ios/scripts/deploy-packages.sh b/platform/ios/scripts/deploy-packages.sh index 103e53768c..643475f680 100755 --- a/platform/ios/scripts/deploy-packages.sh +++ b/platform/ios/scripts/deploy-packages.sh @@ -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" diff --git a/platform/ios/scripts/release-notes.js b/platform/ios/scripts/release-notes.js new file mode 100755 index 0000000000..f47242d997 --- /dev/null +++ b/platform/ios/scripts/release-notes.js @@ -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); diff --git a/platform/ios/scripts/release-notes.md.ejs b/platform/ios/scripts/release-notes.md.ejs new file mode 100644 index 0000000000..eedf9a0afa --- /dev/null +++ b/platform/ios/scripts/release-notes.md.ejs @@ -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. |