Skip to content

Commit 9bd70c9

Browse files
committed
Update docs
1 parent ff18f23 commit 9bd70c9

6 files changed

Lines changed: 197 additions & 180 deletions

File tree

README.md

Lines changed: 2 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,3 @@
1-
# [beachball](https://microsoft.github.io/beachball/)
1+
# [beachball](https://microsoft.github.io/beachball/) monorepo
22

3-
the sunniest version bumping tool
4-
5-
## Prerequisites
6-
7-
A git repo with a remote
8-
9-
## Usage
10-
11-
```
12-
beachball [command] [options]
13-
```
14-
15-
## Commands
16-
17-
### [change](https://microsoft.github.io/beachball/cli/change.html) (default)
18-
19-
a tool to help create change files in the change/ folder
20-
21-
### [check](https://microsoft.github.io/beachball/cli/check.html)
22-
23-
checks whether a change file is needed for this branch
24-
25-
### [bump](https://microsoft.github.io/beachball/cli/bump.html)
26-
27-
bumps versions as well as generating changelogs
28-
29-
### [publish](https://microsoft.github.io/beachball/cli/publish.html)
30-
31-
bumps, publishes to npm registry, and pushes changelogs back into the target branch
32-
33-
### [sync](https://microsoft.github.io/beachball/cli/sync.html)
34-
35-
synchronizes published versions of packages from a registry, makes local package.json changes to match what is published
36-
37-
### [config](https://microsoft.github.io/beachball/cli/config.html)
38-
39-
inspect the effective beachball configuration for the repo or a specific package
40-
41-
## Options
42-
43-
Some of the most common options are summarized below. **For all options, see the pages for [CLI options](https://microsoft.github.io/beachball/cli/options.html) and [config file options](https://microsoft.github.io/beachball/overview/configuration.html).**
44-
45-
### `--config`, `-c`
46-
47-
Explicit configuration file to use instead of the configuration automatically detected by cosmicconfig.
48-
49-
### `--registry`, `-r` (config: `registry`)
50-
51-
registry, defaults to https://registry.npmjs.org
52-
53-
### `--tag`, `-t` (config: `tag`)
54-
55-
- for the `publish` command: dist-tag for npm publishes
56-
- for the `sync` command: will use specified tag to set the version
57-
58-
### `--branch`, `-b` (config: `branch`)
59-
60-
target branch from remote (default: as configured in `git config init.defaultBranch`)
61-
62-
### `--message`, `-m`
63-
64-
- for the `publish` command: message for the checkin (default: "applying package updates")
65-
- for the `change` command: change file comment for all changed packages
66-
67-
### `--type`
68-
69-
for the `change` command: [change type](https://microsoft.github.io/beachball/concepts/change-types.html) for all changed packages
70-
71-
### `--package`
72-
73-
for the `change` command: specific package(s) to create a change file for
74-
75-
### `--no-push` (config: `push`)
76-
77-
skip pushing changes back to git remote origin
78-
79-
### `--no-publish` (config: `publish`)
80-
81-
skip publishing to the npm registry
82-
83-
### `--help`, `-?`, `-h`
84-
85-
show help message
86-
87-
### `--yes`, `-y`
88-
89-
skips the prompts for publish
90-
91-
## Examples
92-
93-
```sh
94-
# check for change files
95-
beachball check
96-
97-
# interactively create change files
98-
beachball change
99-
100-
# non-interactively create change files
101-
beachball change --type patch --message "awesome changes"
102-
103-
# publish changes
104-
beachball publish -r http://localhost:4873 -t beta
105-
```
106-
107-
## Notes
108-
109-
### Overriding concurrency
110-
111-
In large monorepos, the process of fetching versions for sync or before publishing can be time-consuming due to the high number of packages. To optimize performance, you can override the concurrency for fetching from the registry by setting `options.npmReadConcurrency` (default: 5). You can also increase concurrency for hook calls and publish operations via `options.concurrency` (default: 1; respects topological order).
112-
113-
### API surface
114-
115-
Beachball **does not** have a public API beyond the provided [options](https://microsoft.github.io/beachball/overview/configuration.html). Usage of private APIs is not supported and may break at any time.
116-
117-
If you need to customize something beyond what's currently supported in the options, please open a feature request or talk with the maintainers.
118-
119-
### AI integration
120-
121-
Normally, Beachball uses an interactive CLI prompt for generating change files. Since this doesn't work for AI agents, we provide a **change file skill** that guides AI agents through creating properly formatted change files. See the [AI integration](https://microsoft.github.io/beachball/concepts/ai-integration) docs for setup instructions.
3+
the sunniest version bumping tool - see [`packages/beachball`](./packages/beachball) for details

beachball.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @ts-check
22
/** @type {Partial<import('./packages/beachball/src/types/BeachballOptions').RepoOptions>}*/
33
const config = {
4+
access: 'public',
45
branch: 'main',
56
commit: false,
67
disallowedChangeTypes: ['major'],

docs/cli/publish.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ Publishing automates all the bumping and synchronizing of package versions in th
1212

1313
[General options](./options) also apply for this command.
1414

15-
| Option | Alias | Default | Description |
16-
| ----------------------------- | ----- | ------------------------------ | -------------------------------------------------------------------------------- |
17-
| `--auth-type` | `-a` | `'authtoken'` | npm auth type: `'authtoken'` or `'password'` |
18-
| `--git-tags`, `--no-git-tags` | | `true` (`--git-tags`) | whether to create git tags for published package versions |
19-
| `--keep-change-files` | | | don't delete the change files from disk after bumping |
20-
| `--message` | `-m` | `'applying package updates'` | custom commit message |
21-
| `--prerelease-prefix` | | | prerelease prefix (e.g. `beta`) for packages that will receive a prerelease bump |
22-
| `--publish`, `--no-publish` | | `true` (`--publish`) | whether to publish to the npm registry |
23-
| `--push`, `--no-push` | | `true` (`--push`) | whether to commit changes and push them back to the git remote |
24-
| `--registry` | `-r` | `'https://registry.npmjs.org'` | npm registry for publishing |
25-
| `--retries` | | `3` | number of retries for a package publish before failing |
26-
| `--tag` | `-t` | `'latest'` | dist-tag for npm publishes |
27-
| `--token` | `-n` | | credential to use with npm commands (type specified by `--auth-type`) |
28-
| `--verbose` | | `false` | prints additional information to the console |
29-
| `--yes` | `-y` | if CI detected, `true` | skips the prompts for publish |
15+
<!-- prettier-ignore -->
16+
| Option | Alias | Default | Description |
17+
| ------ | ----- | ------- | ----------- |
18+
| `--auth-type` | `-a` | `'authtoken'` | npm auth type: `'authtoken'` or `'password'` |
19+
| `--git-tags`, `--no-git-tags` | | `true` (`--git-tags`) | whether to create git tags for published package versions |
20+
| `--keep-change-files` | | | don't delete the change files from disk after bumping |
21+
| `--message` | `-m` | `'applying package updates'` | custom commit message |
22+
| `--prerelease-prefix` | | | prerelease prefix (e.g. `beta`) for packages that will receive a prerelease bump |
23+
| `--publish`, `--no-publish` | | `true` (`--publish`) | whether to publish to the npm registry |
24+
| `--push`, `--no-push` | | `true` (`--push`) | whether to commit changes and push them back to the git remote |
25+
| `--registry` | `-r` | `'https://registry.npmjs.org'` | npm registry for publishing |
26+
| `--retries` | | `3` | number of retries for a package publish before failing |
27+
| `--tag` | `-t` | `'latest'` | dist-tag for npm publishes |
28+
| `--token` | `-n` | | credential to use with npm commands (type is specified by `--auth-type`) - locally, use `npm login` instead, or see [alternatives for CI](../concepts/ci-integration) |
29+
| `--verbose` | | `false` | prints additional information to the console |
30+
| `--yes` | `-y` | if CI detected, `true` | skips the prompts for publish |
3031

3132
### Algorithm
3233

docs/concepts/ci-integration.md

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@ To automate the bumping of package versions based on change files, you'll need t
1515

1616
## Authentication
1717

18-
Automated publishing from a GitHub repo to the public npm registry (`registry.npmjs.org`) typically uses personal access tokens for authentication. These tokens are stored as secrets in your CI system. You should ensure that these secrets are only available to release builds.
18+
Automated publishing from a GitHub repo to the public npm registry (`registry.npmjs.org`) typically uses personal access tokens (and/or trusted publishing) for authentication. These tokens are stored as secrets in your CI system. You should ensure that these secrets are only available to release builds.
1919

2020
For Azure DevOps repos publishing to a private registry, there are other possible approaches (such as using a service account with credentials stored in a key vault) which are not currently covered by these docs.
2121

2222
### Generating tokens
2323

2424
#### npm token
2525

26-
If publishing to the public npm registry (`registry.npmjs.org`), [create a granular access token](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-granular-access-tokens-on-the-website) with write access to **only** the relevant package(s) and/or scope(s). Classic automation tokens are not recommended due to their overly broad permissions.
26+
If publishing to the public npm registry (`registry.npmjs.org`) from a platform that supports [trusted publishing](https://docs.npmjs.com/trusted-publishers), such as GitHub Actions, you should use trusted publishing instead of a token.
2727

28-
#### GitHub token
28+
Azure DevOps unfortunately doesn't support trusted publishing, so there it's still necessary to [create a granular access token](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-granular-access-tokens-on-the-website) with write access to **only** the relevant package(s) and/or scope(s).
2929

30-
Since a repo's `main`/`master` branch should be protected, this creates some difficulties for pushing changes back during automated publishing.
30+
#### GitHub token
3131

32-
The main way to allow `beachball` to push back to a repo with branch protections is by using a [**fine-grained** personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) with write permissions for **only** the specific repo. (If the repo is in an org that doesn't allow persistent admin access, see [these instructions](https://github.com/microsoft/beachball/issues/1008).)
32+
Since a repo's `main`/`master` branch should be protected, this creates some difficulties for pushing changes back during automated publishing. There are a few options:
3333

34-
An alternative approach is creating a fine-grained PAT with a "machine user" account. Create a new account with an alternate email or [subaddress](https://en.wikipedia.org/wiki/Email_address#Subaddressing) (`+` address), give it contributor permissions to only this repo, and add it under "Restrict who can push to matching branches" in the branch protection rule.
34+
- Traditional approach: use a [**fine-grained** personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) (PAT) with write permissions for **only** the specific repo. (If the repo is in an org that doesn't allow persistent admin access, see [these instructions](https://github.com/microsoft/beachball/issues/1008).)
35+
- Variant: create a fine-grained PAT with a "machine user" account. Create a new account with an alternate email or [subaddress](https://en.wikipedia.org/wiki/Email_address#Subaddressing) (`+` address), give it contributor permissions to only this repo, and add it under "Restrict who can push to matching branches" in the branch protection rule.
36+
- Alternative if publishing via GitHub Actions: use [`actions/create-github-app-token`](https://github.com/actions/create-github-app-token) to generate short-lived tokens. For this purpose, an "app" is essentially just an identity with permissions; you don't need to define any logic or endpoints. Create a GitHub app, install it in your repo, give it permission to bypass policies, and pass its ID and key to the action.
3537

3638
(Note that the [built-in `GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication) won't work for publishing because that actor can't be given permission to bypass policies.)
3739

@@ -57,7 +59,7 @@ There are a couple of options here:
5759

5860
If you're passing any custom options besides the npm token to `beachball publish`, it's recommended to set them in either the `beachball` config (if they don't interfere with other commands), or a `package.json` script (if specific to `publish`).
5961

60-
For example, the following script could be used for publishing public scoped packages:
62+
For example, the following script could be used for publishing public scoped packages (`access` is also safe to set in the beachball config):
6163

6264
```json
6365
{
@@ -87,7 +89,7 @@ The exact publishing setup will vary depending on your CI setup, but the overall
8789
git config user.email "someone@example.com"
8890
```
8991
2. Set up git authentication. This could use tokens (covered below), SSH keys, or some other non-interactive method.
90-
3. Set up npm authentication. This could use tokens passed on the command line (covered below), tokens set in `.npmrc`, or some other method.
92+
3. Set up npm authentication. This could use [trusted publishing](https://docs.npmjs.com/trusted-publishers), tokens set in `.npmrc`, tokens passed on the command line (covered below), or some other method.
9193
4. Run `beachball publish`!
9294

9395
### GitHub repo + GitHub Actions
@@ -98,39 +100,35 @@ This sample assumes the following:
98100

99101
- An environment called `release` (set up [as described above](#storing-tokens)) with the following secrets:
100102
- `REPO_PAT`: A GitHub fine-grained personal access token with write access ([as described above](#github-token))
101-
- `NPM_TOKEN`: An npm token with write access to the package(s) and/or scope(s), such as a [fine-grained token for public npm](#npm-token)
103+
- [Trusted publishing](https://docs.npmjs.com/trusted-publishers) is enabled for the package(s), linked to this workflow, and given access to the `release` environment.
102104
- A repo root `package.json` script `release` which runs `beachball publish`
103-
- The build is running on a Linux/Mac agent. (This could be easily adapted to a Windows agent with different syntax in the commands.)
104105

105106
Note that in GitHub Actions, it's easiest to set up authentication if you set `persist-credentials: false` when checking out code.
106107

107108
```yml
108-
# Example trigger configurations (choose one or more, or another setup)
109-
# on:
110-
# # Release on push to main
111-
# push:
112-
# branches: [main]
113-
# # Release daily (see https://crontab-generator.org/ for help with schedules)
114-
# schedule:
115-
# - cron: '0 8 * * *'
116-
# # Release on manual trigger (can be used alone or with other options)
117-
# workflow_dispatch:
109+
# Add trigger configuration of your choice (this one is manual only)
110+
on:
111+
workflow_dispatch:
118112

119113
environment: release
120114

121115
# Variable syntax below assumes Linux/Mac but could be easily adapted to Windows
122116
runs-on: ubuntu-latest
123117

118+
permissions:
119+
# Required for trusted publishing
120+
id-token: write
121+
124122
steps:
125123
- name: Check out code
126-
uses: actions/checkout@v3
124+
uses: actions/checkout@v6
127125
with:
128126
# Prevent the action from storing credentials in a way that's hard to override
129127
persist-credentials: false
130128

131129
# ... Other steps to prepare for publishing (install, build, test, etc) ...
132130

133-
# Set the name, email, and URL with PAT
131+
# Set the name, email, and URL with PAT (use Windows variable syntax if needed)
134132
- name: Set git credentials
135133
run: |
136134
git config user.name "someone"
@@ -139,11 +137,9 @@ steps:
139137
env:
140138
REPO_PAT: ${{ secrets.REPO_PAT }}
141139

142-
# Pass the token on the command line for publishing
140+
# No token needed with trusted publishing
143141
- name: Publish
144-
run: npm run release -- --token "$NPM_TOKEN"
145-
env:
146-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
142+
run: npm run release
147143
```
148144
149145
### GitHub repo + Azure Pipelines
@@ -156,20 +152,15 @@ This sample assumes the following:
156152
- `REPO_PAT`: A GitHub fine-grained personal access token with write access ([as described above](#github-token))
157153
- `NPM_TOKEN`: An npm token with write access to the package(s) and/or scope(s), such as a [fine-grained token for public npm](#npm-token)
158154
- A repo root `package.json` script `release` which runs `beachball publish`
159-
- The build is running on a Linux/Mac agent. (This could be easily adapted to a Windows agent with different syntax in the commands.)
155+
- A `.npmrc` file with the following content (change the registry if needed):
156+
```txt
157+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
158+
```
160159

161160
```yml
162-
# Example trigger configurations (choose one or more, or another setup)
163-
#
164-
# # Release on push to main
165-
# trigger: [main]
166-
#
167-
# # Release on a schedule
168-
# # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?tabs=yaml&view=azure-devops#supported-cron-syntax
169-
# schedules:
170-
# - cron: '0 8 * * *'
171-
# branches:
172-
# include: [main]
161+
# Add trigger configuration of your choice (this one is manual only)
162+
pr: none
163+
trigger: none
173164
174165
# This group should only be accessible to the release pipeline
175166
variables:
@@ -182,16 +173,20 @@ pool:
182173
steps:
183174
# ... Other steps to set up repo and prepare for publishing (install, build, test, etc) ...
184175
185-
# Set the name, email, and URL with PAT
176+
# Set the name, email, and URL with PAT (use Windows variable syntax if needed)
186177
- script: |
187178
git config user.name "someone"
188179
git config user.email "someone@example.com"
189-
git remote set-url origin "https://$(REPO_PAT)@github.com/your-org/your-repo"
180+
git remote set-url origin "https://$REPO_PAT@github.com/your-org/your-repo"
190181
name: Set git credentials
182+
env:
183+
REPO_PAT: $(REPO_PAT)
191184
192-
# Pass the token on the command line for publishing
193-
- script: npm run release -- --token "$(NPM_TOKEN)"
185+
- script: npm run release
194186
name: Publish
187+
# This works because .npmrc references NPM_TOKEN
188+
env:
189+
NPM_TOKEN: $(NPM_TOKEN)
195190
```
196191

197192
### Azure Repos + Azure Pipelines

0 commit comments

Comments
 (0)