1- name : Build CAN Tool
1+ name : CAN Tool – Build & (optional) Release
22
33on :
4+ workflow_dispatch :
45 push :
5- branches : [ feature/packaged-executable ]
6- paths :
7- - ' backend/**'
8- - ' frontend/**'
9- - ' can-tool.spec'
10- - ' .github/workflows/**'
6+ branches : [ main, feature/packaged-executable ]
7+ tags :
8+ - ' v*' # push a tag like v1.2.3 to create a release
119 pull_request :
12- branches : [ feature/packaged-executable ]
10+ branches : [ main ]
11+
12+ permissions :
13+ contents : read
14+
15+ concurrency :
16+ group : ${{ github.workflow }}-${{ github.ref }}
17+ cancel-in-progress : true
1318
1419jobs :
1520 build :
21+ name : Build (${{ matrix.os }})
22+ runs-on : ${{ matrix.os }}
1623 strategy :
1724 fail-fast : false
1825 matrix :
19- os : [ubuntu-latest, windows-latest, macos-latest]
20- py : ['3.12']
21-
22- runs-on : ${{ matrix.os }}
26+ os : [ubuntu-22.04, windows-latest, macos-13] # macOS Intel; add macos-latest if you want Apple Silicon runners
2327
2428 steps :
2529 - name : Checkout
26- - uses : actions/checkout@v4
30+ uses : actions/checkout@v4
2731
28- # ---------- Frontend build ----------
29- - name : Setup Node.js
32+ # ---------- Frontend ----------
33+ - name : Setup Node
3034 uses : actions/setup-node@v4
3135 with :
3236 node-version : ' 20'
3337 cache : ' npm'
3438 cache-dependency-path : frontend/package-lock.json
3539
36- - name : Build frontend
40+ - name : Install & build frontend
3741 working-directory : frontend
3842 run : |
3943 npm ci || npm install
4044 npm run build
4145
42- - name : Stage static into backend/static
46+ - name : Stage built frontend into backend/static
4347 run : |
4448 rm -rf backend/static
4549 mkdir -p backend/static
4650 cp -r frontend/dist/* backend/static/
4751
48- # ---------- Python build ----------
52+ # ---------- Backend / PyInstaller ----------
4953 - name : Setup Python
5054 uses : actions/setup-python@v5
5155 with :
52- python-version : ${{ matrix.py }}
56+ python-version : ' 3.12'
57+ cache : ' pip'
58+ cache-dependency-path : |
59+ backend/requirements.txt
60+ can-tool.spec
5361
54- - name : Install Python deps
62+ - name : Install backend deps
5563 run : |
5664 python -m pip install --upgrade pip
57- # tolerate missing requirements.txt
58- if [ -f backend/requirements.txt ]; then pip install -r backend/requirements.txt; fi
59- pip install pyinstaller fastapi uvicorn "python-can>=4" jinja2
65+ if [ -f backend/requirements.txt ]; then
66+ pip install -r backend/requirements.txt
67+ else
68+ pip install fastapi "uvicorn[standard]" pyinstaller python-can pydantic jinja2
69+ fi
6070
61- - name : Build with PyInstaller
71+ - name : Build executable with PyInstaller
6272 run : |
6373 pyinstaller --clean --noconfirm can-tool.spec
6474
@@ -67,18 +77,42 @@ jobs:
6777 if : startsWith(matrix.os, 'windows')
6878 shell : pwsh
6979 run : |
70- Compress-Archive -Path dist\can-tool.exe -DestinationPath can-tool-${{ matrix.os }}.zip
80+ New-Item -ItemType Directory -Force -Path package | Out-Null
81+ Copy-Item dist\can-tool.exe package\
82+ Compress-Archive -Path package\* -DestinationPath can-tool-${{ matrix.os }}.zip
7183
7284 - name : Package (Unix)
7385 if : ${{ !startsWith(matrix.os, 'windows') }}
7486 run : |
7587 tar -C dist -czf can-tool-${{ matrix.os }}.tar.gz can-tool
7688
77- - name : Upload artifacts
89+ - name : Upload artifact
7890 uses : actions/upload-artifact@v4
7991 with :
8092 name : can-tool-${{ matrix.os }}
8193 path : |
8294 can-tool-*.zip
8395 can-tool-*.tar.gz
8496 dist/**
97+
98+ release :
99+ name : Create GitHub Release
100+ needs : build
101+ runs-on : ubuntu-22.04
102+ if : startsWith(github.ref, 'refs/tags/')
103+ permissions :
104+ contents : write # required to create a release
105+
106+ steps :
107+ - name : Download all build artifacts
108+ uses : actions/download-artifact@v4
109+ with :
110+ path : artifacts
111+
112+ - name : Create Release
113+ uses : softprops/action-gh-release@v2
114+ with :
115+ generate_release_notes : true
116+ files : |
117+ artifacts/**/can-tool-*.zip
118+ artifacts/**/can-tool-*.tar.gz
0 commit comments