Skip to content

Commit 127c88f

Browse files
committed
chore: switch to npm trusted publishing, remove auto-merge workflow
- Rewrite release.yml to use OIDC trusted publishing (no NPM_TOKEN needed) - Trigger releases on v* tag push instead of workflow_dispatch - Provenance attestations are generated automatically - Remove dependabot-auto-merge.yml workflow - Add RELEASE.md with setup and publishing instructions
1 parent e001122 commit 127c88f

4 files changed

Lines changed: 110 additions & 36 deletions

File tree

.changeset/eslint-10-support.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ Add ESLint 10 support. This is a breaking change — ESLint 9 is no longer suppo
88
- Update peer dependency to `eslint ^10.0.0`
99
- Update all dev dependencies to latest versions
1010
- Migrate from yarn to pnpm
11+
- Switch release workflow to npm trusted publishing (OIDC)
12+
- Remove dependabot-auto-merge workflow

.github/workflows/dependabot-auto-merge.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
name: Release
22

3-
on: workflow_dispatch
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
id-token: write
411

512
jobs:
613
release:
7-
name: Release
14+
name: Publish to npm
815
runs-on: ubuntu-latest
916
steps:
1017
- name: Checkout Repo
1118
uses: actions/checkout@v4
1219
with:
13-
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1420
fetch-depth: 0
1521

16-
- name: Setup Node.js 20.x
22+
- name: Setup Node.js 22.x
1723
uses: actions/setup-node@v4
1824
with:
19-
node-version: 20.x
25+
node-version: 22.x
26+
registry-url: "https://registry.npmjs.org"
2027

2128
- name: Install pnpm
2229
uses: pnpm/action-setup@v4
@@ -26,13 +33,13 @@ jobs:
2633
- name: Install Dependencies
2734
run: pnpm install
2835

29-
- name: Create Release Pull Request or Publish to npm
30-
id: changesets
31-
uses: changesets/action@master
36+
- name: Run Tests
37+
run: pnpm test
38+
39+
- name: Publish to npm (trusted publishing)
40+
run: npm publish --access public
41+
42+
- name: Create GitHub Release
43+
uses: softprops/action-gh-release@v2
3244
with:
33-
publish: pnpm release
34-
commit: 'chore(release): update monorepo packages versions'
35-
title: 'Upcoming Release Changes'
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
generate_release_notes: true

RELEASE.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Release Process
2+
3+
This project uses **npm trusted publishing** with OIDC — no npm tokens are
4+
needed for publishing. Provenance attestations are generated automatically.
5+
6+
---
7+
8+
## One-Time Setup
9+
10+
These steps only need to be done once, before the first release.
11+
12+
### 1. Configure trusted publishing on npmjs.com
13+
14+
1. Go to https://www.npmjs.com/package/eslint-plugin-sort-keys-shorthand/access
15+
2. Sign in as a package owner
16+
3. Scroll to **"Trusted Publisher"** and click **GitHub Actions**
17+
4. Fill in the form:
18+
- **Organization or user:** `fxOne`
19+
- **Repository:** `eslint-plugin-sort-keys-shorthand`
20+
- **Workflow filename:** `release.yml`
21+
- **Environment name:** _(leave empty)_
22+
5. Save
23+
24+
### 2. Lock down token access (recommended)
25+
26+
1. On the same package settings page, go to **"Publishing access"**
27+
2. Select **"Require two-factor authentication and disallow tokens"**
28+
3. Save
29+
30+
### 3. Remove the old NPM_TOKEN secret from GitHub
31+
32+
1. Go to https://github.com/fxOne/eslint-plugin-sort-keys-shorthand/settings/secrets/actions
33+
2. Delete the `NPM_TOKEN` secret (no longer needed)
34+
3. Optionally delete the `AUTOMERGE_TOKEN` secret as well
35+
(the `dependabot-auto-merge.yml` workflow has been removed)
36+
37+
### 4. Revoke old npm access tokens
38+
39+
1. Go to https://www.npmjs.com/settings/~/tokens
40+
2. Revoke any automation/publish tokens that were previously used by CI
41+
42+
---
43+
44+
## Publishing a New Release
45+
46+
### Step 1: Merge the release PR
47+
48+
Merge the release pull request into `master` on GitHub.
49+
50+
### Step 2: Tag the release
51+
52+
```bash
53+
git checkout master
54+
git pull origin master
55+
git tag v4.0.0
56+
git push origin v4.0.0
57+
```
58+
59+
### Step 3: Automated release
60+
61+
Pushing the `v*` tag automatically triggers the **Release** workflow which:
62+
63+
1. Checks out the code
64+
2. Installs dependencies with pnpm
65+
3. Runs the full test suite
66+
4. Publishes to npm using OIDC (no token needed)
67+
5. Creates a GitHub Release with auto-generated release notes
68+
69+
### Step 4: Verify
70+
71+
- Check the workflow run: https://github.com/fxOne/eslint-plugin-sort-keys-shorthand/actions/workflows/release.yml
72+
- Verify the package on npm: https://www.npmjs.com/package/eslint-plugin-sort-keys-shorthand
73+
- The package page should show a **"Provenance"** badge confirming the build origin
74+
75+
---
76+
77+
## How It Works
78+
79+
The release workflow uses **npm trusted publishing** via OpenID Connect (OIDC):
80+
81+
- No `NPM_TOKEN` secret is stored in GitHub
82+
- GitHub Actions mints a short-lived OIDC token during the workflow run
83+
- npm verifies the token against the trusted publisher config on npmjs.com
84+
- Provenance attestations are generated automatically (signed by Sigstore)
85+
- The OIDC token cannot be extracted, reused, or leaked
86+
87+
For more info: https://docs.npmjs.com/trusted-publishers

0 commit comments

Comments
 (0)