Skip to content

Commit 77f658f

Browse files
committed
feat(ci): update build workflow for release
Refactors the CI workflow to create a release first, then build and upload assets for multiple OS. Includes PyInstaller icon and name.
1 parent c046933 commit 77f658f

1 file changed

Lines changed: 37 additions & 23 deletions

File tree

.github/workflows/build.yml

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Build and Release
32

43
on:
@@ -7,45 +6,60 @@ on:
76
- main
87

98
jobs:
10-
build:
9+
create_release:
10+
name: Create Release
1111
runs-on: ubuntu-latest
12+
outputs:
13+
upload_url: ${{ steps.create_release.outputs.upload_url }}
14+
steps:
15+
- name: Create Release
16+
id: create_release
17+
uses: actions/create-release@v1
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
tag_name: v${{ github.run_number }}
22+
release_name: Release v${{ github.run_number }}
23+
draft: false
24+
prerelease: false
1225

26+
build_and_upload:
27+
name: Build and Upload on ${{ matrix.os }}
28+
needs: create_release
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
matrix:
32+
os: [ubuntu-latest, windows-latest]
33+
include:
34+
- os: ubuntu-latest
35+
asset_name: ai-commit-linux
36+
asset_path_suffix: AI-Commit
37+
- os: windows-latest
38+
asset_name: ai-commit-windows.exe
39+
asset_path_suffix: AI-Commit.exe
1340
steps:
1441
- name: Checkout code
15-
uses: actions/checkout@v2
42+
uses: actions/checkout@v4
1643

1744
- name: Set up Python
18-
uses: actions/setup-python@v2
45+
uses: actions/setup-python@v5
1946
with:
20-
python-version: 3.9
47+
python-version: 3.10
2148

2249
- name: Install dependencies
2350
run: |
2451
python -m pip install --upgrade pip
2552
pip install -r requirements.txt
26-
pip install pyinstaller
2753
2854
- name: Build with PyInstaller
29-
run: pyinstaller --onefile main.py
30-
31-
- name: Create Release
32-
id: create_release
33-
uses: actions/create-release@v1
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
with:
37-
tag_name: ${{ github.run_number }}
38-
release_name: Release ${{ github.run_number }}
39-
draft: false
40-
prerelease: false
55+
run: pyinstaller --name "AI-Commit" --windowed --onefile --icon="assets/icon.ico" main.py
4156

4257
- name: Upload Release Asset
43-
id: upload-release-asset
4458
uses: actions/upload-release-asset@v1
4559
env:
4660
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4761
with:
48-
upload_url: ${{ steps.create_release.outputs.upload_url }}
49-
asset_path: ./dist/main
50-
asset_name: ai-commit
51-
asset_content_type: application/octet-stream
62+
upload_url: ${{ needs.create_release.outputs.upload_url }}
63+
asset_path: ./dist/${{ matrix.asset_path_suffix }}
64+
asset_name: ${{ matrix.asset_name }}
65+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)