Skip to content

Commit fc613e0

Browse files
authored
Use NPM trusted publishing (#725)
NPM classic tokens are no more, trusted publishing is the future. Prevent failures like https://github.com/amacneil/dbmate/actions/runs/20837451898/job/59865223681 <!-- CURSOR_SUMMARY --> > [!NOTE] > Adopts NPM OIDC trusted publishing and tidies GitHub workflows and package metadata. > > - CI `npm` job: grants `id-token` permissions, enables `corepack`, removes registry/token usage; `typescript/publish.ts` unsets `NODE_AUTH_TOKEN` and publishes via `corepack npm publish --provenance` > - Moves Dependabot auto-approve into new `dependabot.yml`; minor naming tweaks in post-release workflow > - Adds empty `.prettierrc.json`; sets `packageManager` in `typescript/package.json` > - Updates package metadata for `dbmate` and template packages (repository format, bin mapping, homepage/author) > - Bumps `pkg/dbmate/version.go` to `2.29.1` > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 00b792f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3f099ae commit fc613e0

File tree

9 files changed

+56
-28
lines changed

9 files changed

+56
-28
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,18 @@ jobs:
181181
name: NPM
182182
runs-on: ubuntu-latest
183183
needs: build
184+
permissions:
185+
contents: read
186+
id-token: write
184187

185188
steps:
186189
- uses: actions/checkout@v6
187190

191+
- run: corepack enable
192+
188193
- uses: actions/setup-node@v6
189194
with:
190195
node-version: 20
191-
registry-url: https://registry.npmjs.org
192196
cache: npm
193197
cache-dependency-path: typescript/package-lock.json
194198

@@ -210,23 +214,3 @@ jobs:
210214
- run: npm run publish
211215
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
212216
working-directory: typescript
213-
env:
214-
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
215-
216-
dependabot:
217-
name: Dependabot
218-
runs-on: ubuntu-latest
219-
permissions:
220-
pull-requests: write
221-
if: github.event.pull_request.user.login == 'dependabot[bot]'
222-
steps:
223-
- name: Automatically approve dependabot PRs
224-
uses: octokit/request-action@v2.x
225-
with:
226-
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews
227-
owner: ${{ github.event.repository.owner.login }}
228-
repo: ${{ github.event.repository.name }}
229-
pull_number: ${{ github.event.pull_request.number }}
230-
event: APPROVE
231-
env:
232-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/dependabot.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Dependabot
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
approve:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
pull-requests: write
11+
if: github.event.pull_request.user.login == 'dependabot[bot]'
12+
steps:
13+
- name: Approve Dependabot PR
14+
uses: octokit/request-action@v2.x
15+
with:
16+
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews
17+
owner: ${{ github.event.repository.owner.login }}
18+
repo: ${{ github.event.repository.name }}
19+
pull_number: ${{ github.event.pull_request.number }}
20+
event: APPROVE
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Release
1+
name: Post Release
22

33
on:
44
push:
55
tags: ["v*"]
66

77
jobs:
88
homebrew:
9-
name: Bump Homebrew formula
9+
name: Bump Homebrew Formula
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: mislav/bump-homebrew-formula-action@v3

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

pkg/dbmate/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package dbmate
22

33
// Version of dbmate
4-
const Version = "2.29.0"
4+
const Version = "2.29.1"

typescript/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"private": true,
3+
"packageManager": "npm@11.7.0",
34
"scripts": {
45
"clean": "rimraf dist packages/dbmate/dist",
56
"lint": "eslint --report-unused-disable-directives --fix .",

typescript/packages/dbmate/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"name": "dbmate",
33
"version": "",
44
"description": "A lightweight, framework-agnostic database migration tool",
5-
"repository": "https://github.com/amacneil/dbmate",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/amacneil/dbmate.git"
8+
},
69
"homepage": "https://github.com/amacneil/dbmate#readme",
710
"author": "Adrian Macneil",
811
"license": "MIT",
@@ -15,7 +18,9 @@
1518
"schema",
1619
"sqlite"
1720
],
18-
"bin": "./dist/cli.js",
21+
"bin": {
22+
"dbmate": "dist/cli.js"
23+
},
1924
"main": "./dist/index.js",
2025
"files": [
2126
"dist"

typescript/packages/template/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
"name": "{{name}}",
33
"version": "{{version}}",
44
"description": "The {{jsOS}} {{jsArch}} binary for dbmate",
5-
"repository": "https://github.com/amacneil/dbmate",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/amacneil/dbmate.git"
8+
},
9+
"homepage": "https://github.com/amacneil/dbmate#readme",
10+
"author": "Adrian Macneil",
611
"license": "MIT",
712
"preferUnplugged": true,
813
"os": [

typescript/publish.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ async function main() {
88
);
99

1010
for (const pkg of packages) {
11-
await exec("npm", ["publish", "--access", "public", pkg]);
11+
// Unset NODE_AUTH_TOKEN to avoid conflicts with OIDC trusted publishing
12+
delete process.env.NODE_AUTH_TOKEN;
13+
await exec("corepack", ["npm", "--version"]);
14+
await exec("corepack", [
15+
"npm",
16+
"publish",
17+
"--provenance",
18+
"--access",
19+
"public",
20+
pkg,
21+
]);
1222
}
1323
}
1424

0 commit comments

Comments
 (0)