refactor: update caching key to use rust-toolchain.toml and improve package name extraction
This commit is contained in:
@@ -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:-}"
|
||||
|
||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "1.90.0"
|
||||
Reference in New Issue
Block a user