Skip to content

Commit

Permalink
Further automate publishing of undici-types using GitHub Actions work…
Browse files Browse the repository at this point in the history
…flow (#2290)

* add workflow

* improve automation

* linting
  • Loading branch information
Ethan-Arrowood authored Oct 2, 2023
1 parent 5a75005 commit 4024468
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 74 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/publish-undici-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: node scripts/generate-undici-types-package-json.js
- run: cd types
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"bench:run": "CONNECTIONS=1 node benchmarks/benchmark.js; CONNECTIONS=50 node benchmarks/benchmark.js",
"serve:website": "docsify serve .",
"prepare": "husky install",
"postpublish": "node scripts/update-undici-types-version.js && cd types && npm publish",
"fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
},
"devDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions scripts/generate-undici-types-package-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const fs = require('node:fs')
const path = require('node:path')

const packageJSONPath = path.join(__dirname, '..', 'package.json')
const packageJSONRaw = fs.readFileSync(packageJSONPath, 'utf-8')
const packageJSON = JSON.parse(packageJSONRaw)

const packageTypesJSON = {
name: 'undici-types',
version: packageJSON.version,
description: 'A stand-alone types package for Undici',
homepage: packageJSON.homepage,
bugs: packageJSON.bugs,
repository: packageJSON.repository,
license: packageJSON.license,
types: 'index.d.ts',
files: ['*.d.ts'],
contributors: packageJSON.contributors
}

const packageTypesPath = path.join(__dirname, '..', 'types', 'package.json')

fs.writeFileSync(packageTypesPath, JSON.stringify(packageTypesJSON, null, 2))
18 changes: 0 additions & 18 deletions scripts/update-undici-types-version.js

This file was deleted.

55 changes: 0 additions & 55 deletions types/package.json

This file was deleted.

0 comments on commit 4024468

Please sign in to comment.