Skip to content

Commit ea3e22e

Browse files
authored
Add CI (#4)
1 parent f1fa585 commit ea3e22e

File tree

4 files changed

+62
-5
lines changed

4 files changed

+62
-5
lines changed

.github/workflows/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish NPM Package to GitHub Packages and npm
2+
3+
on:
4+
push:
5+
branches:
6+
- ci
7+
tags:
8+
- 'v*.*.*'
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
23+
- name: Install dependencies
24+
run: npm install
25+
26+
- name: Build Plugin
27+
run: npm run build
28+
29+
- name: Authenticate with GitHub Packages
30+
run: |
31+
echo "//npm.pkg.github.com/:_authToken=${{secrets.PUBLISH_GITHUB_TOKEN}}" > ~/.npmrc
32+
echo "registry=https://npm.pkg.github.com" >> ~/.npmrc
33+
34+
- name: Test publish to GitHub Packages
35+
if: github.ref == 'refs/heads/ci'
36+
run: |
37+
echo "Testing publish to GitHub Packages..."
38+
npm publish --dry-run --registry=https://npm.pkg.github.com
39+
40+
- name: Publish to GitHub Packages
41+
if: startsWith(github.ref, 'refs/tags/v')
42+
run: npm publish --registry=https://npm.pkg.github.com
43+
44+
- name: Authenticate with npm
45+
run: |
46+
echo "//registry.npmjs.org/:_authToken=${{secrets.PUBLISH_NPM_TOKEN}}" >> ~/.npmrc
47+
48+
- name: Test publish to npm registry
49+
if: github.ref == 'refs/heads/ci'
50+
run: |
51+
echo "Testing publish to npm registry..."
52+
npm publish --dry-run --registry=https://registry.npmjs.org
53+
54+
- name: Publish to npm registry
55+
if: startsWith(github.ref, 'refs/tags/v')
56+
run: npm publish --registry=https://registry.npmjs.org

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build/
22
screenshots.png
33
.idea/
4+
.github/
45
src/

build/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const rollup = require('rollup')
22
const buble = require('rollup-plugin-buble')
33
const commonjs = require('rollup-plugin-commonjs')
44
const nodeResolve = require('rollup-plugin-node-resolve')
5-
const { uglify } = require('rollup-plugin-uglify')
5+
const terser = require('@rollup/plugin-terser')
66
const replace = require('rollup-plugin-replace')
77
const isProd = process.env.NODE_ENV === 'production'
88
const version = process.env.VERSION || require('../package.json').version
@@ -65,7 +65,7 @@ async function buildPlugin() {
6565
promises.push(build({
6666
input: 'src/' + item.input,
6767
output: item.name + '.min.js',
68-
plugins: [uglify()]
68+
plugins: [terser()]
6969
}))
7070
})
7171
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@sy-records/docsify-footnotes",
33
"version": "2.0.0",
44
"description": "A plugin that supports the use of footnotes in docsify.",
5-
"main": "src/index.js",
5+
"main": "dist/index.js",
66
"repository": {
77
"type": "git",
88
"url": "git+https://github.com/sy-records/docsify-footnotes.git"
@@ -19,14 +19,14 @@
1919
},
2020
"homepage": "https://github.com/sy-records/docsify-footnotes#readme",
2121
"devDependencies": {
22+
"@rollup/plugin-terser": "^0.4.4",
2223
"cross-env": "^6.0.3",
2324
"rollup": "^2.79.2",
2425
"rollup-plugin-async": "^1.2.0",
2526
"rollup-plugin-buble": "^0.19.8",
2627
"rollup-plugin-commonjs": "^10.1.0",
2728
"rollup-plugin-node-resolve": "^5.2.0",
28-
"rollup-plugin-replace": "^2.2.0",
29-
"rollup-plugin-uglify": "^6.0.4"
29+
"rollup-plugin-replace": "^2.2.0"
3030
},
3131
"scripts": {
3232
"build": "cross-env NODE_ENV=production node build/build.js"

0 commit comments

Comments
 (0)