refactor: update caching key to use rust-toolchain.toml and improve package name extraction

This commit is contained in:
2026-01-11 08:14:51 +01:00
parent b8e209bd03
commit e24630c4a9
2 changed files with 16 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ jobs:
~/.rustup ~/.rustup
~/.cargo/registry ~/.cargo/registry
~/.cargo/git ~/.cargo/git
key: ${{ runner.os }}-rustup-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-rustup- ${{ runner.os }}-rustup-
@@ -62,7 +62,19 @@ jobs:
run: | run: |
set -e set -e
if [ -f Cargo.toml ]; then 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 fi
if [ -z "${PKG_NAME:-}" ]; then if [ -z "${PKG_NAME:-}" ]; then
FULL="${GITHUB_REPOSITORY:-}" FULL="${GITHUB_REPOSITORY:-}"

2
rust-toolchain.toml Normal file
View File

@@ -0,0 +1,2 @@
[toolchain]
channel = "1.90.0"