Skip to content

Commit e26b0e1

Browse files
alerizzoclaude
andcommitted
fix: address PR review feedback and update documentation
- Add test step to release.yml before publishing (Codacy + Copilot review) - Restore prepublishOnly as safety net for local publishes (Codacy + Copilot review) - Set NPM_CONFIG_PROVENANCE=true to preserve provenance signing (Copilot review) - Update README CI/CD section with new changesets workflow - Add versioning/changesets section to AGENTS.md with agent responsibilities - Add agent self-documentation guidelines to AGENTS.md - Update SPECS/deployment.md to reflect new release workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7535334 commit e26b0e1

5 files changed

Lines changed: 61 additions & 20 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
- name: Build
3636
run: npm run build
3737

38+
- name: Test
39+
run: npm test
40+
3841
- name: Create Release PR or Publish
3942
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1
4043
with:
@@ -44,3 +47,4 @@ jobs:
4447
env:
4548
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4649
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
NPM_CONFIG_PROVENANCE: true

AGENTS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This CLI wraps the [Codacy Cloud API v3](https://api.codacy.com/api/api-docs) us
2424

2525
```
2626
codacy-cloud-cli/
27+
├── .changeset/ # Changesets config and pending changeset files
2728
├── src/
2829
│ ├── index.ts # CLI entry point (Commander.js setup)
2930
│ ├── api/
@@ -173,6 +174,35 @@ The `SPECS/` folder at the project root is the single source of truth for specs
173174
4. Update `SPECS/README.md` (mark tasks done, add changelog entry) when completing work
174175
5. Add new tasks to `SPECS/README.md` pending table when discovered during work
175176

177+
## Versioning & Releasing
178+
179+
This project uses [changesets](https://github.com/changesets/changesets) for versioning and npm publishing.
180+
181+
### How it works
182+
183+
1. Every PR must include a changeset file (CI enforces this via the `changeset-check` job)
184+
2. Run `npx changeset` to create one — select the bump type (`patch`, `minor`, `major`) and describe the change
185+
3. For PRs that don't need a version bump (docs, CI, refactors), use `npx changeset --empty`
186+
4. On merge to `main`, the `release.yml` workflow creates a "chore: version packages" PR that bumps the version and updates `CHANGELOG.md`
187+
5. Merging that PR triggers the actual npm publish with provenance
188+
189+
### Agent responsibilities for changesets
190+
191+
When completing work that changes user-facing behavior or adds features, agents **must**:
192+
1. Run `npx changeset` and create an appropriate changeset file before committing
193+
2. Use `patch` for bug fixes, `minor` for new features or commands, `major` for breaking changes
194+
3. Write a clear, user-facing summary in the changeset (this becomes the CHANGELOG entry)
195+
196+
For internal-only changes (refactors, docs, CI, test-only changes), use `npx changeset --empty`.
197+
198+
### Agent responsibilities for self-documenting changes
199+
200+
When completing work, agents **must** update relevant documentation:
201+
1. **`SPECS/README.md`** — mark tasks as done in the pending table, add a changelog entry
202+
2. **`README.md`** — if a new command was added or renamed, update the commands summary table (one row per command, no detailed args/options)
203+
3. **`AGENTS.md`** — if a new convention, pattern, or workflow was introduced that affects how agents work, add it to the relevant section
204+
4. **`SPECS/deployment.md`** — if CI/CD or publishing workflows changed, update this spec to match
205+
176206
## Environment Variables
177207

178208
| Variable | Required | Description |

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,17 @@ npm run update-api # Update the auto-generated API client
8989
### CI/CD
9090

9191
- **CI**: Runs on every push to `main` and on PRs. Builds and tests across Node.js 18, 20, and 22.
92-
- **Publish**: Triggered on GitHub release creation. Builds, tests, and publishes to npm with provenance.
92+
- **Release**: Uses [changesets](https://github.com/changesets/changesets) for automated versioning and npm publishing.
9393

94-
To publish a new version:
95-
1. Update the version in `package.json`
96-
2. Create a GitHub release with a tag matching the version (e.g. `v1.1.0`)
97-
3. The publish workflow will automatically build and push to npm
94+
#### Publishing a new version
9895

99-
**Prerequisite**: Add an `NPM_TOKEN` secret to your GitHub repository settings.
96+
1. When making changes, run `npx changeset` and describe your change (select `patch`, `minor`, or `major`)
97+
2. Include the generated `.changeset/*.md` file in your PR
98+
3. CI enforces that every PR includes a changeset (use `npx changeset --empty` for changes that don't need a version bump, like docs or CI)
99+
4. When PRs are merged to `main`, the release workflow automatically creates a **"chore: version packages"** PR that bumps the version and updates `CHANGELOG.md`
100+
5. Merging that PR publishes to npm with provenance
101+
102+
**Prerequisite**: An `NPM_TOKEN` secret must be configured in the GitHub repository settings.
100103

101104
## License
102105

SPECS/deployment.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Deployment & CI Spec
22

3-
**Status:** ✅ Done (2026-02-18)
3+
**Status:** ✅ Done (updated 2026-05-08)
44

55
## npm Package
66

77
- **Binary name:** `codacy` (registered in `package.json` under `bin`)
88
- **Included files:** `dist/` and `README.md` (via `files` field)
9-
- **Pre-publish:** `prepublishOnly` runs `npm run build` using `tsconfig.build.json`
10-
- **Engines:** requires Node.js >= 18
9+
- **Pre-publish:** `prepublishOnly` runs `npm run update-api && npm run build` as a safety net for local publishes
10+
- **Engines:** requires Node.js >= 20
1111
- **Install globally:** `npm install -g "@codacy/codacy-cloud-cli"`
1212

1313
## GitHub Actions
@@ -18,23 +18,26 @@ Triggers on: push and pull requests to `main`.
1818

1919
Matrix: Node.js 18, 20, 22.
2020

21-
Steps:
22-
1. Checkout
23-
2. Setup Node
24-
3. `npm ci`
25-
4. `npm run build`
26-
5. `npm test`
21+
Jobs:
22+
- **build-and-test**: checkout → setup node → install → generate API client → type check → build → test
23+
- **changeset-check** (PRs only): verifies at least one `.changeset/*.md` file is present in the PR diff
24+
25+
### Release (`release.yml`)
2726

28-
### Publish to npm (`publish.yml`)
27+
Triggers on: push to `main`.
2928

30-
Triggers on: GitHub release published.
29+
Uses the [changesets/action](https://github.com/changesets/changesets) to automate versioning and publishing.
3130

3231
Steps:
3332
1. Checkout
3433
2. Setup Node with `registry-url: https://registry.npmjs.org`
3534
3. `npm ci`
36-
4. `npm run build`
37-
5. `npm publish` (uses `NODE_AUTH_TOKEN` secret)
35+
4. Generate API client (`npm run update-api`)
36+
5. Build (`npm run build`)
37+
6. Test (`npm test`)
38+
7. `changesets/action` — either:
39+
- Creates/updates a "chore: version packages" PR (bumps version, updates CHANGELOG.md)
40+
- If that PR was just merged, runs `changeset publish` to publish to npm with provenance
3841

3942
## Homebrew Formula
4043

@@ -44,5 +47,5 @@ Planned for future distribution as a separate brew formula for macOS/Linux/Windo
4447

4548
| Secret | Used by |
4649
|---|---|
47-
| `NODE_AUTH_TOKEN` | npm publish workflow |
50+
| `NPM_TOKEN` | Release workflow (`NODE_AUTH_TOKEN` for npm publish) |
4851
| `CODACY_API_TOKEN` | CLI runtime (env var, not a secret in CI) |

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"changeset": "changeset",
2424
"version-packages": "changeset version",
2525
"release": "changeset publish",
26+
"prepublishOnly": "npm run update-api && npm run build",
2627
"start": "npx ts-node src/index.ts",
2728
"start:dist": "node dist/index.js",
2829
"fetch-api": "curl https://artifacts.codacy.com/api/codacy-api/55.6.4/apiv3-bundled.yaml -o ./api-v3/api-swagger.yaml --create-dirs",

0 commit comments

Comments
 (0)