Skip to content

Commit

Permalink
优化GitHub actions工作流
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Dec 11, 2023
1 parent 98b4abf commit 1131715
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 125 deletions.
25 changes: 25 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Setup
description: Setup Node Env

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
with:
path: |
${{ env.NPM_CACHE }}
${{ env.ELECTRON_CACHE }}
${{ env.ELECTRON_BUILDERCACHE }}
key: ${{ runner.os }}-node-modules-cache-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-cache-
- name: Install dependencies
run: npm ci
81 changes: 18 additions & 63 deletions .github/workflows/beta-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,17 @@ jobs:
Windows:
name: Windows
runs-on: windows-latest
env:
NPM_CACHE: '%APPDATA%\npm-cache'
ELECTRON_CACHE: '%LOCALAPPDATA%\electron\Cache'
ELECTRON_BUILDERCACHE: '%LOCALAPPDATA%\electron-builder\Cache'
# needs: CheckCode
steps:
- name: Check out git repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Cache file
uses: actions/cache@v3
with:
path: |
node_modules
%APPDATA%\npm-cache
%LOCALAPPDATA%\electron\Cache
%LOCALAPPDATA%\electron-builder\Cache
key: ${{ runner.os }}-build-caches-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Dependencies
run: |
npm ci
- name: Setup Node Env
uses: ./.github/actions/setup

- name: Build src code
run: npm run build
Expand Down Expand Up @@ -141,33 +127,19 @@ jobs:
name: Mac
runs-on: macos-latest
# needs: CheckCode
env:
NPM_CACHE: $HOME/.npm
ELECTRON_CACHE: $HOME/.cache/electron
ELECTRON_BUILDERCACHE: $HOME/.cache/electron-builder
steps:
- name: Check out git repository
uses: actions/checkout@v4

- name: Install python setuptools
run: python3 -m pip install setuptools

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Cache file
uses: actions/cache@v3
with:
path: |
node_modules
$HOME/.cache/electron
$HOME/.cache/electron-builder
$HOME/.npm/_prebuilds
key: ${{ runner.os }}-build-caches-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Dependencies
run: |
npm ci
- name: Setup Node Env
uses: ./.github/actions/setup

- name: Build src code
run: npm run build
Expand All @@ -176,9 +148,6 @@ jobs:
run: |
npm run pack:mac:dmg
npm run pack:mac:dmg:arm64
env:
ELECTRON_CACHE: $HOME/.cache/electron
ELECTRON_BUILDERCACHE: $HOME/.cache/electron-builder
- name: Upload Artifact dmg
uses: actions/upload-artifact@v3
Expand All @@ -201,6 +170,10 @@ jobs:
Linux:
name: Linux
runs-on: ubuntu-latest
env:
NPM_CACHE: $HOME/.npm
ELECTRON_CACHE: $HOME/.cache/electron
ELECTRON_BUILDERCACHE: $HOME/.cache/electron-builder
# needs: CheckCode
steps:
- name: Install package
Expand All @@ -209,26 +182,8 @@ jobs:
- name: Check out git repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Cache file
uses: actions/cache@v3
with:
path: |
node_modules
$HOME/.cache/electron
$HOME/.cache/electron-builder
$HOME/.npm/_prebuilds
key: ${{ runner.os }}-build-caches-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Dependencies
run: |
npm ci
- name: Setup Node Env
uses: ./.github/actions/setup

- name: Build src code
run: npm run build
Expand Down
80 changes: 18 additions & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,17 @@ jobs:
Windows:
name: Windows
runs-on: windows-latest
env:
NPM_CACHE: '%APPDATA%\npm-cache'
ELECTRON_CACHE: '%LOCALAPPDATA%\electron\Cache'
ELECTRON_BUILDERCACHE: '%LOCALAPPDATA%\electron-builder\Cache'
# needs: CheckCode
steps:
- name: Check out git repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Cache file
uses: actions/cache@v3
with:
path: |
node_modules
%APPDATA%\npm-cache
%LOCALAPPDATA%\electron\Cache
%LOCALAPPDATA%\electron-builder\Cache
key: ${{ runner.os }}-build-caches-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Dependencies
run: |
npm ci
- name: Setup Node Env
uses: ./.github/actions/setup

- name: Build src code
run: npm run build
Expand Down Expand Up @@ -101,6 +87,10 @@ jobs:
Mac:
name: Mac
runs-on: macos-latest
env:
NPM_CACHE: $HOME/.npm
ELECTRON_CACHE: $HOME/.cache/electron
ELECTRON_BUILDERCACHE: $HOME/.cache/electron-builder
# needs: CheckCode
steps:
- name: Check out git repository
Expand All @@ -109,26 +99,8 @@ jobs:
- name: Install python3 setuptools
run: python3 -m pip install setuptools

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Cache file
uses: actions/cache@v3
with:
path: |
node_modules
$HOME/.cache/electron
$HOME/.cache/electron-builder
$HOME/.npm/_prebuilds
key: ${{ runner.os }}-build-caches-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Dependencies
run: |
npm ci
- name: Setup Node Env
uses: ./.github/actions/setup

- name: Build src code
run: npm run build
Expand All @@ -138,8 +110,6 @@ jobs:
npm run publish:mac:dmg
npm run publish:mac:dmg:arm64
env:
ELECTRON_CACHE: $HOME/.cache/electron
ELECTRON_BUILDERCACHE: $HOME/.cache/electron-builder
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BT_TOKEN: ${{ secrets.BT_TOKEN }}

Expand All @@ -151,6 +121,10 @@ jobs:
Linux:
name: Linux
runs-on: ubuntu-latest
env:
NPM_CACHE: $HOME/.npm
ELECTRON_CACHE: $HOME/.cache/electron
ELECTRON_BUILDERCACHE: $HOME/.cache/electron-builder
# needs: CheckCode
steps:
- name: Install package
Expand All @@ -159,26 +133,8 @@ jobs:
- name: Check out git repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Cache file
uses: actions/cache@v3
with:
path: |
node_modules
$HOME/.cache/electron
$HOME/.cache/electron-builder
$HOME/.npm/_prebuilds
key: ${{ runner.os }}-build-caches-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Dependencies
run: |
npm ci
- name: Setup Node Env
uses: ./.github/actions/setup

- name: Build src code
run: npm run build
Expand Down

0 comments on commit 1131715

Please sign in to comment.