Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 43 additions & 37 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ on:
workflow_call:

jobs:
windows:
name: Build Windows Artifact
build:
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"
node-version: lts/*

- name: Set up Rust
uses: actions-rs/toolchain@v1
Expand All @@ -24,76 +23,83 @@ 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=$(<cargo_hash.txt)" >> $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-

- name: Cache node_modules
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 pnpm store and modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: ${{ runner.os }}-node-modules-

- name: Install dependencies
path: |
~/.pnpm-store
node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-

- 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
run: cargo install tauri-cli --version ^1.0.0
- name: Install Tauri CLI if not cached
run: cargo install tauri-cli --version ^2.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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- master

permissions:
contents: read
actions: write

jobs:
build:
uses: ./.github/workflows/build-ci.yml
25 changes: 16 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,40 @@ name: Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
workflow_dispatch:

permissions:
contents: read
actions: write

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
Expand All @@ -37,10 +44,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
Expand Down
Loading