Skip to content

Commit abf133e

Browse files
authored
fix: publish one combined GitHub release (#1503)
1 parent cfc11a6 commit abf133e

7 files changed

Lines changed: 344 additions & 3 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"name": "@callstack/repack",
4+
"version": "5.4.2",
5+
"changelog": "# @callstack/repack\n\n## 5.4.2\n\n### Patch Changes\n\n- [#1480](https://github.com/callstack/repack/pull/1480) [`166388b`](https://github.com/callstack/repack/commit/166388b76fc4641f15cd63d3e96aec9d7e582c84) Thanks [@CristiCeban](https://github.com/CristiCeban)! - Fix `.jpeg` images not showing in Android release builds. They were emitted to `raw` instead of `drawable-*`, where React Native looks for them.\n\n If you have a `.jpeg` and a `.png`/`.jpg`/`.gif`/`.webp` image with the same name in the same directory (e.g. `logo.png` and `logo.jpeg`), rename one of them. Both now resolve to the same Android drawable resource name, and the build fails with a duplicate resources error.\n\n- Updated dependencies []:\n - @callstack/repack-dev-server@5.4.2\n\n## 5.4.1\n\n### Patch Changes\n\n- [#1479](https://github.com/callstack/repack/pull/1479) [`811a6d8`](https://github.com/callstack/repack/commit/811a6d84ed09ad83f4395c85218e055e7e9abf91) Thanks [@CristiCeban](https://github.com/CristiCeban)! - Ship consumer ProGuard rules for the Android library so release builds with R8 (`minifyEnabled true`) no longer fail with missing `com.google.errorprone.annotations` classes referenced by `nimbus-jose-jwt`.\n\n- [#1476](https://github.com/callstack/repack/pull/1476) [`5bb41f0`](https://github.com/callstack/repack/commit/5bb41f045f43d935fc79b153f889a1195a0f19ad) Thanks [@whydidoo](https://github.com/whydidoo)! - Support React Native 0.88's Flow parser in Babel loaders, native component codegen, and Reanimated transforms while retaining Hermes parser compatibility with older React Native presets.\n\n- [#1473](https://github.com/callstack/repack/pull/1473) [`f9326a0`](https://github.com/callstack/repack/commit/f9326a0a5fcc7de753190fc7576b91320498dfa8) Thanks [@whydidoo](https://github.com/whydidoo)! - Emit an additional `res/raw` copy of bundled Android font binaries so Metro-compatible consumers such as Skia can load them by name. Preserve the existing `res/font` output for native `@font/...`, `R.font`, and XML font-family references. Generate `res/raw/keep.xml` for bundled Android resources so resource shrinking preserves both font copies and other assets loaded by name at runtime.\n\n XML font-family resources continue to use `res/font`. Asset metadata and iOS, development-server, inline, and remote-loader output paths are unchanged.\n\n- Updated dependencies []:\n - @callstack/repack-dev-server@5.4.1\n\n"
6+
},
7+
{
8+
"name": "@callstack/repack-dev-server",
9+
"version": "5.4.2",
10+
"changelog": "# @callstack/repack-dev-server\n\n## 5.4.2\n\n## 5.4.1\n\n"
11+
},
12+
{
13+
"name": "@callstack/repack-init",
14+
"version": "5.4.2",
15+
"changelog": "# @callstack/repack-init\n\n## 5.4.2\n\n### Patch Changes\n\n- [#1482](https://github.com/callstack/repack/pull/1482) [`4139cf3`](https://github.com/callstack/repack/commit/4139cf3b9fa5f0f80260bfd0b783621543bf3949) Thanks [@jacekAtCK](https://github.com/jacekAtCK)! - Bootstrap new projects with React Native 0.87.1 and refresh the default bundler dependencies to `@rspack/core@^1.7.12`, `@swc/helpers@^0.5.23`, `webpack@^5.111.1` and `terser-webpack-plugin@^5.6.1`. Generated Rspack and webpack configs now enable package exports (`getResolveOptions({ enablePackageExports: true })`).\n\n## 5.4.1\n\n"
16+
},
17+
{
18+
"name": "@callstack/repack-plugin-reanimated",
19+
"version": "5.4.2",
20+
"changelog": "# @callstack/repack-plugin-reanimated\n\n## 5.4.2\n\n## 5.4.1\n\n### Patch Changes\n\n- [#1476](https://github.com/callstack/repack/pull/1476) [`5bb41f0`](https://github.com/callstack/repack/commit/5bb41f045f43d935fc79b153f889a1195a0f19ad) Thanks [@whydidoo](https://github.com/whydidoo)! - Support React Native 0.88's Flow parser in Babel loaders, native component codegen, and Reanimated transforms while retaining Hermes parser compatibility with older React Native presets.\n\n"
21+
},
22+
{
23+
"name": "@callstack/repack-plugin-nativewind",
24+
"version": "5.4.2",
25+
"changelog": "# @callstack/repack-plugin-nativewind\n\n## 5.4.2\n\n## 5.4.1\n\n"
26+
},
27+
{
28+
"name": "@callstack/repack-plugin-expo-modules",
29+
"version": "5.4.2",
30+
"changelog": "# @callstack/repack-plugin-expo-modules\n\n## 5.4.2\n\n## 5.4.1\n\n"
31+
}
32+
]

