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
31 changes: 0 additions & 31 deletions .github/semantic-release.json

This file was deleted.

14 changes: 10 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ jobs:
timeout-minutes: 60
release:
permissions:
contents: write # create releases (semantic-release)
id-token: write # enable use of OIDC for npm provenance (semantic-release)
contents: write # create releases (Nx Release)
id-token: write # enable use of OIDC for npm provenance (Nx Release)
needs:
- review
- ios
Expand All @@ -652,12 +652,18 @@ jobs:
- name: Verify tarball content
run: |
yarn test test/pack.test.ts
- name: Release (dry run)
if: ${{ github.ref != 'refs/heads/trunk' }}
run: |
yarn nx release --dry-run
Comment thread
tido64 marked this conversation as resolved.
- name: Release
if: ${{ github.ref == 'refs/heads/trunk' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: |
yarn semantic-release
yarn nx release
autobot:
name: "Autobot"
permissions:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
.cxx/
.gradle/
.idea/
.nx/cache
.nx/workspace-data
.vs/
.watchman-*
.yarn/*
Expand Down
28 changes: 28 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"defaultBase": "trunk",
"release": {
"projects": ["react-native-test-app"],
"projectsRelationship": "independent",
"changelog": {
"workspaceChangelog": false,
"projectChangelogs": {
"createRelease": "github",
"file": false,
"renderOptions": {
"applyUsernameToAuthors": false
}
}
},
"version": {
"conventionalCommits": true,
"versionActionsOptions": {
"skipLockFileUpdate": true
}
},
"releaseTagPattern": "{version}",
"git": {
"commit": false
}
}
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
"scripts": {
"format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm')",
"format:js": "prettier --write --log-level error $(git ls-files '*.[cm][jt]s' '*.[jt]s' '*.tsx' '*.yml' 'CONTRIBUTING.md' 'README.md' 'test/**/*.json' ':!:.yarn/releases')",
"format:js": "prettier --write --log-level error $(git ls-files '*.[cm][jt]s' '*.[jt]s' '*.tsx' '*.yml' '.github/*.json' 'CONTRIBUTING.md' 'README.md' 'nx.json' 'test/**/*.json' ':!:.yarn/releases')",
"format:swift": "swiftformat $(git ls-files '*.swift')",
"generate:code": "node --experimental-transform-types --no-warnings scripts/internal/generate-manifest.mts",
"generate:docs": "node --experimental-transform-types --no-warnings scripts/internal/generate-manifest-docs.mts",
Expand Down Expand Up @@ -124,10 +124,13 @@
"@babel/preset-env": "^7.20.0",
"@expo/config-plugins": "^9.0.0",
"@microsoft/eslint-plugin-sdl": "^1.0.0",
"@nx/js": "^21.0.0",
Comment thread
Saadnajmi marked this conversation as resolved.
"@react-native-community/cli": "^15.0.1",
"@react-native-community/template": "^0.78.0",
"@rnx-kit/eslint-plugin": "^0.8.0",
"@rnx-kit/tsconfig": "^2.0.0",
"@swc-node/register": "^1.10.0",
"@swc/core": "^1.11.0",
"@types/js-yaml": "^4.0.5",
"@types/mustache": "^4.0.0",
"@types/node": "^22.0.0",
Expand All @@ -138,13 +141,13 @@
"js-yaml": "^4.1.0",
"memfs": "^4.0.0",
"minimatch": "^9.0.0",
"nx": "^21.0.0",
"prettier": "^3.0.0",
"prettier-plugin-organize-imports": "^4.1.0",
"react": "19.0.0",
"react-native": "^0.78.0",
"react-native-macos": "^0.78.0",
"react-native-windows": "^0.78.0",
"semantic-release": "^24.0.0",
"suggestion-bot": "^3.0.0",
"typescript": "^5.0.0"
},
Expand Down Expand Up @@ -179,7 +182,6 @@
"@react-native/js-polyfills": "^0.78.0",
"@react-native/normalize-colors": "^0.78.0",
"@react-native/virtualized-lists": "^0.78.0",
"@semantic-release/npm/npm": "link:./example",
"appium/ajv": "^8.17.1",
"appium/axios": "^1.8.3",
"appium/semver": "^7.7.1",
Expand All @@ -196,6 +198,7 @@
"safe-buffer": "~5.2.1"
},
"workspaces": [
".",
"example"
],
"defaultPlatformPackages": {
Expand All @@ -205,8 +208,5 @@
"visionos": "@callstack/react-native-visionos",
"windows": "react-native-windows"
},
"prettier": "./.github/prettierrc.json",
"release": {
"extends": "./.github/semantic-release.json"
}
"prettier": "./.github/prettierrc.json"
}
174 changes: 123 additions & 51 deletions scripts/internal/release-notes.mts
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
/**
* This script is only used to help write release announcements.
*/
// @ts-expect-error Could not find a declaration file for module
import { generateNotes } from "@semantic-release/release-notes-generator";
import { spawn } from "node:child_process";
import * as path from "node:path";
import { URL, fileURLToPath } from "node:url";
import { readJSONFile } from "../helpers.js";
import type { Manifest } from "../types.js";
import { fileURLToPath } from "node:url";

