diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000000..31f1c6d884 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -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 diff --git a/.github/workflows/beta-pack.yml b/.github/workflows/beta-pack.yml index e7b8ee3be1..33917f1767 100644 --- a/.github/workflows/beta-pack.yml +++ b/.github/workflows/beta-pack.yml @@ -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 @@ -141,6 +127,10 @@ 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 @@ -148,26 +138,8 @@ jobs: - 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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fb506cd8e..18debbfbaa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 @@ -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 @@ -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 }} @@ -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 @@ -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