‎.github/scripts/release-notes.mjs‎

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import { readdir, readFile } from 'node:fs/promises';
2+
import path from 'node:path';
3+
import { fileURLToPath, pathToFileURL } from 'node:url';
4+
5+
const mainPackage = '@callstack/repack';
6+
7+
function changelogEntry(changelog, version) {
8+
// Changesets writes version headings at column 0 and indents every
9+
// continuation line of a changeset by two spaces, so a column-0 `## ` can
10+
// only be a version heading, even inside fenced code or after a heading
11+
// written in a changeset.
12+
const content = [];
13+
let found = false;
14+
15+
for (const line of changelog.split(/\r?\n/)) {
16+
const heading = /^## (.+?)\s*$/.exec(line);
17+
if (heading) {
18+
if (found) break;
19+
found = heading[1] === version;
20+
} else if (found) {
21+
content.push(line);
22+
}
23+
}
24+
25+
if (!found) throw new Error(`Missing changelog entry for ${version}`);
26+
return content.join('\n').trim();
27+
}
28+
29+
export function generateReleaseNotes(packages) {
30+
const main = packages.find((pkg) => pkg.name === mainPackage);
31+
if (!main) throw new Error(`Missing ${mainPackage} in the release group`);
32+
33+
// A changeset can bump packages by different types, so list each note once
34+
// under the highest type it appears with.
35+
const types = ['Major', 'Minor', 'Patch'];
36+
const changes = new Map();
37+
for (const pkg of packages) {
38+
if (pkg.version !== main.version) {
39+
throw new Error(
40+
`Release group version mismatch: ${pkg.name}@${pkg.version}`
41+
);
42+
}
43+
let entry;
44+
try {
45+
entry = changelogEntry(pkg.changelog, pkg.version);
46+
} catch (error) {
47+
throw new Error(`${pkg.name}: ${error.message}`, { cause: error });
48+
}
49+
const sections = entry.split(/^### (Major|Minor|Patch) Changes\s*$/m);
50+
for (let index = 1; index < sections.length; index += 2) {
51+
for (const item of sections[index + 1].split(/(?=^- )/m)) {
52+
const note = item.trim();
53+
const type = sections[index];
54+
const current = changes.get(note);
55+
if (
56+
note &&
57+
!note.startsWith('- Updated dependencies') &&
58+
(!current || types.indexOf(type) < types.indexOf(current))
59+
) {
60+
changes.set(note, type);
61+
}
62+
}
63+
}
64+
}
65+
66+
return [
67+
'## Packages',
68+
packages.map((pkg) => `- \`${pkg.name}@${pkg.version}\``).join('\n'),
69+
...types
70+
.map((type) => [
71+
type,
72+
[...changes].filter(([, t]) => t === type).map(([note]) => note),
73+
])
74+
.filter(([, notes]) => notes.length)
75+
.map(([type, notes]) => `## ${type} Changes\n\n${notes.join('\n\n')}`),
76+
].join('\n\n');
77+
}
78+
79+
export async function readRelease(root) {
80+
const config = JSON.parse(
81+
await readFile(path.join(root, '.changeset/config.json'), 'utf8')
82+
);
83+
const group = config.fixed.find((names) => names.includes(mainPackage));
84+
if (!group) throw new Error(`Missing fixed release group for ${mainPackage}`);
85+
86+
const manifests = await Promise.all(
87+
(await readdir(path.join(root, 'packages'))).map(async (directory) => {
88+
const dir = path.join(root, 'packages', directory);
89+
const manifest = JSON.parse(
90+
await readFile(path.join(dir, 'package.json'), 'utf8')
91+
);
92+
return { dir, ...manifest };
93+
})
94+
);
95+
const packages = await Promise.all(
96+
group.map(async (name) => {
97+
const pkg = manifests.find((manifest) => manifest.name === name);
98+
if (!pkg || pkg.private || config.ignore.includes(name)) {
99+
throw new Error(
100+
`Release group package is missing or excluded: ${name}`
101+
);
102+
}
103+
return {
104+
name,
105+
version: pkg.version,
106+
changelog: await readFile(path.join(pkg.dir, 'CHANGELOG.md'), 'utf8'),
107+
};
108+
})
109+
);
110+
return generateReleaseNotes(packages);
111+
}
112+
113+
if (
114+
process.argv[1] &&
115+
import.meta.url === pathToFileURL(process.argv[1]).href
116+
) {
117+
try {
118+
console.log(
119+
await readRelease(fileURLToPath(new URL('../../', import.meta.url)))
120+
);
121+
} catch (error) {
122+
console.error(error.message);
123+
process.exitCode = 1;
124+
}
125+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import assert from 'node:assert/strict';
2+
import { readFile } from 'node:fs/promises';
3+
import test from 'node:test';
4+
5+
import { generateReleaseNotes } from './release-notes.mjs';
6+
7+
const fixture = JSON.parse(
8+
await readFile(
9+
new URL('./fixtures/release-5.4.2.json', import.meta.url),
10+
'utf8'
11+
)
12+
);
13+
14+
test('merges the actual 5.4.2 notes without dependency updates or empty sections', () => {
15+
const notes = generateReleaseNotes(fixture);
16+
assert.match(notes, /Fix `\.jpeg` images/);
17+
assert.match(notes, /Bootstrap new projects with React Native 0\.87\.1/);
18+
assert.match(notes, /\n\n {2}If you have a `\.jpeg`/);
19+
assert.equal((notes.match(/^## Patch Changes$/gm) ?? []).length, 1);
20+
for (const pkg of fixture) {
21+
assert.ok(notes.includes(`- \`${pkg.name}@${pkg.version}\``));
22+
}
23+
assert.doesNotMatch(
24+
notes,
25+
/Updated dependencies|^## @callstack\/|5\.4\.1|#1479|#1476|consumer ProGuard/m
26+
);
27+
});
28+
29+
test('includes the shared 5.4.1 changeset only once across packages', () => {
30+
const notes = generateReleaseNotes(
31+
fixture.map((pkg) => ({ ...pkg, version: '5.4.1' }))
32+
);
33+
assert.equal((notes.match(/\[#1476\]/g) ?? []).length, 1);
34+
assert.equal((notes.match(/^## Patch Changes$/gm) ?? []).length, 1);
35+
assert.match(notes, /consumer ProGuard/);
36+
assert.match(notes, /XML font-family resources continue to use `res\/font`/);
37+
assert.doesNotMatch(notes, /Updated dependencies|#1480|#1482|5\.4\.2/);
38+
});
39+
40+
test('groups changes by type and preserves multiline notes including fenced headings', () => {
41+
const example =
42+
'- Example\n\n ```md\n ## 0.1.0\n ### Patch Changes\n - Nested item\n ```';
43+
const notes = generateReleaseNotes([
44+
{
45+
name: '@callstack/repack',
46+
version: '6.0.0',
47+
changelog: `## 6.0.0\n\n### Patch Changes\n\n${example}\n\n### Major Changes\n\n- Breaking change\n\n## 5.4.2\n\nOld notes`,
48+
},
49+
{
50+
name: '@callstack/repack-init',
51+
version: '6.0.0',
52+
changelog:
53+
'## 6.0.0\n\n### Minor Changes\n\n- New option\n\n### Patch Changes\n\n- Another fix',
54+
},
55+
]);
56+
assert.ok(notes.includes(example));
57+
assert.ok(
58+
notes.indexOf('## Major Changes') < notes.indexOf('## Minor Changes')
59+
);
60+
assert.ok(
61+
notes.indexOf('## Minor Changes') < notes.indexOf('## Patch Changes')
62+
);
63+
assert.match(notes, /- Another fix/);
64+
assert.doesNotMatch(notes, /Old notes/);
65+
});
66+
67+
test('fails instead of including another version when the requested entry is missing', () => {
68+
const packages = structuredClone(fixture);
69+
packages[0].changelog = '# Package\n\n## 5.4.20\n\nWrong release';
70+
assert.throws(
71+
() => generateReleaseNotes(packages),
72+
/repack: Missing changelog entry for 5\.4\.2/
73+
);
74+
});
75+
76+
test('keeps headings and unclosed fences written inside a changeset', () => {
77+
const notes = generateReleaseNotes([
78+
{
79+
name: '@callstack/repack',
80+
version: '6.0.0',
81+
changelog: [
82+
'## 6.0.0',
83+
'',
84+
'### Major Changes',
85+
'',
86+
'- Breaking change',
87+
'',
88+
' # Overview',
89+
'',
90+
' ## Migration',
91+
'',
92+
' Update your config',
93+
'',
94+
'- Unclosed example',
95+
'',
96+
' ```js',
97+
' const a = 1;',
98+
'',
99+
'- Last change',
100+
'',
101+
'## 5.4.2',
102+
'',
103+
'### Patch Changes',
104+
'',
105+
'- Old notes',
106+
].join('\n'),
107+
},
108+
]);
109+
assert.match(notes, /## Migration\n\n {2}Update your config/);
110+
assert.match(notes, /- Last change/);
111+
assert.doesNotMatch(notes, /5\.4\.2|Old notes/);
112+
});
113+
114+
test('lists a changeset once under its highest change type', () => {
115+
const notes = generateReleaseNotes([
116+
{
117+
name: '@callstack/repack',
118+
version: '6.0.0',
119+
changelog: '## 6.0.0\n\n### Patch Changes\n\n- Shared change',
120+
},
121+
{
122+
name: '@callstack/repack-init',
123+
version: '6.0.0',
124+
changelog: '## 6.0.0\n\n### Minor Changes\n\n- Shared change',
125+
},
126+
]);
127+
assert.equal((notes.match(/- Shared change/g) ?? []).length, 1);
128+
assert.match(notes, /## Minor Changes\n\n- Shared change/);
129+
assert.doesNotMatch(notes, /## Patch Changes/);
130+
});

‎.github/workflows/release.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,31 @@ jobs:
5252
publish-script: pnpm release
5353
commit-message: 'chore: changeset version'
5454
pr-title: 'chore: changeset version'
55-
create-github-releases: true
55+
create-github-releases: false
56+
push-git-tags: true
5657
github-token: ${{ secrets.GITHUB_TOKEN }}
5758
env:
5859
# @changesets/changelog-github reads the token from the environment.
5960
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6061

62+
- name: Create combined GitHub release
63+
if: steps.changesets.outputs.published == 'true'
64+
run: |
65+
version=$(node -p "require('./packages/repack/package.json').version")
66+
tag="@callstack/repack@${version}"
67+
if gh release view "$tag" >/dev/null 2>&1; then
68+
exit 0
69+
fi
70+
node .github/scripts/release-notes.mjs > "$RUNNER_TEMP/release-notes.md"
71+
args=()
72+
if [[ "$version" == *-* ]]; then
73+
args+=(--prerelease)
74+
fi
75+
gh release create "$tag" --verify-tag --title "$version" \
76+
--notes-file "$RUNNER_TEMP/release-notes.md" "${args[@]}"
77+
env:
78+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
6180
canary-release:
6281
name: Canary Release
6382
runs-on: ubuntu-latest

‎.github/workflows/test.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ jobs:
5656

5757
- name: Run tests
5858
run: pnpm test
59+
60+
- name: Test release notes
61+
run: pnpm test:release

‎CONTRIBUTING.md‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,39 @@ package version changes and generated changelog entries for the next release.
9191

9292
Review the version numbers and changelog entries in that PR before merging it.
9393
When the version PR is merged to `main`, the same workflow runs `pnpm release`,
94-
publishes the packages to npm, pushes the release tags, and creates GitHub
95-
releases from the generated changelog entries.
94+
publishes the packages to npm and pushes all package release tags. A separate
95+
step creates one GitHub release on the main package's tag (for example,
96+
`@callstack/repack@5.4.2`), named after the shared version. Its notes list all
97+
packages in the fixed release group and merge their changelog entries by change
98+
type, without duplicate entries or dependency update bullets. Package changelogs
99+
and npm publishing are still managed by Changesets. Existing GitHub releases
100+
are left untouched.
101+
102+
Preview the combined notes without network access or credentials:
103+
104+
```sh
105+
node .github/scripts/release-notes.mjs
106+
pnpm test:release
107+
```
108+
109+
The GitHub release step runs only when Changesets publishes packages. If it
110+
fails after npm publication, rerunning the workflow may not retry that step,
111+
because there are no new packages to publish. To create the missing GitHub
112+
release manually, check out the original release commit, confirm the packages
113+
are published and their release tags exist, then run:
114+
115+
```sh
116+
version=$(node -p "require('./packages/repack/package.json').version")
117+
tag="@callstack/repack@${version}"
118+
node .github/scripts/release-notes.mjs > /tmp/repack-release-notes.md
119+
gh release create "$tag" --verify-tag --title "$version" \
120+
--notes-file /tmp/repack-release-notes.md
121+
```
122+
123+
For a prerelease version, add `--prerelease` to the `gh release create` command.
124+
This requires an authenticated GitHub CLI with permission to create releases.
125+
It does not recover npm publications or recreate package tags. The combined
126+
release covers the fixed group containing `@callstack/repack`.
96127

97128
#### Canary releases
98129

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"lint:ci": "biome check",
1414
"typecheck": "turbo run typecheck",
1515
"test": "turbo run test",
16+
"test:release": "node --test .github/scripts/*.test.mjs",
1617
"version-packages": "pnpm changeset version && pnpm lint",
1718
"version-packages:canary": "pnpm changeset version --snapshot canary && pnpm lint",
1819
"release": "pnpm changeset publish",

0 commit comments

Comments
 (0)