Skip to content

Commit 39b1657

Browse files
authored
ci: set up bundle & package workflow (#41)
Set up Webpack & electron-builder CI workflows. - Added workflow file build.yml & webpack.yml. - Configured nodejs.yml to test build Webpack bundles and Electron app packages (Windows & macOS).
1 parent b4e39cf commit 39b1657

File tree

4 files changed

+156
-2
lines changed

4 files changed

+156
-2
lines changed

.github/workflows/build.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build app package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
test-only:
10+
required: false
11+
type: boolean
12+
13+
jobs:
14+
setup-matrix:
15+
runs-on: ${{ inputs.os }}
16+
outputs:
17+
node_versions: ${{ steps.generate-matrix.outputs.node_versions }}
18+
steps:
19+
- name: Generate matrix
20+
id: generate-matrix
21+
run: |
22+
if [ "${{ inputs.test-only }}" = "true" ]; then
23+
VERSIONS='["14.x", "16.x"]'
24+
else
25+
VERSIONS='["16.x"]'
26+
fi
27+
echo ::set-output name=node_versions::"$VERSIONS"
28+
shell: bash
29+
30+
build-app-package:
31+
needs: setup-matrix
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
node-version: ${{ fromJSON(needs.setup-matrix.outputs.node_versions) }}
36+
name: Build app package with Node v${{ matrix.node-version }} on ${{ inputs.os }}
37+
runs-on: ${{ inputs.os }}
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
42+
- name: Use Node.js ${{ matrix.node-version }}
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: ${{ matrix.node-version }}
46+
cache: npm
47+
48+
- name: Prepare Webpack bundle cache
49+
id: cache-webpack-bundles
50+
uses: actions/cache@v3
51+
with:
52+
path: ./dist
53+
key: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-webpack-${{ inputs.os }}
54+
55+
- name: Install
56+
run: npm ci
57+
58+
- if: ${{ steps.cache-webpack-bundles.outputs.cache-hit != 'true' }}
59+
name: Run webpack
60+
run: npm run prod
61+
62+
- if: ${{ inputs.os == 'ubuntu-latest' }}
63+
name: Build app package on ${{ inputs.os }}
64+
run: |
65+
echo "Build on Linux is not yet supported."
66+
exit 1
67+
68+
- if: ${{ inputs.os == 'macos-latest' }}
69+
name: Build Windows & mac app packages on ${{ inputs.os }}
70+
run: |
71+
if [ "${{ inputs.test-only }}" = "true" ]; then
72+
npm run build:mac -- --publish never
73+
npm run build:win -- --publish never
74+
else
75+
npm run build:mac
76+
npm run build:win
77+
fi
78+
79+
- if: ${{ inputs.os == 'windows-latest' }}
80+
name: Build Windows app package on ${{ inputs.os }}
81+
run: |
82+
if [ "${{ inputs.test-only }}" = "true" ]; then
83+
npm run build:win -- --publish never
84+
else
85+
npm run build:win
86+
fi
87+
shell: bash

.github/workflows/nodejs.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,32 @@ jobs:
5959
needs: prepare-npm-cache-windows
6060
with:
6161
os: windows-latest
62+
63+
bundle-linux:
64+
uses: ./.github/workflows/webpack.yml
65+
needs: test-ubuntu
66+
with:
67+
os: ubuntu-latest
68+
bundle-mac:
69+
uses: ./.github/workflows/webpack.yml
70+
needs: test-macos
71+
with:
72+
os: macos-latest
73+
bundle-windows:
74+
uses: ./.github/workflows/webpack.yml
75+
needs: test-windows
76+
with:
77+
os: windows-latest
78+
79+
build-mac:
80+
uses: ./.github/workflows/build.yml
81+
needs: bundle-mac
82+
with:
83+
os: macos-latest
84+
test-only: true
85+
build-windows:
86+
uses: ./.github/workflows/build.yml
87+
needs: bundle-windows
88+
with:
89+
os: windows-latest
90+
test-only: true

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
cache: npm
26-
- name: install
26+
- name: Install
2727
run: npm ci --omit optional
28-
- name: run tests
28+
- name: Run tests
2929
run: npm run jest-ci

.github/workflows/webpack.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Webpack CI
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build-bundle:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
node-version: [14.x, 16.x]
16+
name: Build Webpack bundles with Node v${{ matrix.node-version }} on ${{ inputs.os }}
17+
runs-on: ${{ inputs.os }}
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: npm
27+
28+
- name: Cache Webpack bundles
29+
id: cache-webpack-bundles
30+
uses: actions/cache@v3
31+
with:
32+
path: ./dist
33+
key: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-webpack-${{ inputs.os }}
34+
35+
- name: Install
36+
run: npm ci
37+
- name: Run webpack
38+
run: npm run prod

0 commit comments

Comments
 (0)