Skip to content

Commit

Permalink
添加多平台Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hguandl committed Jun 21, 2023
1 parent d5f36eb commit 30dce90
Showing 1 changed file with 77 additions and 19 deletions.
96 changes: 77 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,75 @@
name: Release Bundled Package
on:
push:
tags:
- v*
name: Bundle with Pyinstaller
on: push

jobs:
build:
runs-on: windows-latest
permissions:
contents: write

frontend:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- id: set_tag
run: |
if ${{ startsWith(github.ref, 'refs/tags/v') }}; then
echo "tag=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "tag=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Build Frontend
env:
NODE_OPTIONS: "--openssl-legacy-provider"
working-directory: frontend
run: |
npm install
npm run build
- name: Export Backend
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: frontend
path: frontend/dist

backend:
needs: frontend
strategy:
matrix:
os: [macos, ubuntu, windows]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Download Frontend
uses: actions/download-artifact@v3
with:
name: frontend
path: frontend/dist

- name: Install Dependencies
run: pip3 install -r requirements.txt

- name: Bundle blivechat (Unix)
if: matrix.os != 'windows'
run: |
pip3 install pyinstaller
pyinstaller --noconfirm \
--add-data="data:data" \
--add-data="log:log" \
--add-data="frontend/dist:frontend/dist" \
--name blivechat \
main.py
- name: Bundle blivechat (Windows)
if: matrix.os == 'windows'
run: |
pip install -r requirements.txt
pip install pyinstaller
pip3 install pyinstaller
pyinstaller --noconfirm `
--add-data="data;data" `
--add-data="log;log" `
Expand All @@ -36,10 +79,25 @@ jobs:
- name: Package Bundle
working-directory: dist
run: 7z a -tzip blivechat.zip blivechat
run: 7z a -tzip blivechat-${{ needs.frontend.outputs.tag }}-${{ matrix.os }}-x64.zip blivechat

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: blivechat-${{ matrix.os }}-x64
path: dist/blivechat-*.zip

release:
needs: backend
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Artifact
uses: actions/download-artifact@v3

- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/blivechat.zip
files: ./**/blivechat-*.zip

0 comments on commit 30dce90

Please sign in to comment.