Skip to content

Commit

Permalink
update build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongyumail committed Mar 10, 2025
1 parent 722be1a commit 25fc911
Showing 1 changed file with 65 additions and 28 deletions.
93 changes: 65 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Build Executable
name: Build and Release

on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [created]

jobs:
build:
Expand All @@ -16,27 +15,65 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build executable
run: |
pyinstaller display.spec
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: display-${{ matrix.os }}
path: |
dist/
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build executable
run: pyinstaller display.spec

- name: Rename executable
shell: bash
run: |
cd dist
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv display.exe ../display-windows.exe
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
mv display ../display-macos
else
mv display ../display-linux
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: display-${{ matrix.os }}
path: |
display-*
if-no-files-found: error

release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: display-*
merge-multiple: true

- name: Prepare release assets
run: |
mkdir -p release-assets
cp artifacts/* release-assets/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 25fc911

Please sign in to comment.