Skip to content
Merged
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
30 changes: 30 additions & 0 deletions skills/github-release/scripts/validate-pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
file="${line#version-file:}"
path="${file%%:*}"
ver="${file#*:}"
# A "private": true package.json is local tooling, not a
# publishable release surface — its version never tracks the
# release and would fail the sync check on every run.
if [[ "$path" == package.json || "$path" == package-lock.json ]] \
&& [[ -f package.json ]] \
&& grep -qE '"private"[[:space:]]*:[[:space:]]*true' package.json; then
continue
fi
if [[ -n "$ver" ]]; then
versions+=("$ver")
version_files+=("${path}=${ver}")
Expand All @@ -69,6 +77,28 @@
fi
fi

# ---------------------------------------------------------------------------
# 1b. Version files ahead of the latest tag (phantom / untagged release)
# ---------------------------------------------------------------------------
# A "chore: release X.Y.Z" commit that was merged but never tagged leaves the
# version files ahead of the newest tag — the prepared release silently never
# shipped (e.g. its tag-triggered workflow was cancelled). Surface it so the
# releaser decides deliberately whether to tag it or roll it into the next
# version.
if ((${#versions[@]} > 0)); then
# Highest file version, semver-sorted — when files are out of sync the
# sync check above already FAILed; comparing the highest against the tag
# still yields the correct "a prepared release was never tagged" signal.
file_version=$(printf '%s\n' "${versions[@]}" | sort -uV | tail -1)
latest_tag=$(git tag --list 'v[0-9]*' --sort=-v:refname | head -1)
if [[ -n "$latest_tag" && "v${file_version}" != "$latest_tag" ]]; then
if [[ "$(printf '%s\n' "${latest_tag#v}" "$file_version" | sort -V | tail -1)" == "$file_version" ]]; then

Check warning on line 95 in skills/github-release/scripts/validate-pre-release.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this if statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=netresearch_github-release-skill&issues=AZ9scCGrZYYeLVAmnmFM&open=AZ9scCGrZYYeLVAmnmFM&pullRequest=55
check "WARN" "Version files ahead of latest tag" \
"files say ${file_version}, newest tag is ${latest_tag} — a prepared release was never tagged"
fi
fi
fi

# ---------------------------------------------------------------------------
# 2. CHANGELOG.md has [Unreleased] section with content
# ---------------------------------------------------------------------------
Expand Down
Loading