From 0ff3d9ecdd31f51fe4aa9156b4dd4c3fbdfcc03a Mon Sep 17 00:00:00 2001 From: Changhua Date: Thu, 24 Apr 2025 11:42:33 +0800 Subject: [PATCH 1/5] chore(ci): test ci --- test_ci | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test_ci diff --git a/test_ci b/test_ci new file mode 100644 index 0000000..e69de29 From 3794a3d78c3f52fd9d0c41eb59caaded8251048b Mon Sep 17 00:00:00 2001 From: Changhua Date: Thu, 24 Apr 2025 11:58:18 +0800 Subject: [PATCH 2/5] chore(ci): fix script --- .github/workflows/build-ci.yml | 62 ++++++++++++++++++---------------- .github/workflows/release.yml | 21 +++++++----- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index 7717a58..5223b1b 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -5,14 +5,13 @@ on: jobs: windows: - name: Build Windows Artifact + name: Build Windows runs-on: windows-latest - steps: - name: Check out code uses: actions/checkout@v4 - - name: Set up Node.js + - name: Set up node uses: actions/setup-node@v4 with: node-version: "18" @@ -24,76 +23,81 @@ jobs: toolchain: stable override: true - - name: Compute Cargo cache key + # Ignore lines containing 'version = "x.x.x"' and hash the rest of Cargo.lock + - name: Generate custom cache key id: cargo-hash run: | - grep -v '^version = ' src-tauri/Cargo.toml \ - | shasum -a 256 \ - | awk '{ print $1 }' > cargo_hash.txt - echo "CARGO_CACHE_KEY=$(> $GITHUB_ENV + grep -v '^version = ' src-tauri/Cargo.toml | shasum -a 256 | awk '{ print $1 }' > cargo_hash.txt + echo "CARGO_CACHE_KEY=$(cat cargo_hash.txt)" >> $GITHUB_ENV + echo "::set-output name=CARGO_CACHE_KEY::$(cat cargo_hash.txt)" - name: Cache Cargo registry uses: actions/cache@v4 with: path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ env.CARGO_CACHE_KEY }} - restore-keys: ${{ runner.os }}-cargo-registry- + key: ${{ runner.os }}-cargo-registry-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }} + restore-keys: | + ${{ runner.os }}-cargo-registry- - name: Cache Cargo git index uses: actions/cache@v4 with: path: ~/.cargo/git - key: ${{ runner.os }}-cargo-git-${{ env.CARGO_CACHE_KEY }} - restore-keys: ${{ runner.os }}-cargo-git- + key: ${{ runner.os }}-cargo-git-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }} + restore-keys: | + ${{ runner.os }}-cargo-git- - - name: Cache Cargo target dir + - name: Cache Cargo target directory uses: actions/cache@v4 with: path: src-tauri/target - key: ${{ runner.os }}-cargo-target-${{ env.CARGO_CACHE_KEY }}-$(rustc --version) - restore-keys: ${{ runner.os }}-cargo-target- + key: ${{ runner.os }}-cargo-target-${{ matrix.target }}-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }}-$(rustc --version) + restore-keys: | + ${{ runner.os }}-cargo-target- - - name: Cache Tauri CLI + - name: Cache Tauri CLI (cross-platform) id: tauri-cli-cache uses: actions/cache@v4 with: - path: ~/.cargo/bin/cargo-tauri* - key: ${{ runner.os }}-tauri-cli-${{ env.CARGO_CACHE_KEY }} - restore-keys: ${{ runner.os }}-tauri-cli- + path: | + ~/.cargo/bin/cargo-tauri + ~/.cargo/bin/cargo-tauri.exe + key: ${{ runner.os }}-tauri-cli-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }} + restore-keys: | + ${{ runner.os }}-tauri-cli- - name: Cache node_modules uses: actions/cache@v4 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }} - restore-keys: ${{ runner.os }}-node-modules- + restore-keys: | + ${{ runner.os }}-node-modules- - - name: Install dependencies + - name: Install Node Module run: | npm i pnpm -g + echo "C:/Users/runneradmin/AppData/Roaming/npm" >> $GITHUB_PATH pnpm i - shell: bash - name: Install Protoc uses: arduino/setup-protoc@v3 with: version: "22.2" - - name: Install Tauri CLI if needed + - name: Install Tauri CLI if not cached run: cargo install tauri-cli --version ^1.0.0 if: steps.tauri-cli-cache.outputs.cache-hit != 'true' - - name: Build Tauri bundle + - name: Build run: cargo tauri build working-directory: ./src-tauri - - name: Create output dir - run: mkdir -p output - shell: bash + - name: Create output directory + run: mkdir output - - name: Copy executables + - name: Copy files to output run: cp src-tauri/target/release/bundle/nsis/*.exe output/ - shell: bash - name: Upload artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d2049f..d586f4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,33 +2,36 @@ name: Release on: push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" + tags: ["v[0-9]+.[0-9]+.[0-9]+*"] workflow_dispatch: jobs: build: uses: ./.github/workflows/build-ci.yml - publish: + release: name: Publish Release - needs: build runs-on: ubuntu-latest + needs: build steps: - name: Check out code uses: actions/checkout@v4 - - name: Determine version info + - name: Determine Release Info + env: + GITHUB_REF: ${{ github.ref }} run: | VERSION=${GITHUB_REF##*/} MAJOR=${VERSION%%.*} - MINOR=${VERSION#*.}; MINOR=${MINOR%%.*} + MINOR=${VERSION%.*} + MINOR=${MINOR#*.} PATCH=${VERSION##*.} echo "VERSION=$VERSION" >> $GITHUB_ENV echo "WINDOWS_DIR=WeChatFerry_${MAJOR}.${MINOR}.${PATCH}_windows_x64" >> $GITHUB_ENV + echo "INNER_DIR=WeChatFerry-$VERSION" >> $GITHUB_ENV - - name: Create directory + - name: Create Windows Directory run: mkdir -p ${{ env.WINDOWS_DIR }} - name: Download Windows artifact @@ -37,10 +40,10 @@ jobs: name: windows path: ${{ env.WINDOWS_DIR }} - - name: Zip Windows bundle + - name: Create Windows Archive run: zip -r ${{ env.WINDOWS_DIR }}.zip ${{ env.WINDOWS_DIR }} - - name: Publish to GitHub Releases + - name: Upload Windows binary uses: softprops/action-gh-release@v1 with: files: ${{ env.WINDOWS_DIR }}.zip From eed0957dffa1819ebbd80809c19a1d8820f4124a Mon Sep 17 00:00:00 2001 From: Changhua Date: Thu, 24 Apr 2025 16:41:48 +0800 Subject: [PATCH 3/5] chore(ci): update script --- .github/workflows/build-ci.yml | 6 +++--- .github/workflows/ci.yml | 4 ++++ .github/workflows/release.yml | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index 5223b1b..bfddc22 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -4,7 +4,7 @@ on: workflow_call: jobs: - windows: + build: name: Build Windows runs-on: windows-latest steps: @@ -14,7 +14,7 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: "18" + node-version: lts/* - name: Set up Rust uses: actions-rs/toolchain@v1 @@ -86,7 +86,7 @@ jobs: version: "22.2" - name: Install Tauri CLI if not cached - run: cargo install tauri-cli --version ^1.0.0 + run: cargo install tauri-cli --version ^2.0.0 if: steps.tauri-cli-cache.outputs.cache-hit != 'true' - name: Build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a4e735..e90dd0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,10 @@ on: branches: - master +permissions: + contents: read + actions: write + jobs: build: uses: ./.github/workflows/build-ci.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d586f4e..4dae8a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,10 @@ on: tags: ["v[0-9]+.[0-9]+.[0-9]+*"] workflow_dispatch: +permissions: + contents: read + actions: write + jobs: build: uses: ./.github/workflows/build-ci.yml From ce9132ce29a1d1e5d0cfe9ff447c0ac760c4cb73 Mon Sep 17 00:00:00 2001 From: Changhua Date: Thu, 24 Apr 2025 17:17:41 +0800 Subject: [PATCH 4/5] chore: remove unused file --- test_ci | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test_ci diff --git a/test_ci b/test_ci deleted file mode 100644 index e69de29..0000000 From 16e409b0805d98457f348160501be649d646659a Mon Sep 17 00:00:00 2001 From: Changhua Date: Thu, 24 Apr 2025 18:02:11 +0800 Subject: [PATCH 5/5] chore: fix pnpm cache --- .github/workflows/build-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index bfddc22..4ddd350 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -66,13 +66,15 @@ jobs: restore-keys: | ${{ runner.os }}-tauri-cli- - - name: Cache node_modules + - name: Cache pnpm store and modules uses: actions/cache@v4 with: - path: node_modules - key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }} + path: | + ~/.pnpm-store + node_modules + key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-node-modules- + ${{ runner.os }}-pnpm- - name: Install Node Module run: |