-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathlint-changelog.sh
More file actions
executable file
·44 lines (38 loc) · 1.84 KB
/
Copy pathlint-changelog.sh
File metadata and controls
executable file
·44 lines (38 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -euo pipefail
# Validates CHANGELOG.md with @metamask/auto-changelog, mirroring the pattern used
# by metamask-extension (see .github/workflows/repository-health-checks.yml there).
#
# On release-oriented branches, `--rc` is added so validation also enforces that the
# branch's current package.json version has a corresponding changelog section. This
# is what should have caught the malformed '### **Before**' header that broke the
# 8.3.0 -> 8.4.0 release-cut automation before it ever reached CI.
#
# Branch shapes treated as release-oriented:
# release/X.Y.Z, release/X.Y.Z-ota (release branches, incl. OTA hotfixes)
# release-changelog/X.Y.Z[...] (the changelog-generation working branch)
#
# package.json has no "repository" field, so --repo is passed explicitly.
#
# --prettier tells the validator to expect the changelog in Prettier-formatted
# Markdown (blank line after headings), which matches this repo's existing
# CHANGELOG.md style. Without it, validation would fail against a stricter,
# denser canonical form (no blank line after headings) hardcoded in
# @metamask/auto-changelog's stringifier, which would otherwise force
# reformatting the entire file's history to pass.
readonly REPO_URL='https://github.com/MetaMask/metamask-mobile'
branch="${GITHUB_HEAD_REF:-}"
if [[ -z "$branch" ]]; then
branch="${GITHUB_REF_NAME:-}"
fi
if [[ -z "$branch" ]]; then
branch="$(git branch --show-current 2>/dev/null || true)"
fi
rc_flag=()
if [[ "$branch" =~ ^release/[0-9]+\.[0-9]+\.[0-9]+(-ota)?$ ]] || [[ "$branch" =~ ^release-changelog/[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Branch '${branch}' is release-oriented: validating with --rc"
rc_flag=(--rc)
else
echo "Branch '${branch}' is not release-oriented: validating without --rc"
fi
yarn auto-changelog validate --repo "$REPO_URL" --prettier "${rc_flag[@]+"${rc_flag[@]}"}"