Skip to content

Commit 86bbed4

Browse files
Barryclaude
authored andcommitted
feat(upgrade): implement fern-upgrade GitHub Action
Implements end-to-end fern-upgrade action that automates Fern CLI and generator version upgrades. Runs `fern upgrade` and `fern generator upgrade`, detects changes by diffing config files before/after, and opens or updates a shared PR on the `fern/upgrade` branch. - Add version-diff module for parsing fern.config.json and generators.yml - Add PR management with clean-slate branch strategy (force push) - Add PR title/body generation with changelog links from FDR - Add github-token input with default GITHUB_TOKEN fallback - Add CLI version resolution (auto/latest/inherit/specific) - Stub telemetry (FER-9668) and automation config (FER-9669) as TODOs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f5696be commit 86bbed4

12 files changed

Lines changed: 9073 additions & 963 deletions

File tree

actions/upgrade/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# upgrade
2+
3+
**[ALPHA]** Automatically upgrades Fern CLI and generator versions and opens or updates a pull request with the changes.
4+
5+
## How it works
6+
7+
1. Resolves and runs the Fern CLI based on the `version` input
8+
2. Runs `fern upgrade --yes` to bump the CLI version in `fern.config.json`
9+
3. Runs `fern generator upgrade --yes` to bump generator versions in `generators.yml`
10+
4. Detects what changed by comparing config files before and after
11+
5. If changes were detected, pushes to the `fern/upgrade` branch and creates or updates a PR
12+
13+
The action uses a **single open PR model** — if a PR already exists on the `fern/upgrade` branch, it updates the PR title and body. Each run resets the branch to the latest default branch HEAD (clean slate).
14+
15+
## Usage
16+
17+
```yaml
18+
name: Fern Upgrade
19+
on:
20+
schedule:
21+
- cron: '0 6 * * *' # Daily at 6am UTC
22+
workflow_dispatch: {} # Manual trigger + registry webhook support
23+
24+
permissions:
25+
contents: write
26+
pull-requests: write
27+
28+
concurrency:
29+
group: fern-upgrade
30+
cancel-in-progress: false
31+
32+
jobs:
33+
upgrade:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: fern-api/fern-github-actions/actions/upgrade@v1
38+
with:
39+
fern-token: ${{ secrets.FERN_TOKEN }}
40+
```
41+
42+
> **Important:** The `concurrency` block is strongly recommended to prevent race conditions if multiple upgrade runs are triggered simultaneously.
43+
44+
## Inputs
45+
46+
| Input | Required | Default | Description |
47+
|-------|----------|---------|-------------|
48+
| `version` | No | `latest` | Fern CLI version to use. `auto` respects `fern.config.json`, `latest` always uses newest, `inherit` uses CLI from PATH, or pin a specific version. |
49+
| `fern-token` | **Yes** | — | Fern authentication token |
50+
| `github-token` | No | `${{ github.token }}` | GitHub token for PR creation and push access |
51+
52+
## Outputs
53+
54+
| Output | Description |
55+
|--------|-------------|
56+
| `run-id` | UUIDv4 for this upgrade run |
57+
| `pr-url` | URL of the created or updated PR (empty if no changes) |
58+
| `cli-upgraded` | `true` or `false` — whether the CLI version was bumped |
59+
| `generators-upgraded` | JSON array of `{generator, from, to}` for each upgraded generator |
60+
61+
## PR format
62+
63+
**Title:** `chore: upgrade fern (0.25.0 → 0.30.0) and generators`
64+
65+
**Body** includes:
66+
- CLI version change
67+
- Generator version table with changelog links
68+
- Links to generator changelogs on [buildwithfern.com](https://buildwithfern.com)
69+
70+
## Permissions
71+
72+
The workflow requires:
73+
- `contents: write` — to push the `fern/upgrade` branch
74+
- `pull-requests: write` — to create and update PRs

actions/upgrade/action.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,27 @@ inputs:
88
required: false
99
default: "latest"
1010
fern-token:
11-
description: "Fern token for API access and PR creation"
11+
description: "Fern token for API access and CLI authentication"
1212
required: true
13+
github-token:
14+
description: "GitHub token for PR creation and push access. Falls back to default GITHUB_TOKEN."
15+
required: false
16+
default: ${{ github.token }}
1317

1418
outputs:
1519
run-id:
1620
description: "UUIDv4 for this upgrade run"
1721
pr-url:
1822
description: "URL of the created or updated upgrade PR (empty if no changes)"
1923
cli-upgraded:
20-
description: "Whether the Fern CLI version was upgraded"
24+
description: "Whether the Fern CLI version was upgraded (true/false)"
2125
generators-upgraded:
2226
description: "JSON array of {generator, from, to} for each upgraded generator"
2327

2428
runs:
2529
using: "node20"
2630
main: "dist/index.js"
31+
32+
branding:
33+
icon: "refresh-cw"
34+
color: "green"

0 commit comments

Comments
 (0)