-
Notifications
You must be signed in to change notification settings - Fork 321
Running changelog #5354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running changelog #5354
Changes from all commits
098d6f1
f23ccb1
472793b
5cc8268
65554cf
499cfee
145d777
a322b14
a66ae97
c986e03
f6e8065
162d8fd
aa90ee8
2e575ca
7b1edd5
e2c1717
092f433
7501725
0e0ac09
fb64f52
f4d1efb
b2a72ca
238c3e1
d05508a
f792bd8
038ec1c
808cb4c
5dc143c
c682e3c
2018350
6e8c7b4
7ad845b
195f6ad
7adc9e7
6af894f
30c208d
4c5df00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [ | ||
| { | ||
| "ticket": 5338, | ||
| "type": "fixed", | ||
| "title": "Fixed something" | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [ | ||
| { | ||
| "ticket": 1234, | ||
| "type": "added", | ||
| "title": "test 2" | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apply from: "${rootDir}/gradle/dependencies.gradle" | ||
|
|
||
| task createDependenciesMd { | ||
| inputs.properties(this.ext.version) | ||
| outputs.file("$buildDir/dependencies.md") | ||
| doLast { | ||
| def versions = "- Mapbox Maps SDK v${this.ext.version.mapboxMapSdk} ([release notes](https://github.com/mapbox/mapbox-maps-android/releases/tag/android-v${this.ext.version.mapboxMapSdk})) \n" + | ||
| "- Mapbox Navigation Native v${this.ext.version.mapboxNavigator} \n" + | ||
| "- Mapbox Core Common v${this.ext.version.mapboxCommonNative} \n" + | ||
| "- Mapbox Java v${this.ext.version.mapboxSdkServices} ([release notes](https://github.com/mapbox/mapbox-java/releases/tag/v${this.ext.version.mapboxSdkServices})) \n" + | ||
| "- Mapbox Android Core v${this.ext.version.mapboxCore} \n" + | ||
| "- Mapbox Android Telemetry v${this.ext.version.mapboxEvents} " | ||
| new File(buildDir, "dependencies.md").text = versions | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "name": "mapbox-navigation-android", | ||
| "version": "0.0.0", | ||
| "scripts": { | ||
| "test": "mocha scripts/**/*.test.js --inline-diffs" | ||
| }, | ||
| "devDependencies": { | ||
| "@octokit/rest": "^17.1.1", | ||
| "parse-git-patch": "^1.0.7", | ||
| "prompts": "^2.4.1", | ||
| "minimist": "^1.2.5", | ||
| "semver": "^7.3.5", | ||
| "mocha": "9.1.4", | ||
| "mock-fs": "5.1.2" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| const { createEntry } = require("./libs/changelog") | ||
| const minimist = require("minimist") | ||
|
|
||
|
|
||
| async function main() { | ||
| try { | ||
| const argv = minimist(process.argv.slice(2), { | ||
| string: [ | ||
| 'ticket', | ||
| 'type', | ||
| 'message' | ||
| ], | ||
| boolean: [ | ||
| 'dry-run' | ||
| ], | ||
| alias: { | ||
| 'dry-run': 'isDryRun' | ||
| }, | ||
| default: { | ||
| isDryRun: false | ||
| }, | ||
| unknown: function (name) { | ||
| throw `parameter ${name} isn't supported` | ||
| } | ||
| }); | ||
| createEntry(argv) | ||
| } catch(error) { | ||
| console.error(error) | ||
| console.log("Usage") | ||
| } | ||
| } | ||
|
|
||
| main() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| const semver = require('semver') | ||
| const { compileChangeLog, compileReleaseNotesMd, removeEntries, addReleaseNotesToChangelogMD } = require("./libs/changelog") | ||
| const path = require('path'); | ||
| const { execSync } = require('child_process'); | ||
| const fs = require('fs'); | ||
|
|
||
| let BUILD_DIR = path.join(".", "build") | ||
| const CHANGELOG_PATH = path.join(".", "CHANGELOG.md") | ||
|
|
||
| try { | ||
| main() | ||
| } catch (err) { | ||
| console.error(err) | ||
| console.error('Usage: scripts/changelog-pr --version [release version, for example 1.0.0] [--branch main] [--dry-run]'); | ||
| } | ||
|
|
||
| function main() { | ||
| let args = parseArguments() | ||
| // TODO: check if GH exists | ||
| // TODO: check if branch matches current one | ||
| console.log("Generating dependencies.md") | ||
| execSync("./gradlew createDependenciesMd") | ||
| let dependenciesMd = fs.readFileSync(path.join(".", "build", "dependencies.md")) | ||
| console.log("Generated dependencies.md") | ||
|
|
||
| console.log("Compiling changelog") | ||
| let changelog = compileReleaseNotesMd({ | ||
| version: args.version, | ||
| dependenciesMd: dependenciesMd | ||
| }) | ||
|
|
||
| let executor = args.isDryRun | ||
| ? execSyncDryRun | ||
| : execSync | ||
|
|
||
| let releaseNotesTempFile = path.join(BUILD_DIR, "RELEASENOTES.md") | ||
| if (args.isDryRun) { | ||
| console.log("Dry run. Generated changelog:") | ||
| console.log(changelog) | ||
| } else { | ||
| fs.writeFileSync(releaseNotesTempFile, changelog) | ||
| removeEntries() | ||
| updateChangelogMDFile(changelog) | ||
| } | ||
|
|
||
|
|
||
| executor(`git checkout -b add-changelog-${args.version}`) | ||
| executor(`git add .`) | ||
| executor(`git commit -m "created changelog for ${args.version}"`) | ||
| executor(`gh config set prompt disabled`) | ||
| executor(`git push --set-upstream origin add-changelog-${args.version}`) | ||
| executor(`gh pr create --base ${args.branch} --title "Changelog for ${args.version}" --body "" --reviewer mapbox/navigation-android`) | ||
| executor(`gh release create ${args.version} --draft --target ${args.branch} --notes-file ${releaseNotesTempFile} --title ${args.version}`) | ||
| if (args.branch != "main") { | ||
| executor(`git checkout main`) | ||
| executor(`git checkout -b add-changelog-${args.version}-update-main`) | ||
| if (args.isDryRun) { | ||
| console.log("updating changelog at main branch") | ||
| } else { | ||
| updateChangelogMDFile(changelog) | ||
| } | ||
| executor(`git add .`) | ||
| executor(`git commit -m "Changelog for ${args.version}"`) | ||
| executor(`git push origin add-changelog-${args.version}-update-main`) | ||
| executor(`gh pr create --base main --title "Changelog for ${args.version}" --body "" --reviewer mapbox/navigation-android`) | ||
| } | ||
| executor(`git checkout ${args.branch}`) | ||
|
Comment on lines
+44
to
+69
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If somebody launches the script from a not main branch, for example Alternatively we can update
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm. Not I'm not sure that this is an approach we use. All our changes go through the master branch and then they're cherry-picked to release branch. 馃
Comment on lines
+49
to
+69
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to replace |
||
| } | ||
|
|
||
| function updateChangelogMDFile(newReleaseChangelog) { | ||
| let existingChangelog = fs.readFileSync(CHANGELOG_PATH).toString() | ||
| let updatedChangelog = addReleaseNotesToChangelogMD(existingChangelog, newReleaseChangelog) | ||
| fs.writeFileSync(CHANGELOG_PATH, updatedChangelog) | ||
| } | ||
|
|
||
| function execSyncDryRun(command) { | ||
| console.log(`dry-run: ${command}`) | ||
| } | ||
|
|
||
| function parseArguments() { | ||
| const argv = require("minimist")(process.argv.slice(2), { | ||
| string: [ | ||
| 'branch', | ||
| 'version' | ||
| ], | ||
| boolean: [ | ||
| 'dry-run' | ||
| ], | ||
| default: { | ||
| branch: "main", | ||
| 'dry-run': false | ||
| }, | ||
| unknown: function (name) { | ||
| throw `parameter ${name} isn't supported` | ||
| } | ||
| }); | ||
|
|
||
| let result = {} | ||
|
|
||
| result.isDryRun = argv['dry-run'] | ||
| result.branch = argv.branch | ||
|
|
||
| result.version = argv.version | ||
| if (result.version == undefined) { | ||
| throw "you must specify a version for release" | ||
| } | ||
| if (!semver.valid(result.version)) { | ||
| throw `passed version ${result.version} isn't SemVer compatible` | ||
| } | ||
|
|
||
| return result | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed some way to access
mbx-cifromscripts/github.js