From e24630c4a9a29ebdb7d19bfabbf33c6a85ef738f Mon Sep 17 00:00:00 2001 From: icsboyx Date: Sun, 11 Jan 2026 08:14:51 +0100 Subject: [PATCH] refactor: update caching key to use rust-toolchain.toml and improve package name extraction --- .gitea/workflows/build.yaml | 16 ++++++++++++++-- rust-toolchain.toml | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 596df17..140037f 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -27,7 +27,7 @@ jobs: ~/.rustup ~/.cargo/registry ~/.cargo/git - key: ${{ runner.os }}-rustup-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-rustup-${{ hashFiles('rust-toolchain.toml') }} restore-keys: | ${{ runner.os }}-rustup- @@ -62,7 +62,19 @@ jobs: run: | set -e if [ -f Cargo.toml ]; then - PKG_NAME="$(sed -n 's/^name = \"\\(.*\\)\"/\\1/p' Cargo.toml | head -n 1)" + PKG_NAME="$(cargo metadata --no-deps --format-version=1 | python3 - <<'PY' +import json +import sys + +data = json.load(sys.stdin) +for pkg in data.get("packages", []): + for target in pkg.get("targets", []): + if "bin" in target.get("kind", []): + print(target.get("name", "")) + raise SystemExit(0) +print("") +PY +)" fi if [ -z "${PKG_NAME:-}" ]; then FULL="${GITHUB_REPOSITORY:-}" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..ff100ed --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.90.0"