-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpublish_github_release.sh
More file actions
executable file
·70 lines (55 loc) · 1.86 KB
/
Copy pathpublish_github_release.sh
File metadata and controls
executable file
·70 lines (55 loc) · 1.86 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
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
#!/usr/bin/env bash
# Create a GitHub Release for an existing annotated/lightweight tag.
# Pushing a git tag alone does not populate github.com/.../releases — this does.
#
# Usage: scripts/publish_github_release.sh <version>
# Example: scripts/publish_github_release.sh 0.5.0
#
# Requires: gh CLI authenticated (gh auth login), tag already on origin.
set -euo pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 <version>" >&2
echo "Example: $0 0.5.0" >&2
exit 2
fi
VERSION_NUM="${1#v}"
TAG="v${VERSION_NUM}"
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${REPO_ROOT}"
if [ ! -f CHANGELOG.md ]; then
echo "Error: CHANGELOG.md not found" >&2
exit 1
fi
if ! git rev-parse "${TAG}" >/dev/null 2>&1; then
echo "Error: local tag ${TAG} not found" >&2
exit 1
fi
if ! git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then
echo "Error: tag ${TAG} is not on origin; push it first (git push origin ${TAG})" >&2
exit 1
fi
if ! command -v gh >/dev/null 2>&1; then
echo "Error: gh CLI not found; install GitHub CLI" >&2
exit 1
fi
if ! gh api user -q .login >/dev/null 2>&1; then
echo "Error: gh is not authenticated; run: gh auth login" >&2
exit 1
fi
if gh release view "${TAG}" >/dev/null 2>&1; then
echo "GitHub Release ${TAG} already exists: https://github.com/olibartfast/neuriplo-infer/releases/tag/${TAG}"
exit 0
fi
NOTES_FILE="$(mktemp)"
trap 'rm -f "${NOTES_FILE}"' EXIT
bash scripts/extract_changelog_release_notes.sh "${VERSION_NUM}" > "${NOTES_FILE}"
if [ ! -s "${NOTES_FILE}" ]; then
echo "Error: no CHANGELOG section for [${VERSION_NUM}]" >&2
exit 1
fi
echo "==> Creating GitHub Release ${TAG} from CHANGELOG..."
gh release create "${TAG}" \
--repo olibartfast/neuriplo-infer \
--title "${TAG}" \
--notes-file "${NOTES_FILE}"
echo "==> Done: https://github.com/olibartfast/neuriplo-infer/releases/tag/${TAG}"