ci(release): 优化发布工作流

This commit is contained in:
hello8693 2024-08-28 19:47:28 +08:00
parent 2e30841d7e
commit f81bf2d592

View File

@ -1,5 +1,4 @@
# .github/workflows/publish.yaml
name: Build and Package Electron App on Release
name: Release Build and Package
on:
release:
@ -8,32 +7,23 @@ on:
jobs:
build:
runs-on: ${{ matrix.os }}
if: github.event.release.prerelease == false || matrix.os == 'windows-latest'
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
node-version: [20.x]
include:
- os: windows-latest
build_all: false
- os: macos-latest
build_all: true
- os: ubuntu-latest
build_all: true
steps:
- name: Checkout
if: matrix.os == 'windows-latest' || github.event.release.prerelease == false
uses: actions/checkout@v4.1.7
- name: Set up Node.js
if: matrix.os == 'windows-latest' || github.event.release.prerelease == false
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
if: matrix.os == 'windows-latest' || github.event.release.prerelease == false
run: yarn install
- name: Build and package for Windows
@ -41,40 +31,30 @@ jobs:
run: yarn build:win
- name: Build and package for macOS
if: matrix.os == 'macos-latest' && github.event.release.prerelease == false
if: matrix.os == 'macos-latest'
run: yarn build:mac
- name: Build and package for Linux
if: matrix.os == 'ubuntu-latest' && github.event.release.prerelease == false
if: matrix.os == 'ubuntu-latest'
run: yarn build:linux
- name: Get version from package.json
id: get_version
run: echo "::set-output name=version::$(node -p \"require('./package.json').version\")"
- name: Upload artifact for Windows
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
uses: actions/upload-artifact@v4
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/dsz-exam-showboard-${{ steps.get_version.outputs.version }}-setup.exe
asset_name: ExamShowboard-Windows-amd64-${{ steps.get_version.outputs.version }}-setup.exe
asset_content_type: application/octet-stream
name: ExamShowboard-Windows
path: dist/*.exe
- name: Upload artifact for macOS
if: matrix.os == 'macos-latest' && github.event.release.prerelease == false
uses: actions/upload-release-asset@v1
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/dsz-exam-showboard-${{ steps.get_version.outputs.version }}.dmg
asset_name: ExamShowboard-macOS-arm64-${{ steps.get_version.outputs.version }}.dmg
asset_content_type: application/octet-stream
name: ExamShowboard-macOS
path: dist/*.dmg
- name: Upload artifact for Linux
if: matrix.os == 'ubuntu-latest' && github.event.release.prerelease == false
uses: actions/upload-release-asset@v1
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/dsz-exam-showboard-${{ steps.get_version.outputs.version }}.AppImage
asset_name: ExamShowboard-Linux-amd64-${{ steps.get_version.outputs.version }}-setup.AppImage
asset_content_type: application/octet-stream
name: ExamShowboard-Linux
path: dist/*.AppImage