samuelmeuli / action-electron-builder

:electron: GitHub Action for building and releasing Electron apps
MIT License
670 stars 206 forks source link

Cache deps #9

Open HaNdTriX opened 4 years ago

HaNdTriX commented 4 years ago

Thanks a lot for sharing your code!


Issue

It would be awesome if we cache deps. This will speed up the process dramatically:

Cacheable Entries

Example

name: Release

on: [push]

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

    strategy:
      matrix:
        os: [macos-latest, windows-latest]
        # Lets use the preinstalled node version (much faster)
        node-version: [12.x]

    env:
      ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron
      ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder

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

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Get yarn cache
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"

      - name: Cache Node.js modules
        uses: actions/cache@v1
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
          restore-keys: |
            ${{ runner.os }}-yarn-

      - name: Cache Electron
        uses: actions/cache@v1
        with:
          path: ${{ github.workspace }}/.cache/electron
          key: ${{ runner.os }}-electron-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
          restore-keys: |
            ${{ runner.os }}-electron-cache-

      - name: Cache Electron-Builder
        uses: actions/cache@v1
        with:
          path: ${{ github.workspace }}/.cache/electron-builder
          key: ${{ runner.os }}-electron-builder-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
          restore-keys: |
            ${{ runner.os }}-electron-builder-cache-

      - name: Install dependencies
        run: yarn install

      - name: Build Electron app
        uses: samuelmeuli/action-electron-builder@v1
        with:
          github_token: ${{ secrets.github_token }}
samuelmeuli commented 4 years ago

If I understand this correctly, your approach is the correct way of implementing caching – it seems like it needs to be done on the workflow level, not on the action level.

Maybe adding an example to the README would help?

samuelmeuli commented 4 years ago

@HaNdTriX Would you be interested in sharing your setup using a PR? :)

b-zurg commented 4 years ago

@HaNdTriX @samuelmeuli , is the example above a working example of caching dependencies?

bung87 commented 3 years ago

the example provide install command, while action-electron-builder also automatic run install , from my experience I need custom install command , I use lock file which install from local registry , while on GitHub CI , I need install from original registry.