Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/actions/upload-android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ runs:
shell: bash

- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
if: ${{ inputs.trigger == 'develop' }}
if: ${{ inputs.trigger == 'develop' || inputs.trigger == 'pr' }}
with:
name: release-changelog
path: .

- name: Prepare Play Store changelog metadata
if: ${{ inputs.trigger == 'develop' }}
if: ${{ inputs.trigger == 'develop' || inputs.trigger == 'pr' }}
run: |
mkdir -p android/fastlane/metadata/android/en-US/changelogs

if [ -f changelog.txt ]; then
node .github/scripts/prepare-changelog.js
if [[ "${{ inputs.trigger }}" == "pr" ]]; then
cp changelog.txt "android/fastlane/metadata/android/en-US/changelogs/${BUILD_VERSION}.txt"
elif [ -f changelog.txt ]; then
node .github/scripts/changelog.js cap
else
printf "Internal improvements and bug fixes" > "android/fastlane/metadata/android/en-US/changelogs/${BUILD_VERSION}.txt"
fi
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/upload-ios/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ runs:
shell: bash

- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
if: ${{ inputs.trigger == 'develop' }}
if: ${{ inputs.trigger == 'develop' || inputs.trigger == 'pr' }}
with:
name: release-changelog
path: .
Expand All @@ -100,6 +100,7 @@ runs:
APP_STORE_CONNECT_API_KEY_ID: ${{ inputs.APP_STORE_CONNECT_API_KEY_ID }}
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ inputs.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
FASTLANE_REPO_PAT: ${{ inputs.FASTLANE_REPO_PAT }}
TRIGGER: ${{ inputs.trigger }}
shell: bash

- name: Extract version info from Info.plist
Expand Down
61 changes: 61 additions & 0 deletions .github/scripts/changelog.js
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("");
}
Comment thread
diegolmello marked this conversation as resolved.

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);
}
Comment thread
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`,
Comment thread
diegolmello marked this conversation as resolved.
capGraphemes(input, 500, { ellipsis: true }),
"utf8"
);
Comment thread
diegolmello marked this conversation as resolved.
} else {
console.error(`Unknown mode "${mode}". Usage: node changelog.js <pr|cap>`);
process.exit(1);
}
}
20 changes: 0 additions & 20 deletions .github/scripts/prepare-changelog.js

This file was deleted.

27 changes: 25 additions & 2 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,34 @@ jobs:
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
uses: ./.github/workflows/eslint.yml

generate-pr-changelog:
name: Generate PR Changelog
needs: [run-eslint-and-test]
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- name: Generate changelog
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr view "${{ github.event.pull_request.number }}" --json title,number,commits > pr.json
node .github/scripts/changelog.js pr

- name: Upload changelog artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release-changelog
path: changelog.txt
retention-days: 15

android-build-store:
name: Build Android
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
uses: ./.github/workflows/build-android.yml
needs: [run-eslint-and-test]
needs: [run-eslint-and-test, generate-pr-changelog]
secrets: inherit
with:
trigger: "pr"
Expand All @@ -32,7 +55,7 @@ jobs:
name: Build iOS
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
uses: ./.github/workflows/build-ios.yml
needs: [run-eslint-and-test]
needs: [run-eslint-and-test, generate-pr-changelog]
secrets: inherit
with:
trigger: "pr"
Expand Down
6 changes: 5 additions & 1 deletion android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ platform :android do
upload_to_play_store(
package_name: 'chat.rocket.android',
track: 'internal',
aab: 'app/build/outputs/bundle/release/app-release.aab'
aab: 'app/build/outputs/bundle/release/app-release.aab',
skip_upload_metadata: true,
skip_upload_changelogs: false,
skip_upload_images: true,
skip_upload_screenshots: true
)
end

Expand Down
3 changes: 3 additions & 0 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ platform :ios do

if changelog
pilot_options[:changelog] = changelog
end

if ENV["TRIGGER"] == "develop"
pilot_options[:distribute_external] = true
pilot_options[:notify_external_testers] = true
pilot_options[:groups] = ["External Testers"]
Expand Down
Loading