Skip to content

优化: 部分轮询改为 SSE #11

优化: 部分轮询改为 SSE

优化: 部分轮询改为 SSE #11

Workflow file for this run

name: Build and Release Python Application
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.label }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Windows x64
- os: windows-latest
label: windows-x64
asset_suffix: windows-x64
binary_name: mluascript.exe
# Linux x64
- os: ubuntu-latest
label: linux-x64
asset_suffix: linux-x64
binary_name: mluascript
# Linux arm64
- os: ubuntu-24.04-arm
label: linux-arm64
asset_suffix: linux-arm64
binary_name: mluascript
# macOS arm64
- os: macos-14
label: macos-arm64
asset_suffix: macos-arm64
binary_name: mluascript
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: src/mluascript_web/package-lock.json
- name: Install PDM
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install pdm
- name: Install Python dependencies
shell: pwsh
run: |
pdm sync --prod
- name: Install frontend dependencies
shell: pwsh
working-directory: src/mluascript_web
run: |
npm ci
- name: Build executable
shell: pwsh
run: |
pdm run pyinstaller mluascript.spec
- name: Package artifact
shell: pwsh
env:
TAG_NAME: ${{ github.ref_name }}
ASSET_SUFFIX: ${{ matrix.asset_suffix }}
BINARY_NAME: ${{ matrix.binary_name }}
run: |
$packageName = "mluascript-$env:TAG_NAME-$env:ASSET_SUFFIX"
$stageDir = Join-Path $PWD "release"
$packageDir = Join-Path $stageDir $packageName
$binaryPath = Join-Path (Join-Path $PWD "dist") $env:BINARY_NAME
New-Item -ItemType Directory -Path $packageDir -Force | Out-Null
Copy-Item -LiteralPath $binaryPath -Destination $packageDir
if (Test-Path -LiteralPath (Join-Path $PWD "README.md")) {
Copy-Item -LiteralPath (Join-Path $PWD "README.md") -Destination $packageDir
}
if (Test-Path -LiteralPath (Join-Path $PWD "LICENSE")) {
Copy-Item -LiteralPath (Join-Path $PWD "LICENSE") -Destination $packageDir
}
Compress-Archive -Path "$packageDir/*" -DestinationPath (Join-Path $stageDir "$packageName.zip") -Force
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_suffix }}
path: release/*.zip
if-no-files-found: error
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
generate_release_notes: true
files: release-assets/*.zip