From 4052fd164c3699d7a2a3e6b50b5718eaf3848c12 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Thu, 20 Jul 2023 19:04:35 +0800 Subject: [PATCH] :bug: Restore rust cache --- .github/workflows/pake-cli.yaml | 150 +++++++++++-------- .github/workflows/pake_build_with_cache.yaml | 133 +++++++++------- 2 files changed, 162 insertions(+), 121 deletions(-) diff --git a/.github/workflows/pake-cli.yaml b/.github/workflows/pake-cli.yaml index 93b4249..ad00b9b 100644 --- a/.github/workflows/pake-cli.yaml +++ b/.github/workflows/pake-cli.yaml @@ -8,9 +8,9 @@ on: default: "macos-latest" type: choice options: - - "windows-latest" - - "macos-latest" - - "ubuntu-20.04" + - "windows-latest" + - "macos-latest" + - "ubuntu-20.04" url: description: "[URL]" required: true @@ -44,9 +44,9 @@ on: default: "deb" type: choice options: - - "deb" - - "appimage" - - "all" + - "deb" + - "appimage" + - "all" jobs: @@ -57,71 +57,91 @@ jobs: fail-fast: false steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - - name: install node - uses: actions/setup-node@v3 - with: - node-version: 18 + - name: install node + uses: actions/setup-node@v3 + with: + node-version: 18 - - name: Install Rust for ubuntu-20.04 - if: inputs.platform == 'ubuntu-20.04' - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - target: x86_64-unknown-linux-musl + - name: Install Rust for ubuntu-20.04 + if: inputs.platform == 'ubuntu-20.04' + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + target: x86_64-unknown-linux-musl - - name: Install Rust for windows-latest - if: inputs.platform == 'windows-latest' - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable-x86_64-msvc - target: x86_64-pc-windows-msvc + - name: Install Rust for windows-latest + if: inputs.platform == 'windows-latest' + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable-x86_64-msvc + target: x86_64-pc-windows-msvc - - name: Install Rust for macos-latest - if: inputs.platform == 'macos-latest' - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - target: x86_64-apple-darwin + - name: Install Rust for macos-latest + if: inputs.platform == 'macos-latest' + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + target: x86_64-apple-darwin - - name: install dependencies (ubuntu only) - if: inputs.platform == 'ubuntu-20.04' - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra - version: 1.1 + - name: install dependencies (ubuntu only) + if: inputs.platform == 'ubuntu-20.04' + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra + version: 1.1 - - name: install pake-cli local - shell: bash - run: | - echo "install pake on local" - npm install pake-cli + - name: install pake-cli local + shell: bash + run: | + echo "install pake on local" + npm install pake-cli - - name: rust cache - uses: Swatinem/rust-cache@v2 + - name: rust cache restore + uses: actions/cache/restore@v3 + id: cache_store + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + node_modules/pake-cli/src-tauri/target/ + key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }} - - name: build with pake-cli - shell: pwsh - run: | - pwsh ./script/build_with_pake_cli.ps1 - env: - URL: ${{ inputs.url }} - NAME: ${{ inputs.name }} - ICON: ${{ inputs.icon }} - HEIGHT: ${{ inputs.height }} - WIDTH: ${{ inputs.width }} - TRANSPARENT: ${{ inputs.transparent }} - FULLSCREEN: ${{ inputs.fullscreen }} - RESIZE: ${{ inputs.resize }} - MULTI_ARCH: ${{ inputs.multi_arch }} - TARGETS: ${{ inputs.targets }} + - name: build with pake-cli + shell: pwsh + run: | + pwsh ./script/build_with_pake_cli.ps1 + env: + URL: ${{ inputs.url }} + NAME: ${{ inputs.name }} + ICON: ${{ inputs.icon }} + HEIGHT: ${{ inputs.height }} + WIDTH: ${{ inputs.width }} + TRANSPARENT: ${{ inputs.transparent }} + FULLSCREEN: ${{ inputs.fullscreen }} + RESIZE: ${{ inputs.resize }} + MULTI_ARCH: ${{ inputs.multi_arch }} + TARGETS: ${{ inputs.targets }} - - name: Upload archive - uses: actions/upload-artifact@v3 - with: - name: output-${{ inputs.platform }}.zip - path: node_modules/pake-cli/output/* - retention-days: 3 - \ No newline at end of file + - name: Upload archive + uses: actions/upload-artifact@v3 + with: + name: output-${{ inputs.platform }}.zip + path: node_modules/pake-cli/output/* + retention-days: 3 + + - name: rust cache store + uses: actions/cache/save@v3 + if: steps.cache_store.outputs.cache-hit != 'true' + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + node_modules/pake-cli/src-tauri/target/ + key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }} diff --git a/.github/workflows/pake_build_with_cache.yaml b/.github/workflows/pake_build_with_cache.yaml index aecfcee..cc6ddff 100644 --- a/.github/workflows/pake_build_with_cache.yaml +++ b/.github/workflows/pake_build_with_cache.yaml @@ -21,70 +21,91 @@ jobs: matrix: build: [linux, windows, macos] include: - - build: linux - os: ubuntu-20.04 - rust: stable - target: x86_64-unknown-linux-musl - # archive-name: target-linux.tar.gz - - build: windows - os: windows-latest - rust: stable-x86_64-msvc - target: x86_64-pc-windows-msvc - # archive-name: target-windows.tar.gz - - build: macos - os: macos-latest - rust: stable - target: x86_64-apple-darwin - # archive-name: target-macos.tar.gz + - build: linux + os: ubuntu-20.04 + rust: stable + target: x86_64-unknown-linux-musl + # archive-name: target-linux.tar.gz + - build: windows + os: windows-latest + rust: stable-x86_64-msvc + target: x86_64-pc-windows-msvc + # archive-name: target-windows.tar.gz + - build: macos + os: macos-latest + rust: stable + target: x86_64-apple-darwin + # archive-name: target-macos.tar.gz fail-fast: false steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - - name: install node - uses: actions/setup-node@v3 - with: - node-version: 18 + - name: install node + uses: actions/setup-node@v3 + with: + node-version: 18 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} - - name: install dependencies (ubuntu only) - if: matrix.os == 'ubuntu-20.04' - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra - version: 1.1 + - name: install dependencies (ubuntu only) + if: matrix.os == 'ubuntu-20.04' + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra + version: 1.1 - - name: rust cache - uses: Swatinem/rust-cache@v2 + - name: rust cache restore + uses: actions/cache/restore@v3 + id: cache_store + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + src-tauri/target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: build for Ubuntu - if: matrix.os == 'ubuntu-20.04' - run: npm run build:all-unix + - name: build for Ubuntu + if: matrix.os == 'ubuntu-20.04' + run: npm run build:all-unix - - name: build for MacOS - if: matrix.os == 'macos-latest' - run: | - rustup target add aarch64-apple-darwin - npm run build:all-unix + - name: build for MacOS + if: matrix.os == 'macos-latest' + run: | + rustup target add aarch64-apple-darwin + npm run build:all-unix - - name: build for windows - if: matrix.os == 'windows-latest' - shell: pwsh - run: | - npm run build:all-windows + - name: build for windows + if: matrix.os == 'windows-latest' + shell: pwsh + run: | + npm run build:all-windows - - name: Upload files - # arg info: https://github.com/ncipollo/release-action#release-action - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - prerelease: ${{ inputs.is_pre_release }} - artifacts: "output/*/*.*" - tag: ${{ inputs.version }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + - name: Upload files + # arg info: https://github.com/ncipollo/release-action#release-action + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + prerelease: ${{ inputs.is_pre_release }} + artifacts: "output/*/*.*" + tag: ${{ inputs.version }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: rust cache store + uses: actions/cache/save@v3 + if: steps.cache_store.outputs.cache-hit != 'true' + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + src-tauri/target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}