Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate publishes #1532

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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