Skip to content

Commit

Permalink
Automate publishes (#1532)
Browse files Browse the repository at this point in the history
On release creation on GitHub

Publish to npm and jsr
  • Loading branch information
fb55 authored Jul 24, 2024
1 parent aafaf2b commit 4e80a0a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: https://registry.npmjs.org
cache: npm

- name: Install dependencies
run: npm ci

- name: Update package version to latest tag
run: |
npm version from-git --allowSameVersion
git push --follow-tags
- name: Create jsr.json based on package.json
run: |
node -e '
const p = require("./package.json");
const jsrJson = {
name: `@cheerio/${p.name}`,
version: p.version,
...p.tshy,
};
require("fs").writeFileSync("./jsr.json", JSON.stringify(jsrJson, null, 2));
'
- name: Publish package to JSR
run: npx jsr publish

- name: Publish package to NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ coverage/
dist/
.tshy/
docs/
jsr.json
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"src"
],
"scripts": {
"build": "tshy",
"build:docs": "typedoc --hideGenerator src/index.ts",
"build:encode-trie": "node --import=tsx scripts/write-encode-map.ts",
"build:trie": "node --import=tsx scripts/write-decode-map.ts",
Expand All @@ -71,7 +70,7 @@
"lint:es": "eslint . --ignore-path .gitignore",
"lint:prettier": "npm run prettier -- --check",
"lint:ts": "tsc --noEmit",
"prepare": "npm run build",
"prepublishOnly": "tshy",
"prettier": "prettier '**/*.{ts,md,json,yml}'",
"test": "npm run test:vi && npm run lint",
"test:vi": "vitest run"
Expand Down

0 comments on commit 4e80a0a

Please sign in to comment.