-
Notifications
You must be signed in to change notification settings - Fork 0
feat(upgrade): composite upgrade action with CLI-driven JSON output #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lifanzou
wants to merge
17
commits into
main
Choose a base branch
from
lifanzou/fern-upgrade-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
eba22be
feat(upgrade): implement fern-upgrade GitHub Action
28deede
refactor(upgrade): rewrite as composite action
ae986f8
fix(upgrade): fix repo URLs, make upgrade failures fatal, scope git a…
devin-ai-integration[bot] 24e1d68
fix(upgrade): correct resolve-cli action path (actions/resolve-cli)
devin-ai-integration[bot] 0faf397
fix(upgrade): save/restore fern config across branch switch to handle…
devin-ai-integration[bot] aad77a8
feat(upgrade): add include-major flag (default true), link changelogs…
devin-ai-integration[bot] 4c3800f
refactor(upgrade): simplify PR title, keep version details in body
devin-ai-integration[bot] d4319c9
fix(upgrade): remove broken version-specific changelog anchors
devin-ai-integration[bot] 42f2a95
test(upgrade): add unit tests for diff.js helpers (node:test, zero deps)
devin-ai-integration[bot] 56224d0
style(upgrade): fix biome formatting in diff.test.js
devin-ai-integration[bot] 603c771
security(upgrade): mask fern-token and github-token before CLI runs
devin-ai-integration[bot] 07d9871
fix(upgrade): address Devin Review findings
devin-ai-integration[bot] cd4cb90
style(upgrade): fix biome formatting in snapshot.js
devin-ai-integration[bot] 253cc18
security(upgrade): fix script injection — pass include-major via env var
devin-ai-integration[bot] 843e540
refactor(upgrade): derive changelog URLs from generator name
devin-ai-integration[bot] ab343e8
refactor: consume fern automations upgrade CLI JSON output
devin-ai-integration[bot] 89ff193
fix(upgrade): add CLI version check, graceful error handling, update …
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # upgrade | ||
|
|
||
| **[ALPHA]** Automatically upgrades Fern CLI and generator versions and opens or updates a pull request with the changes. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - **Fern CLI version**: This action requires a CLI version that includes the `fern automations upgrade` command. Use `version: 'latest'` (the default) to ensure compatibility, or pin to a version that includes this command. | ||
|
|
||
| ## How it works | ||
|
|
||
| 1. Resolves and installs the Fern CLI based on the `version` input | ||
| 2. Verifies the CLI supports `fern automations upgrade` | ||
| 3. Runs `fern automations upgrade --json [--include-major]` — a single CLI call that: | ||
| - Upgrades the CLI version in `fern.config.json` | ||
| - Upgrades generator versions in `generators.yml` | ||
| - Returns structured JSON with all version changes | ||
| 4. Formats a PR title, body, and commit message from the CLI JSON output | ||
| 5. If changes were detected, pushes to the `fern/upgrade` branch and creates or updates a PR | ||
|
|
||
| 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). | ||
|
|
||
| ## Usage | ||
|
|
||
| ```yaml | ||
| name: Fern Upgrade | ||
| on: | ||
| schedule: | ||
| - cron: '0 6 * * *' # Daily at 6am UTC | ||
| workflow_dispatch: {} # Manual trigger + registry webhook support | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: fern-upgrade | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| upgrade: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: fern-api/actions/upgrade@v1 | ||
| with: | ||
| fern-token: ${{ secrets.FERN_TOKEN }} | ||
| ``` | ||
|
|
||
| > **Important:** The `concurrency` block is strongly recommended to prevent race conditions if multiple upgrade runs are triggered simultaneously. | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Input | Required | Default | Description | | ||
| |-------|----------|---------|-------------| | ||
| | `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. | | ||
| | `fern-token` | **Yes** | — | Fern authentication token | | ||
| | `include-major` | No | `true` | Whether to include major version upgrades for generators. Set to `false` for minor/patch only. **Note:** This defaults to `true` (unlike the CLI default of `false`) because the upgrade action is designed to aggressively upgrade, letting the preview action validate breaking changes. | | ||
| | `github-token` | No | `${{ github.token }}` | GitHub token for PR creation and push access | | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Output | Description | | ||
| |--------|-------------| | ||
| | `run-id` | UUIDv4 for this upgrade run | | ||
| | `pr-url` | URL of the created or updated PR (empty if no changes) | | ||
| | `cli-upgraded` | `true` or `false` — whether the CLI version was bumped | | ||
| | `generators-upgraded` | JSON array of `{generator, from, to}` for each upgraded generator | | ||
|
|
||
| ## PR format | ||
|
|
||
| **Title:** `chore(fern): upgrade CLI 0.25.0 → 0.30.0 and 3 generators` | ||
|
|
||
| **Body** includes: | ||
| - CLI version change | ||
| - Generator version table with changelog links | ||
| - Links to generator changelogs on [buildwithfern.com](https://buildwithfern.com) | ||
|
|
||
| ## Permissions | ||
|
|
||
| The workflow requires: | ||
| - `contents: write` — to push the `fern/upgrade` branch | ||
| - `pull-requests: write` — to create and update PRs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.