diff options
author | Jason Wray <jason@mapbox.com> | 2018-08-21 19:16:18 -0400 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2018-08-22 13:05:49 -0400 |
commit | 5e213d0db1bf1674e9a3374a9c0325b9a150c5d8 (patch) | |
tree | fe7215ad90d2c0c234029ab179d414fb33285eb0 | |
parent | d31df6a615aee731199e992cf8e1d1f8e87daf66 (diff) | |
download | qtlocation-mapboxgl-5e213d0db1bf1674e9a3374a9c0325b9a150c5d8.tar.gz |
[ios, build] Improve jazzy readme generation
- Include changelogs for all releases in the current semver minor series.
- Use template for jazzy readme.
-rwxr-xr-x | platform/ios/scripts/deploy-packages.sh | 2 | ||||
-rwxr-xr-x | platform/ios/scripts/document.sh | 17 | ||||
-rw-r--r-- | platform/ios/scripts/release-notes-github.md.ejs (renamed from platform/ios/scripts/release-notes.md.ejs) | 0 | ||||
-rw-r--r-- | platform/ios/scripts/release-notes-jazzy.md.ejs (renamed from platform/ios/docs/doc-README.md) | 16 | ||||
-rwxr-xr-x | platform/ios/scripts/release-notes.js | 44 |
5 files changed, 65 insertions, 14 deletions
diff --git a/platform/ios/scripts/deploy-packages.sh b/platform/ios/scripts/deploy-packages.sh index 4197a26678..640e2f31bf 100755 --- a/platform/ios/scripts/deploy-packages.sh +++ b/platform/ios/scripts/deploy-packages.sh @@ -103,7 +103,7 @@ 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 ) + RELEASE_NOTES=$( ./platform/ios/scripts/release-notes.js github ) github-release release \ --tag "ios-v${PUBLISH_VERSION}" \ --name "ios-v${PUBLISH_VERSION}" \ diff --git a/platform/ios/scripts/document.sh b/platform/ios/scripts/document.sh index 407d5f9adf..19fce4a0f9 100755 --- a/platform/ios/scripts/document.sh +++ b/platform/ios/scripts/document.sh @@ -4,8 +4,12 @@ set -e set -o pipefail set -u +function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } +function finish { >&2 echo -en "\033[0m"; } +trap finish EXIT + if [ -z `which jazzy` ]; then - echo "Installing jazzy…" + step "Installing jazzy…" CIRCLECI=${CIRCLECI:-false} if [[ "${CIRCLECI}" == true ]]; then @@ -28,11 +32,10 @@ RELEASE_VERSION=$( echo ${SHORT_VERSION} | sed -e 's/^ios-v//' -e 's/-.*//' ) rm -rf /tmp/mbgl mkdir -p /tmp/mbgl/ + +step "Generating readme and release notes" README=/tmp/mbgl/README.md -cp platform/ios/docs/doc-README.md "${README}" -# http://stackoverflow.com/a/4858011/4585461 -echo "## Changes in version ${RELEASE_VERSION}" >> "${README}" -sed -n -e '/^## /{' -e ':a' -e 'n' -e '/^## /q' -e 'p' -e 'ba' -e '}' platform/ios/CHANGELOG.md >> "${README}" +node platform/ios/scripts/release-notes.js jazzy >> "${README}" rm -rf ${OUTPUT} mkdir -p ${OUTPUT} @@ -40,6 +43,7 @@ mkdir -p ${OUTPUT} cp -r platform/darwin/docs/img "${OUTPUT}" cp -r platform/ios/docs/img "${OUTPUT}" +step "Generating jazzy docs for ${SHORT_VERSION}…" DEFAULT_THEME="platform/darwin/docs/theme" THEME=${JAZZY_THEME:-$DEFAULT_THEME} @@ -53,6 +57,7 @@ jazzy \ --root-url https://www.mapbox.com/ios-sdk/api/${RELEASE_VERSION}/ \ --theme ${THEME} \ --output ${OUTPUT} + # https://github.com/realm/jazzy/issues/411 find ${OUTPUT} -name *.html -exec \ - perl -pi -e 's/BRANDLESS_DOCSET_TITLE/iOS SDK $1/, s/Mapbox\s+(Docs|Reference)/Mapbox iOS SDK $1/' {} \; + perl -pi -e 's/BRANDLESS_DOCSET_TITLE/iOS SDK $1/, s/Mapbox\s+(Docs|Reference)/Mapbox Maps SDK for iOS $1/' {} \; diff --git a/platform/ios/scripts/release-notes.md.ejs b/platform/ios/scripts/release-notes-github.md.ejs index 91115225e9..91115225e9 100644 --- a/platform/ios/scripts/release-notes.md.ejs +++ b/platform/ios/scripts/release-notes-github.md.ejs diff --git a/platform/ios/docs/doc-README.md b/platform/ios/scripts/release-notes-jazzy.md.ejs index 3a95aa96de..12b7480a2b 100644 --- a/platform/ios/docs/doc-README.md +++ b/platform/ios/scripts/release-notes-jazzy.md.ejs @@ -4,6 +4,20 @@ The Mapbox Maps SDK for iOS is an open-source framework for embedding interactiv ![Mapbox Maps SDK for iOS screenshots](img/screenshot.png) -For setup information, check out the [Mapbox Maps SDK for iOS homepage](https://www.mapbox.com/ios-sdk/). For detailed usage instructions, read “[First steps with the Mapbox Maps SDK for iOS](https://www.mapbox.com/help/first-steps-ios-sdk/)” and consult the [online examples](https://www.mapbox.com/ios-sdk/examples/). A [full changelog](https://github.com/mapbox/mapbox-gl-native/blob/master/platform/ios/CHANGELOG.md) is also available. +For setup information, check out the [Mapbox Maps SDK for iOS homepage](https://www.mapbox.com/ios-sdk/). For detailed usage instructions, read “[First steps with the Mapbox Maps SDK for iOS](https://www.mapbox.com/help/first-steps-ios-sdk/)” and consult the [online examples](https://www.mapbox.com/ios-sdk/examples/). If you have any questions, please see [our help page](https://www.mapbox.com/help/). We welcome your [bug reports, feature requests, and contributions](https://github.com/mapbox/mapbox-gl-native/issues/). + +## Changes in version <%-CURRENTVERSION%> + +<%-CURRENTCHANGELOG%> + +## Recent changes + +<% OTHERRELEASES.forEach(function(release) { %> +### <%-release.version%> + +<%-release.changelog%> +<% }) -%> + +See the [full changelog](https://github.com/mapbox/mapbox-gl-native/blob/ios-v<%-CURRENTVERSION%>/platform/ios/CHANGELOG.md) for previous releases. diff --git a/platform/ios/scripts/release-notes.js b/platform/ios/scripts/release-notes.js index 5b2e2fa8d2..d7a7d6dbbb 100755 --- a/platform/ios/scripts/release-notes.js +++ b/platform/ios/scripts/release-notes.js @@ -8,6 +8,15 @@ const semver = require('semver'); const changelog = fs.readFileSync('platform/ios/CHANGELOG.md', 'utf8'); +let outputMode = {}; +switch(process.argv[2]) { + case "jazzy": + outputMode.isJazzy = true; break; + case "github": + default: + outputMode.isGitHub = true; +} + /* Find current and immediately previous releases by parsing git tags. */ @@ -55,11 +64,34 @@ const currentReleaseNotes = _.find(releaseNotes, { version: bestReleaseNotesForC /* 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) -}); +let templatedReleaseNotes; + +if (outputMode.isGitHub) { + templatedReleaseNotes = ejs.render(fs.readFileSync('platform/ios/scripts/release-notes-github.md.ejs', 'utf8'), { + 'CURRENTVERSION': currentVersion, + 'PREVIOUSVERSION': previousVersion, + 'CHANGELOG': currentReleaseNotes.changelog, + 'isPrerelease': semver.prerelease(currentVersion) + }); +} + +if (outputMode.isJazzy) { + const minorReleaseSeries = semver.major(currentVersion) + "." + semver.minor(currentVersion) + ".0"; + const range = ">=" + minorReleaseSeries + " <" + currentVersion; + const otherReleasesInSeries = _.filter(releaseNotes, function(release) { + return semver.satisfies(release.version, range); + }); + + otherReleasesInSeries.forEach(function(release) { + // Bump section headings from h3 to h4. + release.changelog = release.changelog.replace(/^### /gm, '#### '); + }); + + templatedReleaseNotes = ejs.render(fs.readFileSync('platform/ios/scripts/release-notes-jazzy.md.ejs', 'utf8'), { + 'CURRENTVERSION': currentVersion, + 'CURRENTCHANGELOG': currentReleaseNotes.changelog, + 'OTHERRELEASES': otherReleasesInSeries + }); +} process.stdout.write(templatedReleaseNotes); |