Skip to content

Commit

Permalink
chore(workflow): add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
GuMengYu committed Jun 9, 2023
1 parent ff014d3 commit 98f2c6d
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 38 deletions.
93 changes: 63 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,86 @@
name: build
name: dev build job

on:
push:
branches:
- dev
tags:
- v*
workflow_dispatch:

jobs:
release:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, windows-latest]
mac_build:
runs-on: macos-latest
timeout-minutes: 30

steps:
- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@master

- name: Setup Node.js environment
uses: actions/setup-node@v3.4.1
uses: actions/setup-node@master
with:
node-version: '16.x'
cache: 'npm'

- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1.6.0
# env:
# VUE_APP_API_DEV_ELECTRON: http://localhost:12138
# VUE_APP_API_PRODUCT_ELECTRON: http://127.0.0.1:12138
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
build_script_name: 'electron:prebuild'
# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}

- uses: actions/upload-artifact@v3

- run: npm ci
- run: npm run electron:build:mac
shell: bash

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: music-you-macos
path: release/*/music-you-mac-*-universal.dmg
if-no-files-found: ignore

windows_build:
runs-on: windows-latest
timeout-minutes: 30

steps:
- name: Check out Git repository
uses: actions/checkout@master

- uses: actions/upload-artifact@v3
- name: Setup Node.js environment
uses: actions/setup-node@master
with:
node-version: '16.x'
cache: 'npm'

- run: npm ci
- run: npm run electron:build:win
shell: bash

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: music-you-windows
path: release/*/*Setup*.exe
if-no-files-found: ignore
if-no-files-found: ignore

linux_build:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Check out Git repository
uses: actions/checkout@master

- name: Setup Node.js environment
uses: actions/setup-node@master
with:
node-version: '16.x'
cache: 'npm'

- run: npm ci
- run: npm run electron:build:linux
shell: bash

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: music-you-linux
path: |
music-you-*.AppImage
music-you-*.tar.gz
if-no-files-found: ignore


104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: release job

on:
push:
branches:
- master
tags:
- v*
workflow_dispatch:

jobs:
mac_release:
runs-on: macos-latest
timeout-minutes: 30

steps:
- name: Check out Git repository
uses: actions/checkout@master

- name: Setup Node.js environment
uses: actions/setup-node@master
with:
node-version: '16.x'
cache: 'npm'

- run: npm ci
- run: npm run electron:build:mac
shell: bash

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
path: release/*/*.*
if-no-files-found: ignore
- name: Create a release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: release/*/*.*

windows_release:
runs-on: windows-latest
timeout-minutes: 30

steps:
- name: Check out Git repository
uses: actions/checkout@master

- name: Setup Node.js environment
uses: actions/setup-node@master
with:
node-version: '16.x'
cache: 'npm'

- run: npm ci
- run: npm run electron:build:win
shell: bash

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
path: release/*/*.*
if-no-files-found: ignore

- name: Create a release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: release/*/*.*

linux_release:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Check out Git repository
uses: actions/checkout@master

- name: Setup Node.js environment
uses: actions/setup-node@master
with:
node-version: '16.x'
cache: 'npm'

- run: npm ci
- run: npm run electron:build:linux
shell: bash

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
path: release/*/*.*
if-no-files-found: ignore

- name: Create a release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: release/*/*.*


8 changes: 3 additions & 5 deletions electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@
"linux": {
"target": [
"AppImage",
"snap",
"deb",
"rpm",
"freebsd",
"pacman",
"tar.xz",
"tar.gz",
"snap"
],
"category": "Audio"
"category": "Audio;Music"
},
"nsis": {
"oneClick": false,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"build": "vite build",
"electron:dev": "vite --mode electron",
"electron:build": "npm run electron:prebuild && electron-builder",
"electron:build:mac": "npm run electron:prebuild && electron-builder --mac",
"electron:build:win": "npm run electron:prebuild && electron-builder --win",
"electron:build:linux": "npm run electron:prebuild && electron-builder --linux",
"electron:build:mac": "npm run electron:prebuild && electron-builder --mac --publish onTag",
"electron:build:win": "npm run electron:prebuild && electron-builder --win --publish onTag",
"electron:build:linux": "npm run electron:prebuild && electron-builder --linux --publish onTag",
"electron:prebuild": "vite build --mode electron",
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:ts",
"lint:eslint": "eslint \"src/**/*.{js,jsx,ts,tsx,vue}\" --fix",
Expand Down

0 comments on commit 98f2c6d

Please sign in to comment.