Skip to content

Commit a2dba53

Browse files
authored
Merge pull request #94 from lich0821/test_ci
chore(ci): fix ci
2 parents c92db9e + 16e409b commit a2dba53

3 files changed

Lines changed: 63 additions & 46 deletions

File tree

.github/workflows/build-ci.yml

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ on:
44
workflow_call:
55

66
jobs:
7-
windows:
8-
name: Build Windows Artifact
7+
build:
8+
name: Build Windows
99
runs-on: windows-latest
10-
1110
steps:
1211
- name: Check out code
1312
uses: actions/checkout@v4
1413

15-
- name: Set up Node.js
14+
- name: Set up node
1615
uses: actions/setup-node@v4
1716
with:
18-
node-version: "18"
17+
node-version: lts/*
1918

2019
- name: Set up Rust
2120
uses: actions-rs/toolchain@v1
@@ -24,76 +23,83 @@ jobs:
2423
toolchain: stable
2524
override: true
2625

27-
- name: Compute Cargo cache key
26+
# Ignore lines containing 'version = "x.x.x"' and hash the rest of Cargo.lock
27+
- name: Generate custom cache key
2828
id: cargo-hash
2929
run: |
30-
grep -v '^version = ' src-tauri/Cargo.toml \
31-
| shasum -a 256 \
32-
| awk '{ print $1 }' > cargo_hash.txt
33-
echo "CARGO_CACHE_KEY=$(<cargo_hash.txt)" >> $GITHUB_ENV
30+
grep -v '^version = ' src-tauri/Cargo.toml | shasum -a 256 | awk '{ print $1 }' > cargo_hash.txt
31+
echo "CARGO_CACHE_KEY=$(cat cargo_hash.txt)" >> $GITHUB_ENV
32+
echo "::set-output name=CARGO_CACHE_KEY::$(cat cargo_hash.txt)"
3433
3534
- name: Cache Cargo registry
3635
uses: actions/cache@v4
3736
with:
3837
path: ~/.cargo/registry
39-
key: ${{ runner.os }}-cargo-registry-${{ env.CARGO_CACHE_KEY }}
40-
restore-keys: ${{ runner.os }}-cargo-registry-
38+
key: ${{ runner.os }}-cargo-registry-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }}
39+
restore-keys: |
40+
${{ runner.os }}-cargo-registry-
4141
4242
- name: Cache Cargo git index
4343
uses: actions/cache@v4
4444
with:
4545
path: ~/.cargo/git
46-
key: ${{ runner.os }}-cargo-git-${{ env.CARGO_CACHE_KEY }}
47-
restore-keys: ${{ runner.os }}-cargo-git-
46+
key: ${{ runner.os }}-cargo-git-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }}
47+
restore-keys: |
48+
${{ runner.os }}-cargo-git-
4849
49-
- name: Cache Cargo target dir
50+
- name: Cache Cargo target directory
5051
uses: actions/cache@v4
5152
with:
5253
path: src-tauri/target
53-
key: ${{ runner.os }}-cargo-target-${{ env.CARGO_CACHE_KEY }}-$(rustc --version)
54-
restore-keys: ${{ runner.os }}-cargo-target-
54+
key: ${{ runner.os }}-cargo-target-${{ matrix.target }}-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }}-$(rustc --version)
55+
restore-keys: |
56+
${{ runner.os }}-cargo-target-
5557
56-
- name: Cache Tauri CLI
58+
- name: Cache Tauri CLI (cross-platform)
5759
id: tauri-cli-cache
5860
uses: actions/cache@v4
5961
with:
60-
path: ~/.cargo/bin/cargo-tauri*
61-
key: ${{ runner.os }}-tauri-cli-${{ env.CARGO_CACHE_KEY }}
62-
restore-keys: ${{ runner.os }}-tauri-cli-
63-
64-
- name: Cache node_modules
62+
path: |
63+
~/.cargo/bin/cargo-tauri
64+
~/.cargo/bin/cargo-tauri.exe
65+
key: ${{ runner.os }}-tauri-cli-${{ steps.cargo-hash.outputs.CARGO_CACHE_KEY }}
66+
restore-keys: |
67+
${{ runner.os }}-tauri-cli-
68+
69+
- name: Cache pnpm store and modules
6570
uses: actions/cache@v4
6671
with:
67-
path: node_modules
68-
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
69-
restore-keys: ${{ runner.os }}-node-modules-
70-
71-
- name: Install dependencies
72+
path: |
73+
~/.pnpm-store
74+
node_modules
75+
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
76+
restore-keys: |
77+
${{ runner.os }}-pnpm-
78+
79+
- name: Install Node Module
7280
run: |
7381
npm i pnpm -g
82+
echo "C:/Users/runneradmin/AppData/Roaming/npm" >> $GITHUB_PATH
7483
pnpm i
75-
shell: bash
7684
7785
- name: Install Protoc
7886
uses: arduino/setup-protoc@v3
7987
with:
8088
version: "22.2"
8189

82-
- name: Install Tauri CLI if needed
83-
run: cargo install tauri-cli --version ^1.0.0
90+
- name: Install Tauri CLI if not cached
91+
run: cargo install tauri-cli --version ^2.0.0
8492
if: steps.tauri-cli-cache.outputs.cache-hit != 'true'
8593

86-
- name: Build Tauri bundle
94+
- name: Build
8795
run: cargo tauri build
8896
working-directory: ./src-tauri
8997

90-
- name: Create output dir
91-
run: mkdir -p output
92-
shell: bash
98+
- name: Create output directory
99+
run: mkdir output
93100

94-
- name: Copy executables
101+
- name: Copy files to output
95102
run: cp src-tauri/target/release/bundle/nsis/*.exe output/
96-
shell: bash
97103

98104
- name: Upload artifact
99105
uses: actions/upload-artifact@v4

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches:
66
- master
77

8+
permissions:
9+
contents: read
10+
actions: write
11+
812
jobs:
913
build:
1014
uses: ./.github/workflows/build-ci.yml

.github/workflows/release.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,40 @@ name: Release
22

33
on:
44
push:
5-
tags:
6-
- "v[0-9]+.[0-9]+.[0-9]+"
5+
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
76
workflow_dispatch:
87

8+
permissions:
9+
contents: read
10+
actions: write
11+
912
jobs:
1013
build:
1114
uses: ./.github/workflows/build-ci.yml
1215

13-
publish:
16+
release:
1417
name: Publish Release
15-
needs: build
1618
runs-on: ubuntu-latest
19+
needs: build
1720

1821
steps:
1922
- name: Check out code
2023
uses: actions/checkout@v4
2124

22-
- name: Determine version info
25+
- name: Determine Release Info
26+
env:
27+
GITHUB_REF: ${{ github.ref }}
2328
run: |
2429
VERSION=${GITHUB_REF##*/}
2530
MAJOR=${VERSION%%.*}
26-
MINOR=${VERSION#*.}; MINOR=${MINOR%%.*}
31+
MINOR=${VERSION%.*}
32+
MINOR=${MINOR#*.}
2733
PATCH=${VERSION##*.}
2834
echo "VERSION=$VERSION" >> $GITHUB_ENV
2935
echo "WINDOWS_DIR=WeChatFerry_${MAJOR}.${MINOR}.${PATCH}_windows_x64" >> $GITHUB_ENV
36+
echo "INNER_DIR=WeChatFerry-$VERSION" >> $GITHUB_ENV
3037
31-
- name: Create directory
38+
- name: Create Windows Directory
3239
run: mkdir -p ${{ env.WINDOWS_DIR }}
3340

3441
- name: Download Windows artifact
@@ -37,10 +44,10 @@ jobs:
3744
name: windows
3845
path: ${{ env.WINDOWS_DIR }}
3946

40-
- name: Zip Windows bundle
47+
- name: Create Windows Archive
4148
run: zip -r ${{ env.WINDOWS_DIR }}.zip ${{ env.WINDOWS_DIR }}
4249

43-
- name: Publish to GitHub Releases
50+
- name: Upload Windows binary
4451
uses: softprops/action-gh-release@v1
4552
with:
4653
files: ${{ env.WINDOWS_DIR }}.zip

0 commit comments

Comments
 (0)