Skip to content

Commit

Permalink
chore: Use electron cache & update action version (#695)
Browse files Browse the repository at this point in the history
* CI: fix electron cache
  • Loading branch information
BuWH committed Jul 19, 2024
1 parent 10a6405 commit 411dc5d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 51 deletions.
81 changes: 40 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,39 @@ on:
- 'pnpm-lock.yaml'
- '.github/**'

# env:
# ELECTRON_CACHE: ~/.cache/electron
# ELECTRON_BUILDER_CACHE: ~/.cache/electron-builder

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
with:
version: 9.2.0
version: 9.3.0
- name: Fix node-gyp and Python
if: ${{ runner.os == 'macOS' }}
if: ${{ runner.os == 'macOS' }}
run: python3 -m pip install --break-system-packages --user packaging setuptools
- name: Use Node.js 20
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
# - name: Restore cached Electron
# id: cache-electron
# uses: actions/cache/restore@v3
# with:
# path: |
# ~/.cache/electron
# ~/.cache/electron-builder
# key: ${{ runner.os }}-electron
- name: Install
run: pnpm install
- name: Restore cached Electron
id: cache-electron
uses: actions/cache/restore@v4
with:
path: |
~/.cache/electron
~/.cache/electron-builder
key: ${{ runner.os }}-electron-build-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-electron-build-
- name: Build
run: |
pnpm run --prefix xmcl-keystone-ui build
Expand All @@ -57,15 +55,8 @@ jobs:
NODE_OPTIONS: --max-old-space-size=32768
NODE_ENV: production
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_TOKEN }}
# - name: Save cached Electron
# uses: actions/cache/save@v3
# with:
# path: |
# ~/.cache/electron
# ~/.cache/electron-builder
# key: ${{ runner.os }}-electron
- name: Upload Source Maps
if: ${{ runner.os == 'Windows' }}
if: ${{ runner.os == 'Windows' }}
uses: actions/upload-artifact@v4
with:
name: sourcemap
Expand All @@ -78,57 +69,65 @@ jobs:
path: |
xmcl-electron-app/build/output/
- name: Upload Windows Zip Build
if: ${{ runner.os == 'Windows' }}
if: ${{ runner.os == 'Windows' }}
uses: actions/upload-artifact@v4
with:
name: win-b${{ github.run_number }}
path: |
xmcl-electron-app/build/output/win-unpacked/
- name: Upload Linux x64 Zip Build
if: ${{ runner.os == 'Linux' }}
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v4
with:
name: linux-b${{ github.run_number }}-x64
path: |
xmcl-electron-app/build/output/linux-unpacked/
- name: Upload Linux arm64 Zip Build
if: ${{ runner.os == 'Linux' }}
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v4
with:
name: linux-b${{ github.run_number }}-arm64
path: |
xmcl-electron-app/build/output/linux-arm64-unpacked/
- name: Upload Mac x64 Zip Build
if: ${{ runner.os == 'macOS' }}
if: ${{ runner.os == 'macOS' }}
uses: actions/upload-artifact@v4
with:
name: mac-b${{ github.run_number }}-x64
path: |
xmcl-electron-app/build/output/mac/
- name: Upload Mac arm64 Zip Build
if: ${{ runner.os == 'macOS' }}
if: ${{ runner.os == 'macOS' }}
uses: actions/upload-artifact@v4
with:
name: mac-b${{ github.run_number }}-arm64
path: |
xmcl-electron-app/build/output/mac-arm64/
- name: Save cached Electron
if: steps.cache-electron.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.cache/electron
~/.cache/electron-builder
key: ${{ runner.os }}-electron-build-${{ hashFiles('**/pnpm-lock.yaml') }}

prepare-release:
runs-on: ubuntu-latest
needs:
needs:
- build
if: ${{ !startsWith(github.event.head_commit.message, 'chore(release)') }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
with:
version: 9.2.0
version: 9.3.0
- name: Use Node.js 20
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install
Expand Down Expand Up @@ -192,15 +191,15 @@ jobs:
needs:
- build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
with:
version: 9.2.0
version: 9.3.0
- name: Use Node.js 20
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
Expand Down Expand Up @@ -252,7 +251,7 @@ jobs:
body: ${{ steps.release_note.outputs.body }}
asset_dir_path: ./build
- name: Checkout Website
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: Voxelum/xmcl-page
path: xmcl-page
Expand All @@ -273,4 +272,4 @@ jobs:
body: Update ${{ steps.prepare_release.outputs.version }} release note
reviewers: ci010
assignees: ci010
branch: release-note-${{ steps.prepare_release.outputs.version }}
branch: release-note-${{ steps.prepare_release.outputs.version }}
8 changes: 4 additions & 4 deletions .github/workflows/deploy-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
with:
version: 9.2.0
version: 9.3.0
- name: Use Node.js 16
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
with:
version: 9.2.0
version: 9.3.0
- name: Use Node.js 20
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.44.15",
"private": true,
"license": "MIT",
"packageManager": "[email protected]+sha512.ee7b93e0c2bd11409c6424f92b866f31d3ea1bef5fbe47d3c7500cdc3c9668833d2e55681ad66df5b640c61fa9dc25d546efa54d76d7f8bf54b13614ac293631",
"packageManager": "[email protected]",
"engines": {
"node": ">=16"
},
Expand All @@ -18,4 +18,4 @@
"lint": "pnpm run --prefix=xmcl-keystone-ui lint && pnpm run --prefix=xmcl-runtime lint && pnpm run --prefix=xmcl-runtime-api lint && pnpm run --prefix=xmcl-electron-app lint",
"lint:fix": "pnpm run --prefix=xmcl-runtime-api lint:fix && pnpm run --prefix=xmcl-runtime lint:fix && pnpm run --prefix=xmcl-electron-app lint:fix && pnpm run --prefix=xmcl-keystone-ui lint:fix"
}
}
}

0 comments on commit 411dc5d

Please sign in to comment.