mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
ci: add script to prune package.json
for release
This commit is contained in:
parent
b54fda9457
commit
37c8100d52
2 changed files with 38 additions and 8 deletions
20
.github/workflows/release.yml
vendored
20
.github/workflows/release.yml
vendored
|
@ -4,7 +4,7 @@ on:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
@ -15,19 +15,23 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: "20.x"
|
node-version: "20.x"
|
||||||
registry-url: "https://registry.npmjs.org"
|
registry-url: "https://registry.npmjs.org"
|
||||||
- name: Build
|
|
||||||
run: |
|
- name: Install dependencies
|
||||||
npm install
|
run: npm install
|
||||||
npm run build:docs & npm run build:lib
|
|
||||||
|
- name: Build docs and library
|
||||||
|
run: npm run build:docs & npm run build:lib
|
||||||
|
|
||||||
|
- name: Prune package.json
|
||||||
|
run: node scripts/build-package.js
|
||||||
|
|
||||||
- name: Publish package (stable)
|
- name: Publish package (stable)
|
||||||
if: ${{ ! contains(github.ref, '-next') }}
|
if: ${{ ! contains(github.ref, '-next') }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
||||||
|
|
||||||
# Currently, only npm supports publishing packages with provenance
|
|
||||||
# https://docs.npmjs.com/generating-provenance-statements
|
|
||||||
run: |
|
run: |
|
||||||
npm publish --provenance --access public
|
npm publish --provenance --access public
|
||||||
|
|
||||||
- name: Publish package (next)
|
- name: Publish package (next)
|
||||||
if: ${{ contains(github.ref, '-next') }}
|
if: ${{ contains(github.ref, '-next') }}
|
||||||
env:
|
env:
|
||||||
|
|
26
scripts/build-package.js
Normal file
26
scripts/build-package.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const path = require("node:path");
|
||||||
|
|
||||||
|
const packagePath = path.join(process.cwd(), "package.json");
|
||||||
|
const package = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
||||||
|
|
||||||
|
const keys_to_remove = ["prettier", "standard-version", "devDependencies"];
|
||||||
|
const scripts_to_keep = ["postinstall"];
|
||||||
|
|
||||||
|
for (const key of keys_to_remove) {
|
||||||
|
delete package[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (package.scripts) {
|
||||||
|
const preserved_scripts = {};
|
||||||
|
|
||||||
|
for (const script of scripts_to_keep) {
|
||||||
|
if (package.scripts[script]) {
|
||||||
|
preserved_scripts[script] = package.scripts[script];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package.scripts = preserved_scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2) + "\n");
|
Loading…
Add table
Add a link
Reference in a new issue