Skip to content

Commit d5cff87

Browse files
committed
Create build.yml
1 parent 07300b0 commit d5cff87

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

.github/workflows/build.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# main.yml
2+
3+
# Workflow's name
4+
name: Build Electron App For Windows/macOs/Ubuntu
5+
6+
# Workflow's trigger
7+
on:
8+
push:
9+
tags:
10+
- "v*.*.*"
11+
12+
# Workflow's jobs
13+
jobs:
14+
# job's id
15+
release:
16+
# job's name
17+
name: build and release electron app
18+
19+
# the type of machine to run the job on
20+
runs-on: ${{ matrix.os }}
21+
22+
# create a build matrix for jobs
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
os: [windows-latest, macos-latest, 'ubuntu-latest']
27+
28+
# create steps
29+
steps:
30+
# step1: check out repository
31+
- name: Check out git repository
32+
uses: actions/checkout@v3
33+
34+
# step2: install node env
35+
- name: Install Node.js
36+
uses: actions/setup-node@v3
37+
with:
38+
node-version: 16
39+
40+
# step3: npm install
41+
- name: npm install
42+
run: |
43+
npm install --legacy-peer-deps
44+
45+
# step4: build app for mac/win/linux
46+
- name: Build windows app
47+
if: matrix.os == 'windows-latest'
48+
run: |
49+
npm run electron:build
50+
env:
51+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Build mac app
54+
if: matrix.os == 'macos-latest'
55+
run: |
56+
npm run electron:build
57+
env:
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Build ubuntu app
61+
if: matrix.os == 'ubuntu-latest'
62+
run: |
63+
npm run electron:build
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
# step5: cleanup artifacts in dist_electron
68+
- name: cleanup artifacts for windows
69+
if: matrix.os == 'windows-latest'
70+
run: |
71+
npx rimraf "dist_electron/!(*.exe)"
72+
73+
- name: cleanup artifacts for macos
74+
if: matrix.os == 'macos-latest'
75+
run: |
76+
npx rimraf "dist_electron/!(*.dmg)"
77+
78+
- name: cleanup artifacts for ubuntu
79+
if: matrix.os == 'ubuntu-latest'
80+
run: |
81+
npx rimraf "dist_electron/!(*.AppImage)"
82+
83+
# step6: upload artifacts
84+
- name: upload artifacts
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: ${{ matrix.os }}
88+
path: dist_electron
89+
90+
# step7: create release
91+
- name: release
92+
uses: softprops/action-gh-release@v1
93+
if: startsWith(github.ref, 'refs/tags/')
94+
with:
95+
prerelease: true
96+
files: "dist_electron/**"
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)