|
1 | | -name: Build plugin |
2 | | - |
3 | | -permissions: |
4 | | - contents: write |
5 | | - |
6 | | -on: |
7 | | - release: |
8 | | - types: [published] |
9 | | - workflow_dispatch: {} |
10 | | - |
11 | | -jobs: |
12 | | - build: |
13 | | - name: Build JS bundles |
14 | | - runs-on: ubuntu-latest |
15 | | - |
16 | | - steps: |
17 | | - - name: Checkout repository |
18 | | - uses: actions/checkout@v4 |
19 | | - |
20 | | - - name: Setup Node.js |
21 | | - uses: actions/setup-node@v4 |
22 | | - with: |
23 | | - node-version: 18 |
24 | | - |
25 | | - - name: Install dependencies |
26 | | - run: | |
27 | | - npm ci || npm install |
28 | | -
|
29 | | - - name: Create dist directory |
30 | | - run: mkdir -p dist |
31 | | - |
32 | | - - name: Build unminified bundle with esbuild |
33 | | - run: | |
34 | | - npx esbuild src/index.js \ |
35 | | - --bundle \ |
36 | | - --format=iife \ |
37 | | - --global-name=YasguiGraphPlugin \ |
38 | | - --define:process.env.NODE_ENV=\"production\" \ |
39 | | - --loader:.png=dataurl \ |
40 | | - --loader:.svg=dataurl \ |
41 | | - --loader:.jpg=dataurl \ |
42 | | - --loader:.gif=dataurl \ |
43 | | - --outfile=dist/yasgui-graph-plugin.js |
44 | | -
|
45 | | - - name: Build minified bundle with esbuild |
46 | | - run: | |
47 | | - npx esbuild src/index.js \ |
48 | | - --bundle \ |
49 | | - --minify \ |
50 | | - --format=iife \ |
51 | | - --global-name=YasguiGraphPlugin \ |
52 | | - --define:process.env.NODE_ENV=\"production\" \ |
53 | | - --loader:.png=dataurl \ |
54 | | - --loader:.svg=dataurl \ |
55 | | - --loader:.jpg=dataurl \ |
56 | | - --loader:.gif=dataurl \ |
57 | | - --outfile=dist/yasgui-graph-plugin.min.js |
58 | | -
|
59 | | - - name: Create minified CSS (if available) |
60 | | - run: | |
61 | | - # prefer a root style.css, then demo/style.css, otherwise create a minimal placeholder |
62 | | - if [ -f style.css ]; then |
63 | | - cat style.css > dist/yasgui-graph-plugin.min.css |
64 | | - elif [ -f demo/style.css ]; then |
65 | | - cat demo/style.css > dist/yasgui-graph-plugin.min.css |
66 | | - else |
67 | | - echo '/* yasgui-graph-plugin: no CSS provided */' > dist/yasgui-graph-plugin.min.css |
68 | | - fi |
69 | | -
|
70 | | - - name: Upload minified JS to GitHub Release |
71 | | - if: github.event_name == 'release' |
72 | | - uses: softprops/action-gh-release@v2 |
73 | | - with: |
74 | | - files: | |
75 | | - dist/yasgui-graph-plugin.min.js |
76 | | - dist/yasgui-graph-plugin.min.css |
| 1 | +name: Build plugin |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + workflow_dispatch: {} |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build JS bundles |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: 18 |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + npm ci || npm install |
| 28 | +
|
| 29 | + - name: Create dist directory |
| 30 | + run: mkdir -p dist |
| 31 | + |
| 32 | + - name: Build unminified bundle with esbuild |
| 33 | + run: | |
| 34 | + npx esbuild src/index.ts \ |
| 35 | + --bundle \ |
| 36 | + --format=iife \ |
| 37 | + --global-name=YasguiGraphPlugin \ |
| 38 | + --define:process.env.NODE_ENV=\"production\" \ |
| 39 | + --loader:.png=dataurl \ |
| 40 | + --loader:.svg=dataurl \ |
| 41 | + --loader:.jpg=dataurl \ |
| 42 | + --loader:.gif=dataurl \ |
| 43 | + --outfile=dist/yasgui-graph-plugin.js |
| 44 | +
|
| 45 | + - name: Build minified bundle with esbuild |
| 46 | + run: | |
| 47 | + npx esbuild src/index.ts \ |
| 48 | + --bundle \ |
| 49 | + --minify \ |
| 50 | + --format=iife \ |
| 51 | + --global-name=YasguiGraphPlugin \ |
| 52 | + --define:process.env.NODE_ENV=\"production\" \ |
| 53 | + --loader:.png=dataurl \ |
| 54 | + --loader:.svg=dataurl \ |
| 55 | + --loader:.jpg=dataurl \ |
| 56 | + --loader:.gif=dataurl \ |
| 57 | + --outfile=dist/yasgui-graph-plugin.min.js |
| 58 | +
|
| 59 | + - name: Create minified CSS (if available) |
| 60 | + run: | |
| 61 | + # prefer a root style.css, then demo/style.css, otherwise create a minimal placeholder |
| 62 | + if [ -f style.css ]; then |
| 63 | + cat style.css > dist/yasgui-graph-plugin.min.css |
| 64 | + elif [ -f demo/style.css ]; then |
| 65 | + cat demo/style.css > dist/yasgui-graph-plugin.min.css |
| 66 | + else |
| 67 | + echo '/* yasgui-graph-plugin: no CSS provided */' > dist/yasgui-graph-plugin.min.css |
| 68 | + fi |
| 69 | +
|
| 70 | + - name: Upload minified JS to GitHub Release |
| 71 | + if: github.event_name == 'release' |
| 72 | + uses: softprops/action-gh-release@v2 |
| 73 | + with: |
| 74 | + files: | |
| 75 | + dist/yasgui-graph-plugin.min.js |
| 76 | + dist/yasgui-graph-plugin.min.css |
0 commit comments