Skip to content

Commit 59df649

Browse files
authored
Update manual release documentation (#9142)
1 parent 93e022c commit 59df649

1 file changed

Lines changed: 46 additions & 99 deletions

File tree

docs/releases.md

Lines changed: 46 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ For situations requiring a release outside of the regular nightly and weekly pro
7070
4. Fill in the required inputs:
7171
- **Version**: The exact version to release (e.g., `v0.6.1`). This must be a valid semantic version with a `v` prefix.
7272
- **Ref**: The branch, tag, or full commit SHA to release from.
73-
- **NPM Channel**: The npm tag to publish with. Select `stable` for a general release, `preview` for a pre-release, or `none` to skip publishing to npm entirely.
73+
- **NPM Channel**: The npm channel to publish to. The options are `preview`, `nightly`, `latest` (for stable releases), and `dev`. The default is `dev`.
7474
- **Dry Run**: Leave as `true` to run all steps without publishing, or set to `false` to perform a live release.
7575
- **Force Skip Tests**: Set to `true` to skip the test suite. This is not recommended for production releases.
76+
- **Skip GitHub Release**: Set to `true` to skip creating a GitHub release and create an npm release only.
7677
5. Click **Run workflow**.
7778

7879
The workflow will then proceed to test (if not skipped), build, and publish the release. If the workflow fails during a non-dry run, it will automatically create a GitHub issue with the failure details.
@@ -295,108 +296,54 @@ By performing a dry run, you can be confident that your changes to the packaging
295296

296297
## Release Deep Dive
297298

298-
The main goal of the release process is to take the source code from the packages/ directory, build it, and assemble a
299-
clean, self-contained package in a temporary `bundle` directory at the root of the project. This `bundle` directory is what
300-
actually gets published to NPM.
299+
The release process creates two distinct types of artifacts for different distribution channels: standard packages for the NPM registry and a single, self-contained executable for GitHub Releases.
301300

302301
Here are the key stages:
303302

304-
Stage 1: Pre-Release Sanity Checks and Versioning
305-
306-
- What happens: Before any files are moved, the process ensures the project is in a good state. This involves running tests,
307-
linting, and type-checking (npm run preflight). The version number in the root package.json and packages/cli/package.json
308-
is updated to the new release version.
309-
- Why: This guarantees that only high-quality, working code is released. Versioning is the first step to signify a new
310-
release.
311-
312-
Stage 2: Building the Source Code
313-
314-
- What happens: The TypeScript source code in packages/core/src and packages/cli/src is compiled into JavaScript.
315-
- File movement:
316-
- packages/core/src/\*_/_.ts -> compiled to -> packages/core/dist/
317-
- packages/cli/src/\*_/_.ts -> compiled to -> packages/cli/dist/
318-
- Why: The TypeScript code written during development needs to be converted into plain JavaScript that can be run by
319-
Node.js. The core package is built first as the cli package depends on it.
320-
321-
Stage 3: Assembling the Final Publishable Package
322-
323-
This is the most critical stage where files are moved and transformed into their final state for publishing. A temporary
324-
`bundle` folder is created at the project root to house the final package contents.
325-
326-
1. The `package.json` is Transformed:
327-
- What happens: The package.json from packages/cli/ is read, modified, and written into the root `bundle`/ directory.
328-
- File movement: packages/cli/package.json -> (in-memory transformation) -> `bundle`/package.json
329-
- Why: The final package.json must be different from the one used in development. Key changes include:
330-
- Removing devDependencies.
331-
- Removing workspace-specific "dependencies": { "@gemini-cli/core": "workspace:\*" } and ensuring the core code is
332-
bundled directly into the final JavaScript file.
333-
- Ensuring the bin, main, and files fields point to the correct locations within the final package structure.
334-
335-
2. The JavaScript Bundle is Created:
336-
- What happens: The built JavaScript from both packages/core/dist and packages/cli/dist are bundled into a single,
337-
executable JavaScript file.
338-
- File movement: packages/cli/dist/index.js + packages/core/dist/index.js -> (bundled by esbuild) -> `bundle`/gemini.js (or a
339-
similar name).
340-
- Why: This creates a single, optimized file that contains all the necessary application code. It simplifies the package
341-
by removing the need for the core package to be a separate dependency on NPM, as its code is now included directly.
342-
343-
3. Static and Supporting Files are Copied:
344-
- What happens: Essential files that are not part of the source code but are required for the package to work correctly
345-
or be well-described are copied into the `bundle` directory.
346-
- File movement:
347-
- README.md -> `bundle`/README.md
348-
- LICENSE -> `bundle`/LICENSE
349-
- packages/cli/src/utils/\*.sb (sandbox profiles) -> `bundle`/
350-
- Why:
351-
- The README.md and LICENSE are standard files that should be included in any NPM package.
352-
- The sandbox profiles (.sb files) are critical runtime assets required for the CLI's sandboxing feature to
353-
function. They must be located next to the final executable.
354-
355-
Stage 4: Publishing to NPM
356-
357-
- What happens: The npm publish command is run from inside the root `bundle` directory.
358-
- Why: By running npm publish from within the `bundle` directory, only the files we carefully assembled in Stage 3 are uploaded
359-
to the NPM registry. This prevents any source code, test files, or development configurations from being accidentally
360-
published, resulting in a clean and minimal package for users.
361-
362-
Summary of File Flow
363-
364-
```mermaid
365-
graph TD
366-
subgraph "Source Files"
367-
A["packages/core/src/*.ts<br/>packages/cli/src/*.ts"]
368-
B["packages/cli/package.json"]
369-
C["README.md<br/>LICENSE<br/>packages/cli/src/utils/*.sb"]
370-
end
371-
372-
subgraph "Process"
373-
D(Build)
374-
E(Transform)
375-
F(Assemble)
376-
G(Publish)
377-
end
378-
379-
subgraph "Artifacts"
380-
H["Bundled JS"]
381-
I["Final package.json"]
382-
J["bundle/"]
383-
end
384-
385-
subgraph "Destination"
386-
K["NPM Registry"]
387-
end
388-
389-
A --> D --> H
390-
B --> E --> I
391-
C --> F
392-
H --> F
393-
I --> F
394-
F --> J
395-
J --> G --> K
396-
```
303+
**Stage 1: Pre-Release Sanity Checks and Versioning**
304+
305+
- **What happens:** Before any files are moved, the process ensures the project is in a good state. This involves running tests, linting, and type-checking (`npm run preflight`). The version number in the root `package.json` and `packages/cli/package.json` is updated to the new release version.
306+
307+
**Stage 2: Building the Source Code for NPM**
308+
309+
- **What happens:** The TypeScript source code in `packages/core/src` and `packages/cli/src` is compiled into standard JavaScript.
310+
- **File movement:**
311+
- `packages/core/src/**/*.ts` -> compiled to -> `packages/core/dist/`
312+
- `packages/cli/src/**/*.ts` -> compiled to -> `packages/cli/dist/`
313+
- **Why:** The TypeScript code written during development needs to be converted into plain JavaScript that can be run by Node.js. The `core` package is built first as the `cli` package depends on it.
314+
315+
**Stage 3: Publishing Standard Packages to NPM**
316+
317+
- **What happens:** The `npm publish` command is run for the `@google/gemini-cli-core` and `@google/gemini-cli` packages.
318+
- **Why:** This publishes them as standard Node.js packages. Users installing via `npm install -g @google/gemini-cli` will download these packages, and `npm` will handle installing the `@google/gemini-cli-core` dependency automatically. The code in these packages is not bundled into a single file.
319+
320+
**Stage 4: Assembling and Creating the GitHub Release Asset**
321+
322+
This stage happens _after_ the NPM publish and creates the single-file executable that enables `npx` usage directly from the GitHub repository.
323+
324+
1. **The JavaScript Bundle is Created:**
325+
- **What happens:** The built JavaScript from both `packages/core/dist` and `packages/cli/dist`, along with all third-party JavaScript dependencies, are bundled by `esbuild` into a single, executable JavaScript file (e.g., `gemini.js`). The `node-pty` library is excluded from this bundle as it contains native binaries.
326+
- **Why:** This creates a single, optimized file that contains all the necessary application code. It simplifies execution for users who want to run the CLI without a full `npm install`, as all dependencies (including the `core` package) are included directly.
327+
328+
2. **The `bundle` Directory is Assembled:**
329+
- **What happens:** A temporary `bundle` folder is created at the project root. The single `gemini.js` executable is placed inside it, along with other essential files.
330+
- **File movement:**
331+
- `gemini.js` (from esbuild) -> `bundle/gemini.js`
332+
- `README.md` -> `bundle/README.md`
333+
- `LICENSE` -> `bundle/LICENSE`
334+
- `packages/cli/src/utils/*.sb` (sandbox profiles) -> `bundle/`
335+
- **Why:** This creates a clean, self-contained directory with everything needed to run the CLI and understand its license and usage.
336+
337+
3. **The GitHub Release is Created:**
338+
- **What happens:** The contents of the `bundle` directory, including the `gemini.js` executable, are attached as assets to a new GitHub Release.
339+
- **Why:** This makes the single-file version of the CLI available for direct download and enables the `npx https://github.com/google-gemini/gemini-cli` command, which downloads and runs this specific bundled asset.
340+
341+
**Summary of Artifacts**
342+
343+
- **NPM:** Publishes standard, un-bundled Node.js packages. The primary artifact is the code in `packages/cli/dist`, which depends on `@google/gemini-cli-core`.
344+
- **GitHub Release:** Publishes a single, bundled `gemini.js` file that contains all dependencies, for easy execution via `npx`.
397345

398-
This process ensures that the final published artifact is a purpose-built, clean, and efficient representation of the
399-
project, rather than a direct copy of the development workspace.
346+
This dual-artifact process ensures that both traditional `npm` users and those who prefer the convenience of `npx` have an optimized experience.
400347

401348
## Notifications
402349

0 commit comments

Comments
 (0)