aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/assert-readme.sh
blob: 333a75320c00c4fda11e667ef15d4776daaf4fae (about) (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
set -eu

TLD="$(cat aux/tld.txt)"
. aux/lib.sh

while getopts 'n:m:' flag; do
	case "$flag" in
		n)
			PROJECT="$OPTARG"
			;;
		m)
			MAILING_LIST="$OPTARG"
			;;
		*)
			exit 2
			;;
	esac
done
shift $((OPTIND - 1))

assert_arg() {
	if [ -z "$1" ]; then
		echo "Missing $2" >&2
		exit 2
	fi
}

assert_arg "${PROJECT:-}" '-n PROJECT'
assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST'

EXPECTED="$(mkstemp)"
cat <<EOF >> "$EXPECTED"

For running the extra development-only checks, run:

\`\`\`shell
$ make dev-check
\`\`\`

and for generating the documentation HTML and website, run:

\`\`\`shell
$ make public
\`\`\`

Send contributions to the [mailing list] via [\`git send-email\`](https://git-send-email.io/).


## Links

- [homepage](https://$TLD/$PROJECT/en/)
- [source code](https://git.euandreh.xyz/$PROJECT/)
- [bug tracking](https://$TLD/$PROJECT/TODOs.html)
- [mailing list]
- [CI logs](https://$TLD/$PROJECT/ci.html)
- [CHANGELOG](https://$TLD/$PROJECT/en/CHANGELOG.html)

[mailing list]: https://lists.sr.ht/~euandreh/$MAILING_LIST?search=%5B$PROJECT%5D
EOF

RELEASES_LIST="$(mkstemp)"
add_release() {
	DATE="$1"
	VVERSION="$2"
	echo "- [$VVERSION](https://git.euandreh.xyz/$PROJECT/commit/?id=$VVERSION) [$PROJECT-$VVERSION.tar.xz](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.xz) ([sig](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.xz.asc)) - $DATE" >> "$RELEASES_LIST"
}

for VVERSION in $(git tag); do
	DATE="$(git log -1 --format=%cd --date=short "$VVERSION")"
	add_release "$DATE" "$VVERSION"
done

# "$@" represents a list of tags to be also included in the verification.
for VVERSION in "$@"; do
	if ! git tag | grep -qF "$VVERSION"; then
		DATE="$(date '+%Y-%m-%d')"
		add_release "$DATE" "$VVERSION"
	fi
done

if [ -s "$RELEASES_LIST" ]; then
	printf '\n\n## Releases\n\n' >> "$EXPECTED"
	sort -r "$RELEASES_LIST" >> "$EXPECTED"
fi

cat <<EOF >> "$EXPECTED"


## License

The code is licensed under [GNU Affero General Public License v3.0 or later][AGPL-3.0-or-later] (AGPL-3.0-or-later).

[AGPL-3.0-or-later]: https://git.euandreh.xyz/$PROJECT/tree/COPYING
EOF

if ! tail -n "$(wc -l < "$EXPECTED")" README.md | diff - "$EXPECTED"; then
	echo 'Wrong metadata at the end of README.md file'
	echo "See expected content at: $EXPECTED"
	exit 1
fi