-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ci: add PR-build changelog for TestFlight and Play Store #7411
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| "use strict"; | ||
| const fs = require("fs"); | ||
|
|
||
| const segmenter = new Intl.Segmenter("en", { granularity: "grapheme" }); | ||
|
|
||
| function graphemes(str) { | ||
| return Array.from(segmenter.segment(str), s => s.segment); | ||
| } | ||
|
|
||
| // Hard-cap to `limit` graphemes. When `ellipsis` is true, reserve 3 graphemes | ||
| // for a trailing "..." (matches the legacy Play Store preparer). Assumes | ||
| // limit >= 4 when ellipsis is true. | ||
| function capGraphemes(str, limit, { ellipsis = false } = {}) { | ||
| const chars = graphemes(str); | ||
| if (chars.length <= limit) return str; | ||
| if (ellipsis) return chars.slice(0, limit - 3).join("") + "..."; | ||
| return chars.slice(0, limit).join(""); | ||
| } | ||
|
|
||
| function formatPrChangelog({ title, number, commits }) { | ||
| const header = `${title} (#${number})`; | ||
| // Reverse to newest-first; gh pr view --json commits returns oldest-first | ||
| const rows = [...commits].reverse().map(c => `${c.oid.slice(0, 7)} ${c.messageHeadline}`); | ||
|
|
||
| const build = rs => (rs.length > 0 ? [header, "", ...rs] : [header]).join("\n"); | ||
|
|
||
| let output = build(rows); | ||
| if (graphemes(output).length <= 500) return output; | ||
|
|
||
| // Drop oldest rows (end of newest-first list) until within limit | ||
| while (rows.length > 0) { | ||
| rows.pop(); | ||
| output = build(rows); | ||
| if (graphemes(output).length <= 500) return output; | ||
| } | ||
|
|
||
| // Header alone exceeds 500: hard-slice, no ellipsis | ||
| return capGraphemes(output, 500); | ||
| } | ||
|
diegolmello marked this conversation as resolved.
|
||
|
|
||
| module.exports = { formatPrChangelog, capGraphemes, graphemes }; | ||
|
|
||
| if (require.main === module) { | ||
| const mode = process.argv[2]; | ||
|
|
||
| if (mode === "pr") { | ||
| const pr = JSON.parse(fs.readFileSync("pr.json", "utf8")); | ||
| fs.writeFileSync("changelog.txt", formatPrChangelog(pr), "utf8"); | ||
| } else if (mode === "cap") { | ||
| const buildVersion = process.env.BUILD_VERSION; | ||
| const input = fs.readFileSync("changelog.txt", "utf8"); | ||
| fs.writeFileSync( | ||
| `android/fastlane/metadata/android/en-US/changelogs/${buildVersion}.txt`, | ||
|
diegolmello marked this conversation as resolved.
|
||
| capGraphemes(input, 500, { ellipsis: true }), | ||
| "utf8" | ||
| ); | ||
|
diegolmello marked this conversation as resolved.
|
||
| } else { | ||
| console.error(`Unknown mode "${mode}". Usage: node changelog.js <pr|cap>`); | ||
| process.exit(1); | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.