From 68b85ee38a23a964bb0fdcbbddf1ec81ab10fc67 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 14:17:40 -0600 Subject: [PATCH 01/25] added scripts to auto generate changelogs --- package.json | 5 +- scripts/changelog-csv.sh | 75 +++++++++++++++ scripts/generate-rc-commits.mjs | 162 ++++++++++++++++++++++++++++++++ yarn.lock | 116 ++++++++++++++++++++++- 4 files changed, 355 insertions(+), 3 deletions(-) create mode 100755 scripts/changelog-csv.sh create mode 100644 scripts/generate-rc-commits.mjs diff --git a/package.json b/package.json index 552e94579b0..1866c79f266 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "test:merge-coverage": "nyc report --temp-dir ./tests/coverage --report-dir ./tests/merged-coverage/ --reporter json --reporter text --reporter lcovonly", "test:validate-coverage": "nyc check-coverage --nycrc-path ./coverage-thresholds.json -t ./tests/merged-coverage/", "update-changelog": "./scripts/auto-changelog.sh", + "changeset-changelog": "wrap () { node ./scripts/generate-rc-commits.js \"$@\" && ./scripts/changelog-csv.sh }; wrap ", "prestorybook": "rnstl", "deduplicate": "yarn yarn-deduplicate && yarn install", "create-release": "./scripts/set-versions.sh && yarn update-changelog", @@ -189,6 +190,7 @@ "@metamask/utils": "^8.1.0", "@ngraveio/bc-ur": "^1.1.6", "@notifee/react-native": "^7.8.2", + "@octokit/rest": "^21.0.0", "@react-native-async-storage/async-storage": "^1.23.1", "@react-native-clipboard/clipboard": "1.8.4", "@react-native-community/blur": "4.3.2", @@ -338,6 +340,7 @@ "redux-thunk": "^2.4.2", "reselect": "^4.0.0", "rxjs": "^7.8.1", + "simple-git": "^3.22.0", "socket.io-client": "^4.5.3", "stream-browserify": "3.0.0", "through2": "3.0.1", @@ -572,4 +575,4 @@ } }, "packageManager": "yarn@1.22.22" -} \ No newline at end of file +} diff --git a/scripts/changelog-csv.sh b/scripts/changelog-csv.sh new file mode 100755 index 00000000000..ab80ab3ecaf --- /dev/null +++ b/scripts/changelog-csv.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -e +set -u +set -o pipefail + +readonly CSV_FILE='commits.csv' +# Temporary file for new entries +NEW_ENTRIES=$(mktemp) +# Backup file for existing CHANGELOG +CHANGELOG_BACKUP="CHANGELOG.md.bak" + +# Backup existing CHANGELOG.md +cp CHANGELOG.md "$CHANGELOG_BACKUP" + +# Function to append entry to the correct category in the temp file +append_entry() { + local change_type="$1" + local entry="$2" + # Ensure the "Other" category is explicitly handled + case "$change_type" in + Added|Changed|Fixed) ;; + *) change_type="Other" ;; # Categorize as "Other" if not matching predefined categories + esac + echo "$entry" >> "$NEW_ENTRIES-$change_type" +} + +# Read the CSV file and append entries to temp files based on change type +while IFS=, read -r commit_message author pr_link team change_type +do + pr_id=$(echo "$pr_link" | grep -o '[^/]*$') + entry="- [#$pr_id]($pr_link): $commit_message" + append_entry "$change_type" "$entry" +done < <(tail -n +2 "$CSV_FILE") # Skip the header line + +# Function to insert new entries into CHANGELOG.md after a specific line +insert_new_entries() { + local marker="## Current Main Branch" + local changelog="CHANGELOG.md" + local temp_changelog=$(mktemp) + + # Find the line number of the marker + local line_num=$(grep -n "$marker" "$CHANGELOG_BACKUP" | cut -d ':' -f 1) + + # Split the existing CHANGELOG at the marker line + head -n "$line_num" "$CHANGELOG_BACKUP" > "$temp_changelog" + + # Append the release header + echo "" >> "$temp_changelog" + echo "## - " >> "$temp_changelog" + echo "" >> "$temp_changelog" + + # Append new entries for each change type if they exist + for change_type in Added Changed Fixed Other; do + if [[ -s "$NEW_ENTRIES-$change_type" ]]; then + echo "### $change_type" >> "$temp_changelog" + cat "$NEW_ENTRIES-$change_type" >> "$temp_changelog" + echo "" >> "$temp_changelog" # Add a newline for spacing + fi + done + + # Append the rest of the original CHANGELOG content + tail -n +$((line_num + 1)) "$CHANGELOG_BACKUP" >> "$temp_changelog" + + # Replace the original CHANGELOG with the updated one + mv "$temp_changelog" "$changelog" +} + +# Insert new entries into CHANGELOG.md +insert_new_entries + +# Cleanup +rm "$NEW_ENTRIES-"* "$CHANGELOG_BACKUP" + +echo 'CHANGELOG updated' \ No newline at end of file diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs new file mode 100644 index 00000000000..24afc2eb9cc --- /dev/null +++ b/scripts/generate-rc-commits.mjs @@ -0,0 +1,162 @@ +// eslint-disable-next-line import/no-nodejs-modules +import fs from 'fs'; +// eslint-disable-next-line import/no-extraneous-dependencies +import simpleGit from 'simple-git'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { Octokit } from '@octokit/rest'; + +// "GITHUB_TOKEN" is an automatically generated, repository-specific access token provided by GitHub Actions. +const githubToken = process.env.GITHUB_TOKEN; +if (!githubToken) { + console.log('GITHUB_TOKEN not found'); + process.exit(1); +} + +// Initialize Octokit with your GitHub token +const octokit = new Octokit({ auth: githubToken}); + +async function getPRLabels(prNumber) { + try { + const { data } = await octokit.pulls.get({ + owner: 'MetaMask', + repo: 'metamask-mobile', + pull_number: prNumber[1], + }); + + const labels = data.labels.map(label => label.name); + + // Check if any label name contains "team" + const hasTeamLabel = labels.filter(label => label.toLowerCase().includes('team')); + + return hasTeamLabel || 'Unknown'; + + } catch (error) { + console.error(`Error fetching labels for PR #${prNumber}:`, error); + return []; + } +} + +// Function to filter commits based on unique commit messages and group by teams +async function filterCommitsByTeam(branchA, branchB) { + try { + const git = simpleGit(); + + const logOptions = { + from: branchB, + to: branchA, + format: { + hash: '%H', + author: '%an', + message: '%s', + }, + }; + + const log = await git.log(logOptions); + const seenMessages = new Set(); + const seenMessagesArray = []; + const commitsByTeam = {}; + + const MAX_COMMITS = 500; // Limit the number of commits to process + + for (const commit of log.all) { + const { author, message, hash } = commit; + if (commitsByTeam.length >= MAX_COMMITS) { + break; + } + + // Extract PR number from the commit message using regex + const prMatch = message.match(/\(#(\d{5})\)$/u); + const prLink = prMatch ? `https://github.com/MetaMask/metamask-mobile/pull/${prMatch[1]}` : ''; + + const team = await getPRLabels(prMatch); + console.log(team); + + // Check if the commit message is unique + if (!seenMessages.has(message)) { + seenMessagesArray.push(message); + seenMessages.add(message); + + // Initialize the team's commits array if it doesn't exist + if (!commitsByTeam[team]) { + commitsByTeam[team] = []; + } + + commitsByTeam[team].push({ + message, + author, + hash: hash.substring(0, 10), + prLink, + }); + } + } + + return commitsByTeam; + } catch (error) { + console.error(error); + return {}; + } +} + +function formatAsCSV(commitsByTeam) { + const csvContent = []; + for (const [team, commits] of Object.entries(commitsByTeam)) { + commits.forEach((commit) => { + const row = [ + escapeCSV(commit.message), + escapeCSV(commit.author), + commit.prLink, + escapeCSV(team), + assignChangeType(commit.message) + ]; + csvContent.push(row.join(',')); + }); + } + csvContent.unshift('Commit Message,Author,PR Link,Team,Change Type'); + + return csvContent; +} + +// Helper function to escape CSV fields +function escapeCSV(field) { + if (field.includes(',') || field.includes('"') || field.includes('\n')) { + return `"${field.replace(/"/g, '""')}"`; // Encapsulate in double quotes and escape existing quotes + } + return field; +} +// Helper function to create change type +function assignChangeType(field) { + if (field.includes('feat')) + return 'Added'; + else if (field.includes('cherry') || field.includes('bump')) + return 'Ops'; + else if (field.includes('chore') || field.includes('test') || field.includes('ci') || field.includes('docs') || field.includes('refactor')) + return 'Changed'; + else if (field.includes('fix')) + return 'Fixed'; + + return 'Unknown'; +} + +async function main() { + const args = process.argv.slice(2); + + if (args.length !== 2) { + console.error('Usage: node script.js branchA branchB'); + process.exit(1); + } + + const branchA = args[0]; + const branchB = args[1]; + + const commitsByTeam = await filterCommitsByTeam(branchA, branchB); + + if (Object.keys(commitsByTeam).length === 0) { + console.log('No unique commits found.'); + } else { + const csvContent = formatAsCSV(commitsByTeam); + fs.writeFileSync('commits.csv', csvContent.join('\n')); + console.log('CSV file "commits.csv" created successfully.'); + } +} + +main(); diff --git a/yarn.lock b/yarn.lock index 3e03fa82aef..f6f2041a4f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3434,6 +3434,18 @@ "@keystonehq/bc-ur-registry-eth" "^0.6.12" "@ngraveio/bc-ur" "^1.1.6" +"@kwsites/file-exists@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@kwsites/file-exists/-/file-exists-1.1.1.tgz#ad1efcac13e1987d8dbaf235ef3be5b0d96faa99" + integrity sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw== + dependencies: + debug "^4.1.1" + +"@kwsites/promise-deferred@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz#8ace5259254426ccef57f3175bc64ed7095ed919" + integrity sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw== + "@lavamoat/aa@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@lavamoat/aa/-/aa-4.2.0.tgz#1262589c77386b1741fe904ebdfe97b959bc8fa4" @@ -5105,6 +5117,11 @@ resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7" integrity sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA== +"@octokit/auth-token@^5.0.0": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-5.1.1.tgz#3bbfe905111332a17f72d80bd0b51a3e2fa2cf07" + integrity sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA== + "@octokit/core@^5.0.1": version "5.2.0" resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.2.0.tgz#ddbeaefc6b44a39834e1bb2e58a49a117672a7ea" @@ -5118,6 +5135,27 @@ before-after-hook "^2.2.0" universal-user-agent "^6.0.0" +"@octokit/core@^6.1.2": + version "6.1.2" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-6.1.2.tgz#20442d0a97c411612da206411e356014d1d1bd17" + integrity sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg== + dependencies: + "@octokit/auth-token" "^5.0.0" + "@octokit/graphql" "^8.0.0" + "@octokit/request" "^9.0.0" + "@octokit/request-error" "^6.0.1" + "@octokit/types" "^13.0.0" + before-after-hook "^3.0.2" + universal-user-agent "^7.0.0" + +"@octokit/endpoint@^10.0.0": + version "10.1.1" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-10.1.1.tgz#1a9694e7aef6aa9d854dc78dd062945945869bcc" + integrity sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q== + dependencies: + "@octokit/types" "^13.0.0" + universal-user-agent "^7.0.2" + "@octokit/endpoint@^9.0.1": version "9.0.5" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-9.0.5.tgz#e6c0ee684e307614c02fc6ac12274c50da465c44" @@ -5135,6 +5173,15 @@ "@octokit/types" "^13.0.0" universal-user-agent "^6.0.0" +"@octokit/graphql@^8.0.0": + version "8.1.1" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-8.1.1.tgz#3cacab5f2e55d91c733e3bf481d3a3f8a5f639c4" + integrity sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg== + dependencies: + "@octokit/request" "^9.0.0" + "@octokit/types" "^13.0.0" + universal-user-agent "^7.0.0" + "@octokit/openapi-types@^20.0.0": version "20.0.0" resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-20.0.0.tgz#9ec2daa0090eeb865ee147636e0c00f73790c6e5" @@ -5145,6 +5192,13 @@ resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-22.2.0.tgz#75aa7dcd440821d99def6a60b5f014207ae4968e" integrity sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg== +"@octokit/plugin-paginate-rest@^11.0.0": + version "11.3.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.3.0.tgz#f8511b5df06b83e662c54f249a11a0da2213c6c3" + integrity sha512-n4znWfRinnUQF6TPyxs7EctSAA3yVSP4qlJP2YgI3g9d4Ae2n5F3XDOjbUluKRxPU3rfsgpOboI4O4VtPc6Ilg== + dependencies: + "@octokit/types" "^13.5.0" + "@octokit/plugin-paginate-rest@^9.0.0": version "9.2.1" resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.2.1.tgz#2e2a2f0f52c9a4b1da1a3aa17dabe3c459b9e401" @@ -5152,6 +5206,11 @@ dependencies: "@octokit/types" "^12.6.0" +"@octokit/plugin-request-log@^5.1.0": + version "5.3.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-5.3.0.tgz#4dea4f34316b7075d02796edcb73103266119e61" + integrity sha512-FiGcyjdtYPlr03ExBk/0ysIlEFIFGJQAVoPPMxL19B24bVSEiZQnVGBunNtaAF1YnvE/EFoDpXmITtRnyCiypQ== + "@octokit/plugin-rest-endpoint-methods@^10.0.0": version "10.4.1" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.1.tgz#41ba478a558b9f554793075b2e20cd2ef973be17" @@ -5159,6 +5218,13 @@ dependencies: "@octokit/types" "^12.6.0" +"@octokit/plugin-rest-endpoint-methods@^13.0.0": + version "13.2.1" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.2.1.tgz#b5e9118b4e76180cee65e03b71bcfcf632ae12d9" + integrity sha512-YMWBw6Exh1ZBs5cCE0AnzYxSQDIJS00VlBqISTgNYmu5MBdeM07K/MAJjy/VkNaH5jpJmD/5HFUvIZ+LDB5jSQ== + dependencies: + "@octokit/types" "^13.5.0" + "@octokit/request-error@^5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.1.0.tgz#ee4138538d08c81a60be3f320cd71063064a3b30" @@ -5168,6 +5234,13 @@ deprecation "^2.0.0" once "^1.4.0" +"@octokit/request-error@^6.0.1": + version "6.1.1" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-6.1.1.tgz#bed1b5f52ce7fefb1077a92bf42124ff36f73f2c" + integrity sha512-1mw1gqT3fR/WFvnoVpY/zUM2o/XkMs/2AszUUG9I69xn0JFLv6PGkPhNk5lbfvROs79wiS0bqiJNxfCZcRJJdg== + dependencies: + "@octokit/types" "^13.0.0" + "@octokit/request@^8.3.0", "@octokit/request@^8.3.1": version "8.4.0" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-8.4.0.tgz#7f4b7b1daa3d1f48c0977ad8fffa2c18adef8974" @@ -5178,6 +5251,26 @@ "@octokit/types" "^13.1.0" universal-user-agent "^6.0.0" +"@octokit/request@^9.0.0": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-9.1.1.tgz#e836eb69c0fb4b59b6437af7716ca348a1232a52" + integrity sha512-pyAguc0p+f+GbQho0uNetNQMmLG1e80WjkIaqqgUkihqUp0boRU6nKItXO4VWnr+nbZiLGEyy4TeKRwqaLvYgw== + dependencies: + "@octokit/endpoint" "^10.0.0" + "@octokit/request-error" "^6.0.1" + "@octokit/types" "^13.1.0" + universal-user-agent "^7.0.2" + +"@octokit/rest@^21.0.0": + version "21.0.0" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-21.0.0.tgz#bde4b657193643b6b691810fe890755a3c67dd9f" + integrity sha512-XudXXOmiIjivdjNZ+fN71NLrnDM00sxSZlhqmPR3v0dVoJwyP628tSlc12xqn8nX3N0965583RBw5GPo6r8u4Q== + dependencies: + "@octokit/core" "^6.1.2" + "@octokit/plugin-paginate-rest" "^11.0.0" + "@octokit/plugin-request-log" "^5.1.0" + "@octokit/plugin-rest-endpoint-methods" "^13.0.0" + "@octokit/types@^12.6.0": version "12.6.0" resolved "https://registry.yarnpkg.com/@octokit/types/-/types-12.6.0.tgz#8100fb9eeedfe083aae66473bd97b15b62aedcb2" @@ -5185,7 +5278,7 @@ dependencies: "@octokit/openapi-types" "^20.0.0" -"@octokit/types@^13.0.0", "@octokit/types@^13.1.0": +"@octokit/types@^13.0.0", "@octokit/types@^13.1.0", "@octokit/types@^13.5.0": version "13.5.0" resolved "https://registry.yarnpkg.com/@octokit/types/-/types-13.5.0.tgz#4796e56b7b267ebc7c921dcec262b3d5bfb18883" integrity sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ== @@ -12381,6 +12474,11 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== +before-after-hook@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-3.0.2.tgz#d5665a5fa8b62294a5aa0a499f933f4a1016195d" + integrity sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A== + big-integer@1.6.x: version "1.6.51" resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" @@ -14361,7 +14459,7 @@ debug@3.1.0: dependencies: ms "2.0.0" -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2: +debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@~4.3.1, debug@~4.3.2: version "4.3.5" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== @@ -26283,6 +26381,15 @@ simple-get@^4.0.0, simple-get@^4.0.1: once "^1.3.1" simple-concat "^1.0.0" +simple-git@^3.22.0: + version "3.25.0" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.25.0.tgz#3666e76d6831f0583dc380645945b97e0ac4aab6" + integrity sha512-KIY5sBnzc4yEcJXW7Tdv4viEz8KyG+nU0hay+DWZasvdFOYKeUZ6Xc25LUHHjw0tinPT7O1eY6pzX7pRT1K8rw== + dependencies: + "@kwsites/file-exists" "^1.1.1" + "@kwsites/promise-deferred" "^1.1.1" + debug "^4.3.5" + simple-plist@^1.1.0: version "1.3.1" resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.3.1.tgz#16e1d8f62c6c9b691b8383127663d834112fb017" @@ -27870,6 +27977,11 @@ universal-user-agent@^6.0.0: resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== +universal-user-agent@^7.0.0, universal-user-agent@^7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-7.0.2.tgz#52e7d0e9b3dc4df06cc33cb2b9fd79041a54827e" + integrity sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q== + universalify@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" From bb5e0e2cfb81f3ac4d300d46585eac7915994a93 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 14:35:48 -0600 Subject: [PATCH 02/25] moved create release scripts to .github and edited for testing --- {scripts => .github/scripts}/changelog-csv.sh | 0 {scripts => .github/scripts}/create-release-pr.sh | 0 {scripts => .github/scripts}/generate-rc-commits.mjs | 0 .github/workflows/create-release-pr.yml | 11 ++++++++++- package.json | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) rename {scripts => .github/scripts}/changelog-csv.sh (100%) rename {scripts => .github/scripts}/create-release-pr.sh (100%) rename {scripts => .github/scripts}/generate-rc-commits.mjs (100%) diff --git a/scripts/changelog-csv.sh b/.github/scripts/changelog-csv.sh similarity index 100% rename from scripts/changelog-csv.sh rename to .github/scripts/changelog-csv.sh diff --git a/scripts/create-release-pr.sh b/.github/scripts/create-release-pr.sh similarity index 100% rename from scripts/create-release-pr.sh rename to .github/scripts/create-release-pr.sh diff --git a/scripts/generate-rc-commits.mjs b/.github/scripts/generate-rc-commits.mjs similarity index 100% rename from scripts/generate-rc-commits.mjs rename to .github/scripts/generate-rc-commits.mjs diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 87609ee4f96..b77a04b3688 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -12,7 +12,9 @@ on: version-number: description: 'A natural version number. eg: 862' required: true - + previous-version-tag: + description: 'Previous release version tag. eg: v7.7.0' + required: true jobs: create-release-pr: runs-on: ubuntu-latest @@ -51,3 +53,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ./scripts/create-release-pr.sh ${{ github.event.inputs.semver-version }} + - name: Create Changelog + id: create-changelog + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + node ./scripts/generate-rc-commits.js v7.24.0 ${{ github.event.inputs.semver-version }} && ./scripts/changelog-csv.sh \ No newline at end of file diff --git a/package.json b/package.json index 1866c79f266..8be360a482e 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "changeset-changelog": "wrap () { node ./scripts/generate-rc-commits.js \"$@\" && ./scripts/changelog-csv.sh }; wrap ", "prestorybook": "rnstl", "deduplicate": "yarn yarn-deduplicate && yarn install", - "create-release": "./scripts/set-versions.sh && yarn update-changelog", + "create-release": "./scripts/set-versions.sh", "add-release-label-to-pr-and-linked-issues": "ts-node ./.github/scripts/add-release-label-to-pr-and-linked-issues.ts", "add-team-label-to-pr": "ts-node ./.github/scripts/add-team-label-to-pr.ts", "run-bitrise-e2e-check": "ts-node ./.github/scripts/bitrise/run-bitrise-e2e-check.ts", From 682fb7a4653e334c2d93066dd1b3d2e528a74fcc Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 14:43:11 -0600 Subject: [PATCH 03/25] updated script to take in args --- .github/scripts/create-release-pr.sh | 13 +++++++++++-- .github/workflows/create-release-pr.yml | 9 +-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/scripts/create-release-pr.sh b/.github/scripts/create-release-pr.sh index c0523b242b7..85d7cf2f71c 100755 --- a/.github/scripts/create-release-pr.sh +++ b/.github/scripts/create-release-pr.sh @@ -4,8 +4,9 @@ set -e set -u set -o pipefail -NEW_VERSION="${1}" -RELEASE_BRANCH_PREFIX="release/" +PREVIOUS_VERSION="${1}" +NEW_VERSION="${2}" +RELEASE_BRANCH_PREFIX="test-release/" if [[ -z $NEW_VERSION ]]; then echo "Error: No new version specified." @@ -33,3 +34,11 @@ gh pr create \ --title "${NEW_VERSION}" \ --body "${RELEASE_BODY}" \ --head "${RELEASE_BRANCH_NAME}"; + +node ./generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" + +./changelog-csv.sh + +git commit -am "updated changelog and generated feature test plan" + +git push "${RELEASE_BRANCH_NAME}" \ No newline at end of file diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index b77a04b3688..c0c9a49ed41 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -52,11 +52,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - ./scripts/create-release-pr.sh ${{ github.event.inputs.semver-version }} - - name: Create Changelog - id: create-changelog - shell: bash - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - node ./scripts/generate-rc-commits.js v7.24.0 ${{ github.event.inputs.semver-version }} && ./scripts/changelog-csv.sh \ No newline at end of file + ./scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} \ No newline at end of file From 812661d03b677bab83d29fc2e1c22e89dffd83b3 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 14:47:30 -0600 Subject: [PATCH 04/25] set the base branch to test for RC cut --- .github/scripts/create-release-pr.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/scripts/create-release-pr.sh b/.github/scripts/create-release-pr.sh index 85d7cf2f71c..9a20242a891 100755 --- a/.github/scripts/create-release-pr.sh +++ b/.github/scripts/create-release-pr.sh @@ -19,6 +19,9 @@ RELEASE_BODY="This is the release candidate for version ${NEW_VERSION}." git config user.name metamaskbot git config user.email metamaskbot@users.noreply.github.com +#TODO remove +git checkout chore/changelog-release-automation + git checkout -b "${RELEASE_BRANCH_NAME}" if ! (git add . && git commit -m "${NEW_VERSION}"); From f4aecd6f177b6760164decd35c18675a5f684044 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 14:56:26 -0600 Subject: [PATCH 05/25] fix path --- .github/workflows/create-release-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index c0c9a49ed41..ac3733efe2d 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -52,4 +52,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - ./scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} \ No newline at end of file + .github/scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} \ No newline at end of file From f2f046a81856b55f6893b97b1eb7066756ce78b9 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 14:59:06 -0600 Subject: [PATCH 06/25] fix path --- .github/scripts/create-release-pr.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/create-release-pr.sh b/.github/scripts/create-release-pr.sh index 9a20242a891..1540861f71b 100755 --- a/.github/scripts/create-release-pr.sh +++ b/.github/scripts/create-release-pr.sh @@ -34,13 +34,13 @@ git push --set-upstream origin "${RELEASE_BRANCH_NAME}" gh pr create \ --draft \ - --title "${NEW_VERSION}" \ + --title TESTING "${NEW_VERSION}" \ --body "${RELEASE_BODY}" \ --head "${RELEASE_BRANCH_NAME}"; -node ./generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" +node .github/scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" -./changelog-csv.sh +.github/scripts/changelog-csv.sh git commit -am "updated changelog and generated feature test plan" From c44be1103b7b2800d42cae4783447b7d2ca35df8 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:01:58 -0600 Subject: [PATCH 07/25] fix PR create msg --- .github/scripts/create-release-pr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/create-release-pr.sh b/.github/scripts/create-release-pr.sh index 1540861f71b..45e94eb0223 100755 --- a/.github/scripts/create-release-pr.sh +++ b/.github/scripts/create-release-pr.sh @@ -34,7 +34,7 @@ git push --set-upstream origin "${RELEASE_BRANCH_NAME}" gh pr create \ --draft \ - --title TESTING "${NEW_VERSION}" \ + --title "TESTING ${NEW_VERSION}" \ --body "${RELEASE_BODY}" \ --head "${RELEASE_BRANCH_NAME}"; From 8b0a6d0e7bd34e594c38cc5b45c40f2354869829 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:06:24 -0600 Subject: [PATCH 08/25] fix deps for action --- .github/workflows/create-release-pr.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index ac3733efe2d..6c1173ef9e6 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -36,12 +36,20 @@ jobs: # The workaround is to use a personal access token (BUG_REPORT_TOKEN) instead of # the default GITHUB_TOKEN for the checkout action. token: ${{ secrets.BUG_REPORT_TOKEN }} - - name: Get Node.js version - id: nvm - run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_OUTPUT" - - uses: actions/setup-node@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 with: - node-version: ${{ steps.nvm.outputs.NODE_VERSION }} + node-version-file: '.nvmrc' + cache: yarn + + - name: Install dependencies + run: yarn --immutable + # - name: Get Node.js version + # id: nvm + # run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_OUTPUT" + # - uses: actions/setup-node@v3 + # with: + # node-version: ${{ steps.nvm.outputs.NODE_VERSION }} - name: Set Versions id: set-versions shell: bash From 65b1417cd2e68508dfebbff7390f8a9d0a564750 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:13:07 -0600 Subject: [PATCH 09/25] moved script files --- {.github/scripts => scripts}/changelog-csv.sh | 0 {.github/scripts => scripts}/create-release-pr.sh | 2 +- {.github/scripts => scripts}/generate-rc-commits.mjs | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {.github/scripts => scripts}/changelog-csv.sh (100%) rename {.github/scripts => scripts}/create-release-pr.sh (96%) rename {.github/scripts => scripts}/generate-rc-commits.mjs (100%) diff --git a/.github/scripts/changelog-csv.sh b/scripts/changelog-csv.sh similarity index 100% rename from .github/scripts/changelog-csv.sh rename to scripts/changelog-csv.sh diff --git a/.github/scripts/create-release-pr.sh b/scripts/create-release-pr.sh similarity index 96% rename from .github/scripts/create-release-pr.sh rename to scripts/create-release-pr.sh index 45e94eb0223..f6e5c1597d6 100755 --- a/.github/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -44,4 +44,4 @@ node .github/scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BR git commit -am "updated changelog and generated feature test plan" -git push "${RELEASE_BRANCH_NAME}" \ No newline at end of file +git push \ No newline at end of file diff --git a/.github/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs similarity index 100% rename from .github/scripts/generate-rc-commits.mjs rename to scripts/generate-rc-commits.mjs From 7a156d602a81f615f82ab430fea4f54c6a25d5d4 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:17:14 -0600 Subject: [PATCH 10/25] fix paths --- .github/workflows/create-release-pr.yml | 9 +-------- scripts/create-release-pr.sh | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 6c1173ef9e6..302a69699dd 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -41,15 +41,8 @@ jobs: with: node-version-file: '.nvmrc' cache: yarn - - name: Install dependencies run: yarn --immutable - # - name: Get Node.js version - # id: nvm - # run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_OUTPUT" - # - uses: actions/setup-node@v3 - # with: - # node-version: ${{ steps.nvm.outputs.NODE_VERSION }} - name: Set Versions id: set-versions shell: bash @@ -60,4 +53,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - .github/scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} \ No newline at end of file + .scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} \ No newline at end of file diff --git a/scripts/create-release-pr.sh b/scripts/create-release-pr.sh index f6e5c1597d6..a97f11fa2e2 100755 --- a/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -38,9 +38,9 @@ gh pr create \ --body "${RELEASE_BODY}" \ --head "${RELEASE_BRANCH_NAME}"; -node .github/scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" +node .scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" -.github/scripts/changelog-csv.sh +.scripts/changelog-csv.sh git commit -am "updated changelog and generated feature test plan" From a37519f8507c68e003e1d0708cf1926e5fb9801f Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:22:59 -0600 Subject: [PATCH 11/25] fix paths and PR text --- .github/workflows/create-release-pr.yml | 2 +- scripts/create-release-pr.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 302a69699dd..4f03fec09c9 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -53,4 +53,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - .scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} \ No newline at end of file + ./scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} \ No newline at end of file diff --git a/scripts/create-release-pr.sh b/scripts/create-release-pr.sh index a97f11fa2e2..448c97384d4 100755 --- a/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -14,7 +14,7 @@ if [[ -z $NEW_VERSION ]]; then fi RELEASE_BRANCH_NAME="${RELEASE_BRANCH_PREFIX}${NEW_VERSION}" -RELEASE_BODY="This is the release candidate for version ${NEW_VERSION}." +RELEASE_BODY="This is the release candidate for version ${NEW_VERSION}. \n \n The test csv can be found at ./commit.csv" git config user.name metamaskbot git config user.email metamaskbot@users.noreply.github.com @@ -34,13 +34,13 @@ git push --set-upstream origin "${RELEASE_BRANCH_NAME}" gh pr create \ --draft \ - --title "TESTING ${NEW_VERSION}" \ + --title "feat: TESTING ${NEW_VERSION}" \ --body "${RELEASE_BODY}" \ --head "${RELEASE_BRANCH_NAME}"; -node .scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" +node ./scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" -.scripts/changelog-csv.sh +./scripts/changelog-csv.sh git commit -am "updated changelog and generated feature test plan" From 8c7b2d41f407d5f506ce32d7999dd7fdefafc020 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:44:06 -0600 Subject: [PATCH 12/25] update csv script --- scripts/create-release-pr.sh | 5 ++-- scripts/generate-rc-commits.mjs | 47 ++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/scripts/create-release-pr.sh b/scripts/create-release-pr.sh index 448c97384d4..882176f95a6 100755 --- a/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -38,10 +38,9 @@ gh pr create \ --body "${RELEASE_BODY}" \ --head "${RELEASE_BRANCH_NAME}"; +#Generate changelog and test plan csv node ./scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" - ./scripts/changelog-csv.sh - +git add ./scripts/commits.csv git commit -am "updated changelog and generated feature test plan" - git push \ No newline at end of file diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index 24afc2eb9cc..bb00a603403 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -28,11 +28,14 @@ async function getPRLabels(prNumber) { // Check if any label name contains "team" const hasTeamLabel = labels.filter(label => label.toLowerCase().includes('team')); + if(hasTeamLabel.length > 1 && hasTeamLabel.includes('team-mobile-platform')) + hasTeamLabel = hasTeamLabel.filter(item => item !== 'team-mobile-platform'); + return hasTeamLabel || 'Unknown'; } catch (error) { console.error(`Error fetching labels for PR #${prNumber}:`, error); - return []; + return 'Unknown'; } } @@ -65,28 +68,28 @@ async function filterCommitsByTeam(branchA, branchB) { } // Extract PR number from the commit message using regex - const prMatch = message.match(/\(#(\d{5})\)$/u); - const prLink = prMatch ? `https://github.com/MetaMask/metamask-mobile/pull/${prMatch[1]}` : ''; - - const team = await getPRLabels(prMatch); - console.log(team); - - // Check if the commit message is unique - if (!seenMessages.has(message)) { - seenMessagesArray.push(message); - seenMessages.add(message); - - // Initialize the team's commits array if it doesn't exist - if (!commitsByTeam[team]) { - commitsByTeam[team] = []; + const prMatch = message.match(/\(#(\d{4,5})\)$/u); + if(prMatch){ + const prLink = prMatch ? `https://github.com/MetaMask/metamask-mobile/pull/${prMatch[1]}` : ''; + const team = await getPRLabels(prMatch); + + // Check if the commit message is unique + if (!seenMessages.has(message)) { + seenMessagesArray.push(message); + seenMessages.add(message); + + // Initialize the team's commits array if it doesn't exist + if (!commitsByTeam[team]) { + commitsByTeam[team] = []; + } + + commitsByTeam[team].push({ + message, + author, + hash: hash.substring(0, 10), + prLink, + }); } - - commitsByTeam[team].push({ - message, - author, - hash: hash.substring(0, 10), - prLink, - }); } } From 4a2faf5a8768a743e5040ba190cbf978f1cf1f51 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:48:20 -0600 Subject: [PATCH 13/25] update csv script to use let --- scripts/generate-rc-commits.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index bb00a603403..a2215a5a20a 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -26,7 +26,7 @@ async function getPRLabels(prNumber) { const labels = data.labels.map(label => label.name); // Check if any label name contains "team" - const hasTeamLabel = labels.filter(label => label.toLowerCase().includes('team')); + let hasTeamLabel = labels.filter(label => label.toLowerCase().includes('team')); if(hasTeamLabel.length > 1 && hasTeamLabel.includes('team-mobile-platform')) hasTeamLabel = hasTeamLabel.filter(item => item !== 'team-mobile-platform'); From b29266590623933078d2dfaff0b97166c84bc506 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 15:53:13 -0600 Subject: [PATCH 14/25] updated path --- scripts/create-release-pr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-release-pr.sh b/scripts/create-release-pr.sh index 882176f95a6..11cd2d90e76 100755 --- a/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -41,6 +41,6 @@ gh pr create \ #Generate changelog and test plan csv node ./scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" ./scripts/changelog-csv.sh -git add ./scripts/commits.csv +git add ./commits.csv git commit -am "updated changelog and generated feature test plan" git push \ No newline at end of file From 8f979f71f7b72b6468997706b8bf10992c752e37 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 28 Jun 2024 16:24:41 -0600 Subject: [PATCH 15/25] updated deps and move to devDeps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8be360a482e..7427dcd5d1c 100644 --- a/package.json +++ b/package.json @@ -190,7 +190,6 @@ "@metamask/utils": "^8.1.0", "@ngraveio/bc-ur": "^1.1.6", "@notifee/react-native": "^7.8.2", - "@octokit/rest": "^21.0.0", "@react-native-async-storage/async-storage": "^1.23.1", "@react-native-clipboard/clipboard": "1.8.4", "@react-native-community/blur": "4.3.2", @@ -340,7 +339,6 @@ "redux-thunk": "^2.4.2", "reselect": "^4.0.0", "rxjs": "^7.8.1", - "simple-git": "^3.22.0", "socket.io-client": "^4.5.3", "stream-browserify": "3.0.0", "through2": "3.0.1", @@ -373,6 +371,7 @@ "@metamask/object-multiplex": "^1.1.0", "@metamask/providers": "^13.1.0", "@metamask/test-dapp": "^8.9.0", + "@octokit/rest": "^21.0.0", "@open-rpc/mock-server": "^1.7.5", "@open-rpc/schema-utils-js": "^1.16.2", "@open-rpc/test-coverage": "^2.2.2", @@ -479,6 +478,7 @@ "regenerator-runtime": "0.13.9", "rn-nodeify": "10.3.0", "serve-handler": "^6.1.5", + "simple-git": "^3.22.0", "ts-node": "^10.5.0", "typescript": "~4.8.4", "wdio-cucumberjs-json-reporter": "^4.4.3", From 638cf2a64fdadd4b1d484643e8239bb867ce5f0d Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 14:52:52 -0600 Subject: [PATCH 16/25] updated yarn command --- .github/workflows/create-release-pr.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 4f03fec09c9..58c8c4152d2 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -46,7 +46,7 @@ jobs: - name: Set Versions id: set-versions shell: bash - run: SEMVER_VERSION=${{ github.event.inputs.semver-version }} VERSION_NUMBER=${{ github.event.inputs.version-number }} yarn create-release + run: SEMVER_VERSION=${{ github.event.inputs.semver-version }} VERSION_NUMBER=${{ github.event.inputs.version-number }} yarn set-version - name: Create Release PR id: create-release-pr shell: bash diff --git a/package.json b/package.json index 7427dcd5d1c..15fbd9d715f 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "changeset-changelog": "wrap () { node ./scripts/generate-rc-commits.js \"$@\" && ./scripts/changelog-csv.sh }; wrap ", "prestorybook": "rnstl", "deduplicate": "yarn yarn-deduplicate && yarn install", - "create-release": "./scripts/set-versions.sh", + "set-version": "./scripts/set-versions.sh", "add-release-label-to-pr-and-linked-issues": "ts-node ./.github/scripts/add-release-label-to-pr-and-linked-issues.ts", "add-team-label-to-pr": "ts-node ./.github/scripts/add-team-label-to-pr.ts", "run-bitrise-e2e-check": "ts-node ./.github/scripts/bitrise/run-bitrise-e2e-check.ts", From 5c92492732d11765deea0545960421d0d359efa3 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:02:31 -0600 Subject: [PATCH 17/25] added release value arg --- scripts/changelog-csv.sh | 7 ++++++- scripts/create-release-pr.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/changelog-csv.sh b/scripts/changelog-csv.sh index ab80ab3ecaf..eb97545b59c 100755 --- a/scripts/changelog-csv.sh +++ b/scripts/changelog-csv.sh @@ -5,8 +5,13 @@ set -u set -o pipefail readonly CSV_FILE='commits.csv' + +# Add release branch arg name +RELEASE_BRANCH_NAME="${1}" + # Temporary file for new entries NEW_ENTRIES=$(mktemp) + # Backup file for existing CHANGELOG CHANGELOG_BACKUP="CHANGELOG.md.bak" @@ -47,7 +52,7 @@ insert_new_entries() { # Append the release header echo "" >> "$temp_changelog" - echo "## - " >> "$temp_changelog" + echo "## $RELEASE_BRANCH_NAME - " >> "$temp_changelog" echo "" >> "$temp_changelog" # Append new entries for each change type if they exist diff --git a/scripts/create-release-pr.sh b/scripts/create-release-pr.sh index 11cd2d90e76..c2aec7c9c73 100755 --- a/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -40,7 +40,7 @@ gh pr create \ #Generate changelog and test plan csv node ./scripts/generate-rc-commits.mjs "${PREVIOUS_VERSION}" "${RELEASE_BRANCH_NAME}" -./scripts/changelog-csv.sh +./scripts/changelog-csv.sh "${RELEASE_BRANCH_NAME}" git add ./commits.csv git commit -am "updated changelog and generated feature test plan" git push \ No newline at end of file From c08dbf0c332010fa40fa00c5ccc748b2649354a6 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:17:12 -0600 Subject: [PATCH 18/25] added trap and refactor constants --- scripts/changelog-csv.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/changelog-csv.sh b/scripts/changelog-csv.sh index eb97545b59c..05ab977b0fc 100755 --- a/scripts/changelog-csv.sh +++ b/scripts/changelog-csv.sh @@ -6,17 +6,18 @@ set -o pipefail readonly CSV_FILE='commits.csv' -# Add release branch arg name +# Add release branch arg name RELEASE_BRANCH_NAME="${1}" # Temporary file for new entries NEW_ENTRIES=$(mktemp) # Backup file for existing CHANGELOG -CHANGELOG_BACKUP="CHANGELOG.md.bak" +CHANGELOG="CHANGELOG.md" +CHANGELOG_BACKUP="$CHANGELOG.bak" # Backup existing CHANGELOG.md -cp CHANGELOG.md "$CHANGELOG_BACKUP" +cp "$CHANGELOG" "$CHANGELOG_BACKUP" # Function to append entry to the correct category in the temp file append_entry() { @@ -41,7 +42,6 @@ done < <(tail -n +2 "$CSV_FILE") # Skip the header line # Function to insert new entries into CHANGELOG.md after a specific line insert_new_entries() { local marker="## Current Main Branch" - local changelog="CHANGELOG.md" local temp_changelog=$(mktemp) # Find the line number of the marker @@ -68,13 +68,13 @@ insert_new_entries() { tail -n +$((line_num + 1)) "$CHANGELOG_BACKUP" >> "$temp_changelog" # Replace the original CHANGELOG with the updated one - mv "$temp_changelog" "$changelog" + mv "$temp_changelog" "$CHANGELOG" } +# Trap to ensure cleanup happens +trap 'rm -f "$NEW_ENTRIES-"* "$CHANGELOG_BACKUP"' EXIT + # Insert new entries into CHANGELOG.md insert_new_entries -# Cleanup -rm "$NEW_ENTRIES-"* "$CHANGELOG_BACKUP" - echo 'CHANGELOG updated' \ No newline at end of file From 24516dd37a1a22da9ff08b583086c3205dcf1b28 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:21:56 -0600 Subject: [PATCH 19/25] updated team variable name and logic --- scripts/create-release-pr.sh | 2 +- scripts/generate-rc-commits.mjs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/create-release-pr.sh b/scripts/create-release-pr.sh index c2aec7c9c73..2737bd13d89 100755 --- a/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -14,7 +14,7 @@ if [[ -z $NEW_VERSION ]]; then fi RELEASE_BRANCH_NAME="${RELEASE_BRANCH_PREFIX}${NEW_VERSION}" -RELEASE_BODY="This is the release candidate for version ${NEW_VERSION}. \n \n The test csv can be found at ./commit.csv" +RELEASE_BODY="This is the release candidate for version ${NEW_VERSION}. \n\nThe test csv can be found at [./commit.csv](commit.csv)" git config user.name metamaskbot git config user.email metamaskbot@users.noreply.github.com diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index a2215a5a20a..2f19f7aeb6f 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -26,12 +26,12 @@ async function getPRLabels(prNumber) { const labels = data.labels.map(label => label.name); // Check if any label name contains "team" - let hasTeamLabel = labels.filter(label => label.toLowerCase().includes('team')); + let teamArray = labels.filter(label => label.toLowerCase().startsWith('team-')); - if(hasTeamLabel.length > 1 && hasTeamLabel.includes('team-mobile-platform')) - hasTeamLabel = hasTeamLabel.filter(item => item !== 'team-mobile-platform'); + if(teamArray.length > 1 && teamArray.includes('team-mobile-platform')) + teamArray = teamArray.filter(item => item !== 'team-mobile-platform'); - return hasTeamLabel || 'Unknown'; + return teamArray || 'Unknown'; } catch (error) { console.error(`Error fetching labels for PR #${prNumber}:`, error); From 8f2a7b4e40cd5ac726b581b926603a11560551d5 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:27:40 -0600 Subject: [PATCH 20/25] added error log if we are processing more than 500 commits --- scripts/generate-rc-commits.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index 2f19f7aeb6f..f6e5bf15387 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -64,6 +64,7 @@ async function filterCommitsByTeam(branchA, branchB) { for (const commit of log.all) { const { author, message, hash } = commit; if (commitsByTeam.length >= MAX_COMMITS) { + console.error('Too many commits for script to work') break; } @@ -71,7 +72,7 @@ async function filterCommitsByTeam(branchA, branchB) { const prMatch = message.match(/\(#(\d{4,5})\)$/u); if(prMatch){ const prLink = prMatch ? `https://github.com/MetaMask/metamask-mobile/pull/${prMatch[1]}` : ''; - const team = await getPRLabels(prMatch); + const teams = await getPRLabels(prMatch); // Check if the commit message is unique if (!seenMessages.has(message)) { @@ -79,8 +80,8 @@ async function filterCommitsByTeam(branchA, branchB) { seenMessages.add(message); // Initialize the team's commits array if it doesn't exist - if (!commitsByTeam[team]) { - commitsByTeam[team] = []; + if (!commitsByTeam[teams]) { + commitsByTeam[teams] = []; } commitsByTeam[team].push({ From bdba6e30e8f4e6765d09a2c8ea601b6a43702f1c Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:30:11 -0600 Subject: [PATCH 21/25] removed unused array and formatting --- scripts/generate-rc-commits.mjs | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index f6e5bf15387..1c51aa15a49 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -55,8 +55,6 @@ async function filterCommitsByTeam(branchA, branchB) { }; const log = await git.log(logOptions); - const seenMessages = new Set(); - const seenMessagesArray = []; const commitsByTeam = {}; const MAX_COMMITS = 500; // Limit the number of commits to process @@ -74,26 +72,19 @@ async function filterCommitsByTeam(branchA, branchB) { const prLink = prMatch ? `https://github.com/MetaMask/metamask-mobile/pull/${prMatch[1]}` : ''; const teams = await getPRLabels(prMatch); - // Check if the commit message is unique - if (!seenMessages.has(message)) { - seenMessagesArray.push(message); - seenMessages.add(message); - - // Initialize the team's commits array if it doesn't exist - if (!commitsByTeam[teams]) { - commitsByTeam[teams] = []; - } - - commitsByTeam[team].push({ - message, - author, - hash: hash.substring(0, 10), - prLink, - }); + // Initialize the team's commits array if it doesn't exist + if (!commitsByTeam[teams]) { + commitsByTeam[teams] = []; } + + commitsByTeam[team].push({ + message, + author, + hash: hash.substring(0, 10), + prLink, + }); } } - return commitsByTeam; } catch (error) { console.error(error); From 903c347dd82783bc70b1d3aee892b357039f0e6a Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:30:58 -0600 Subject: [PATCH 22/25] reduced hash length to standard --- scripts/generate-rc-commits.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index 1c51aa15a49..52726e01149 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -80,7 +80,7 @@ async function filterCommitsByTeam(branchA, branchB) { commitsByTeam[team].push({ message, author, - hash: hash.substring(0, 10), + hash: hash.substring(0, 7), prLink, }); } From 1346f7b0ef41b3a18d20cfd2f3ed5c055ed4f5b6 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:48:38 -0600 Subject: [PATCH 23/25] updated console logs --- scripts/generate-rc-commits.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index 52726e01149..fa59c2a1195 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -134,9 +134,10 @@ function assignChangeType(field) { async function main() { const args = process.argv.slice(2); + const fileTitle = 'commits.csv'; if (args.length !== 2) { - console.error('Usage: node script.js branchA branchB'); + console.error('Usage: node generate-rc-commits.mjs branchA branchB'); process.exit(1); } @@ -146,10 +147,10 @@ async function main() { const commitsByTeam = await filterCommitsByTeam(branchA, branchB); if (Object.keys(commitsByTeam).length === 0) { - console.log('No unique commits found.'); + console.log('No commits found.'); } else { const csvContent = formatAsCSV(commitsByTeam); - fs.writeFileSync('commits.csv', csvContent.join('\n')); + fs.writeFileSync(fileTitle, csvContent.join('\n')); console.log('CSV file "commits.csv" created successfully.'); } } From 40aa5889cae7cf23b6b86552a5da9fa75df00643 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 1 Jul 2024 15:49:34 -0600 Subject: [PATCH 24/25] updated console log --- scripts/generate-rc-commits.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-rc-commits.mjs b/scripts/generate-rc-commits.mjs index fa59c2a1195..13b97b10f3c 100644 --- a/scripts/generate-rc-commits.mjs +++ b/scripts/generate-rc-commits.mjs @@ -151,7 +151,7 @@ async function main() { } else { const csvContent = formatAsCSV(commitsByTeam); fs.writeFileSync(fileTitle, csvContent.join('\n')); - console.log('CSV file "commits.csv" created successfully.'); + console.log('CSV file ', fileTitle, ' created successfully.'); } } From c793a2baa7162bf3ed9af622cf9dee1eb7db4682 Mon Sep 17 00:00:00 2001 From: metamaskbot Date: Tue, 2 Jul 2024 20:31:37 +0000 Subject: [PATCH 25/25] 7.26.1 --- android/app/build.gradle | 4 ++-- bitrise.yml | 8 ++++---- ios/MetaMask.xcodeproj/project.pbxproj | 24 ++++++++++++------------ package.json | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index b9d2c2f58e5..bd7a911be2e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -181,8 +181,8 @@ android { applicationId "io.metamask" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 1354 - versionName "7.24.4" + versionCode 1358 + versionName "7.26.1" testBuildType System.getProperty('testBuildType', 'debug') missingDimensionStrategy 'react-native-camera', 'general' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/bitrise.yml b/bitrise.yml index b1ccc6af85c..0e89bfbe1e4 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -1471,16 +1471,16 @@ app: PROJECT_LOCATION_IOS: ios - opts: is_expand: false - VERSION_NAME: 7.24.4 + VERSION_NAME: 7.26.1 - opts: is_expand: false - VERSION_NUMBER: 1354 + VERSION_NUMBER: 1358 - opts: is_expand: false - FLASK_VERSION_NAME: 7.24.4 + FLASK_VERSION_NAME: 7.26.1 - opts: is_expand: false - FLASK_VERSION_NUMBER: 1354 + FLASK_VERSION_NUMBER: 1358 - opts: is_expand: false ANDROID_APK_LINK: '' diff --git a/ios/MetaMask.xcodeproj/project.pbxproj b/ios/MetaMask.xcodeproj/project.pbxproj index e6c756b9576..5175f8e8e48 100644 --- a/ios/MetaMask.xcodeproj/project.pbxproj +++ b/ios/MetaMask.xcodeproj/project.pbxproj @@ -1207,7 +1207,7 @@ CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMaskDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1354; + CURRENT_PROJECT_VERSION = 1358; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = 48XVW22RCG; @@ -1244,7 +1244,7 @@ "${inherited}", ); LLVM_LTO = YES; - MARKETING_VERSION = 7.24.4; + MARKETING_VERSION = 7.26.1; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = ( @@ -1272,7 +1272,7 @@ CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMask.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1354; + CURRENT_PROJECT_VERSION = 1358; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 48XVW22RCG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 48XVW22RCG; @@ -1307,7 +1307,7 @@ "${inherited}", ); LLVM_LTO = YES; - MARKETING_VERSION = 7.24.4; + MARKETING_VERSION = 7.26.1; ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = ( @@ -1335,7 +1335,7 @@ CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMaskDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1354; + CURRENT_PROJECT_VERSION = 1358; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = 48XVW22RCG; @@ -1368,7 +1368,7 @@ ); LIBRARY_SEARCH_PATHS = "$(SDKROOT)/usr/lib/swift$(inherited)"; LLVM_LTO = YES; - MARKETING_VERSION = 7.24.4; + MARKETING_VERSION = 7.26.1; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = ( @@ -1396,7 +1396,7 @@ CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMask.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1354; + CURRENT_PROJECT_VERSION = 1358; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 48XVW22RCG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 48XVW22RCG; @@ -1427,7 +1427,7 @@ ); LIBRARY_SEARCH_PATHS = "$(SDKROOT)/usr/lib/swift$(inherited)"; LLVM_LTO = YES; - MARKETING_VERSION = 7.24.4; + MARKETING_VERSION = 7.26.1; ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = ( @@ -1554,7 +1554,7 @@ CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMaskDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1354; + CURRENT_PROJECT_VERSION = 1358; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = 48XVW22RCG; @@ -1591,7 +1591,7 @@ "\"$(SRCROOT)/MetaMask/System/Library/Frameworks\"", ); LLVM_LTO = YES; - MARKETING_VERSION = 7.24.4; + MARKETING_VERSION = 7.26.1; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "$(inherited)", @@ -1622,7 +1622,7 @@ CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMask.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1354; + CURRENT_PROJECT_VERSION = 1358; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 48XVW22RCG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 48XVW22RCG; @@ -1657,7 +1657,7 @@ "\"$(SRCROOT)/MetaMask/System/Library/Frameworks\"", ); LLVM_LTO = YES; - MARKETING_VERSION = 7.24.4; + MARKETING_VERSION = 7.26.1; ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = ( "$(inherited)", diff --git a/package.json b/package.json index 15fbd9d715f..8ebc07f7609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask", - "version": "7.24.4", + "version": "7.26.1", "private": true, "scripts": { "audit:ci": "./scripts/yarn-audit.sh",