function reformat(
output: string,
lastRelease: string,
nextRelease: string
): string {
const replacements: [RegExp, string][] = [
[/^# .*/m, `📣 react-native-test-app ${nextRelease}`],
[/^### .*/m, `Other fixes since ${lastRelease}:`],
[/^\* \*\*android:\*\*/gm, "* **Android:**"],
[/^\* \*\*apple:\*\*/gm, "* **Apple:**"],
[/^\* \*\*ios:\*\*/gm, "* **iOS:**"],
[/^\* \*\*macos:\*\*/gm, "* **macOS:**"],
[/^\* \*\*visionos:\*\*/gm, "* **visionOS:**"],
[/^\* \*\*windows:\*\*/gm, "* **Windows:**"],
[/\s*\(\[#\d+\]\(https:\/\/github.com.*/gm, ""],
];
return replacements
.reduce(
(output, [search, replace]) => output.replace(search, replace),
output
)
.trim();
type Commit = {
hash: string;
message: string;
};

type Group =
| "general"
| "android"
| "apple"
| "ios"
| "macos"
| "visionos"
| "windows";

type Changes = Record<string, Record<Group, string[]>>;

function assertCategory(category: string): asserts category is "feat" | "fix" {
if (category !== "feat" && category !== "fix") {
throw new Error(`Unknown category: ${category}`);
}
}

function repositoryUrl() {
const p = fileURLToPath(new URL("../../package.json", import.meta.url));
const manifest = readJSONFile<Manifest>(p);
return manifest.repository?.url;
function capitalize(s: string): string {
return String(s[0]).toUpperCase() + s.substring(1);
}

/**
* @param {string} lastRelease
* @param {string} nextRelease
*/
function main(lastRelease: string, nextRelease: string): void {
function getCommits(
lastRelease: string,
nextRelease: string,
callback: (commits: Commit[]) => void
): void {
const args = [
"log",
`--pretty=format:{ "hash": "%H", "message": "%s" }`,
Expand All @@ -68,33 +60,113 @@ function main(lastRelease: string, nextRelease: string): void {
.replaceAll('"', '\\"')
.replaceAll(""", '"')
.replaceAll("\n", ",");

const commits = JSON.parse(output);
if (commits.length === 0) {
return;
}

const context = {
commits,
lastRelease: { gitTag: lastRelease },
nextRelease: { gitTag: nextRelease },
options: {
repositoryUrl: repositoryUrl(),
},
cwd: process.cwd(),
};

const releaseNotes: Promise<string> = generateNotes({}, context);
releaseNotes
.then((output) => reformat(output, lastRelease, nextRelease))
.then((output) => console.log(output));
callback(commits);
});
}

function sanitizeGroup(group: string): Group {
switch (group) {
case "android":
case "apple":
case "ios":
case "macos":
case "visionos":
case "windows":
return group;
default:
return "general";
}
}

function parseCommits(commits: Commit[]): Changes {
const changes: Changes = {
feat: {
general: [],
android: [],
apple: [],
ios: [],
macos: [],
visionos: [],
windows: [],
},
fix: {
general: [],
android: [],
apple: [],
ios: [],
macos: [],
visionos: [],
windows: [],
},
};

for (const { message } of commits) {
const m = message.match(/^(feat|fix)(?:\((.*?)\))?: (.*)$/);
if (m) {
const [, cat, group, message] = m;
assertCategory(cat);
changes[cat][sanitizeGroup(group)].push(message);
}
}

return changes;
}

function renderGroup(group: string): string {
switch (group) {
case "android":
return "**Android:** ";
case "apple":
return "**Apple:** ";
case "ios":
return "**iOS:** ";
case "macos":
return "**macOS:** ";
case "visionos":
return "**visionOS:** ";
case "windows":
return "**Windows:** ";
default:
return "";
}
}

function renderCategory(
header: string,
changes: Changes[string],
output: string[]
): string[] {
const groups = Object.entries(changes);
if (groups.length > 0) {
output.push("", header, "");
for (const [group, entries] of groups) {
for (const entry of entries) {
output.push(`- ${renderGroup(group)}${capitalize(entry)}`);
}
}
}
return output;
}

const [, , lastRelease, nextRelease] = process.argv;
if (!lastRelease || !nextRelease) {
const thisScript = path.basename(fileURLToPath(import.meta.url));
console.log(`Usage: ${thisScript} <start tag> <end tag>`);
process.exitCode = 1;
} else {
main(lastRelease, nextRelease);
getCommits(lastRelease, nextRelease, (commits) => {
const { feat, fix } = parseCommits(commits);

const lines = [`📣 react-native-test-app ${nextRelease}`];
renderCategory("New features:", feat, lines);
renderCategory(`Fixes since ${lastRelease}:`, fix, lines);

console.log(lines.join("\n"));
});
}
Loading
Loading