mirror of
https://github.com/lahfir/agent-desktop.git
synced 2026-07-26 17:12:15 +00:00
ci: guard release metadata consistency
This commit is contained in:
parent
794d378bfc
commit
a5b2c3d912
4 changed files with 96 additions and 2 deletions
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
|
|
@ -69,6 +69,9 @@ jobs:
|
|||
fi
|
||||
echo "OK: core crate has no platform dependencies"
|
||||
|
||||
- name: Check release metadata consistency
|
||||
run: scripts/check-release-consistency.sh
|
||||
|
||||
- name: Clippy
|
||||
run: cargo clippy --locked --all-targets -- -D warnings
|
||||
|
||||
|
|
|
|||
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
|
|
@ -46,7 +46,7 @@ jobs:
|
|||
exit 0
|
||||
fi
|
||||
|
||||
git init release-pr
|
||||
git init -b main release-pr
|
||||
cd release-pr
|
||||
git remote add origin "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git"
|
||||
git fetch --depth=1 origin "$BRANCH"
|
||||
|
|
@ -54,7 +54,8 @@ jobs:
|
|||
|
||||
rustup show
|
||||
VERSION=$(sed -n 's/.*version *= *"\([^"]*\)".*/\1/p' Cargo.toml | head -1)
|
||||
cargo update --offline -p agent-desktop --precise "$VERSION"
|
||||
cargo update -p agent-desktop --precise "$VERSION"
|
||||
scripts/check-release-consistency.sh
|
||||
|
||||
if git diff --quiet -- Cargo.lock; then
|
||||
echo "Cargo.lock already matches release version ${VERSION}"
|
||||
|
|
|
|||
3
.github/workflows/supply-chain.yml
vendored
3
.github/workflows/supply-chain.yml
vendored
|
|
@ -24,6 +24,9 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Check release metadata consistency
|
||||
run: scripts/check-release-consistency.sh
|
||||
|
||||
- name: Cargo dependency policy
|
||||
uses: EmbarkStudios/cargo-deny-action@6c8f9facfa5047ec02d8485b6bf52b587b7777d1 # v2.0.18
|
||||
with:
|
||||
|
|
|
|||
87
scripts/check-release-consistency.sh
Executable file
87
scripts/check-release-consistency.sh
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
fail() {
|
||||
echo "FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
read_toml_version() {
|
||||
sed -n 's/^version *= *"\([^"]*\)".*/\1/p' Cargo.toml | head -1
|
||||
}
|
||||
|
||||
read_json_version() {
|
||||
local file="$1"
|
||||
sed -n 's/.*"version" *: *"\([^"]*\)".*/\1/p' "$file" | head -1
|
||||
}
|
||||
|
||||
read_manifest_version() {
|
||||
sed -n 's/.*"\." *: *"\([^"]*\)".*/\1/p' .release-please-manifest.json | head -1
|
||||
}
|
||||
|
||||
lock_version_for() {
|
||||
local package="$1"
|
||||
awk -v target="$package" '
|
||||
/^\[\[package\]\]/ {
|
||||
if (name == target) {
|
||||
print version
|
||||
found = 1
|
||||
exit
|
||||
}
|
||||
name = ""
|
||||
version = ""
|
||||
next
|
||||
}
|
||||
/^name = / {
|
||||
name = $3
|
||||
gsub(/"/, "", name)
|
||||
next
|
||||
}
|
||||
/^version = / {
|
||||
version = $3
|
||||
gsub(/"/, "", version)
|
||||
next
|
||||
}
|
||||
END {
|
||||
if (!found && name == target) {
|
||||
print version
|
||||
}
|
||||
}
|
||||
' Cargo.lock
|
||||
}
|
||||
|
||||
workspace_version="$(read_toml_version)"
|
||||
npm_version="$(read_json_version npm/package.json)"
|
||||
manifest_version="$(read_manifest_version)"
|
||||
|
||||
[[ -n "$workspace_version" ]] || fail "could not read workspace version from Cargo.toml"
|
||||
[[ -n "$npm_version" ]] || fail "could not read npm package version"
|
||||
[[ -n "$manifest_version" ]] || fail "could not read release-please manifest version"
|
||||
|
||||
[[ "$npm_version" == "$workspace_version" ]] \
|
||||
|| fail "npm/package.json version ${npm_version} does not match Cargo.toml ${workspace_version}"
|
||||
|
||||
[[ "$manifest_version" == "$workspace_version" ]] \
|
||||
|| fail ".release-please-manifest.json version ${manifest_version} does not match Cargo.toml ${workspace_version}"
|
||||
|
||||
packages=(
|
||||
agent-desktop
|
||||
agent-desktop-core
|
||||
agent-desktop-ffi
|
||||
agent-desktop-linux
|
||||
agent-desktop-macos
|
||||
agent-desktop-windows
|
||||
)
|
||||
|
||||
for package in "${packages[@]}"; do
|
||||
lock_version="$(lock_version_for "$package")"
|
||||
[[ -n "$lock_version" ]] || fail "Cargo.lock is missing ${package}"
|
||||
[[ "$lock_version" == "$workspace_version" ]] \
|
||||
|| fail "Cargo.lock ${package} version ${lock_version} does not match Cargo.toml ${workspace_version}"
|
||||
done
|
||||
|
||||
cargo metadata --locked --no-deps --format-version 1 >/dev/null
|
||||
echo "OK: release metadata is internally consistent for ${workspace_version}"
|
||||
Loading…
Reference in a new issue