-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·91 lines (76 loc) · 2.88 KB
/
release.sh
File metadata and controls
executable file
·91 lines (76 loc) · 2.88 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
# Build and release a BEAST 3 package.
#
# Runs `mvn package` to produce the BEAST package ZIP (via maven-assembly-plugin),
# then optionally creates a GitHub release with the ZIP attached.
#
# Usage:
# ./release.sh # build + create package ZIP
# ./release.sh --release # also create a GitHub release with the ZIP attached
#
# The ZIP can then be submitted to CBAN (CompEvol/CBAN) by adding an entry
# to packages2.8.xml via pull request. See README.md for details.
#
set -euo pipefail
# --- Extract metadata from version.xml ---
if [[ ! -f version.xml ]]; then
echo "ERROR: version.xml not found in $(pwd)" >&2
exit 1
fi
# Parse only the <package> element (not <provider classname="..."> etc.)
PKG_LINE=$(grep '<package ' version.xml | head -1)
PKG_NAME=$(echo "$PKG_LINE" | sed "s/.*name=['\"]\\([^'\"]*\\)['\"].*/\\1/")
VERSION=$(echo "$PKG_LINE" | sed "s/.*version=['\"]\\([^'\"]*\\)['\"].*/\\1/")
if [[ -z "$PKG_NAME" || -z "$VERSION" ]]; then
echo "ERROR: could not parse name/version from version.xml" >&2
exit 1
fi
ZIP_NAME="${PKG_NAME}.v${VERSION}.zip"
GITHUB_REPO=$(git remote get-url origin 2>/dev/null \
| sed 's|.*github.com[:/]\(.*\)\.git$|\1|; s|.*github.com[:/]\(.*\)$|\1|')
echo "=== ${PKG_NAME} v${VERSION} ==="
echo ""
# --- Step 1: Maven build + assemble package ZIP ---
echo "--- Building with Maven ---"
mvn clean package -Dmaven.test.skip=true
echo ""
# Locate the ZIP produced by maven-assembly-plugin (in the -fx module for multi-module)
ZIP_PATH="beast-sampled-ancestors-fx/target/${ZIP_NAME}"
if [[ ! -f "$ZIP_PATH" ]]; then
echo "ERROR: expected ZIP not found at ${ZIP_PATH}" >&2
exit 1
fi
# Copy to project root for convenience
cp "$ZIP_PATH" "$ZIP_NAME"
echo "=== Package: ${ZIP_NAME} ==="
unzip -l "$ZIP_NAME"
# --- Step 2: Optionally create GitHub release ---
if [[ "${1:-}" == "--release" ]]; then
if [[ -z "$GITHUB_REPO" ]]; then
echo "ERROR: could not determine GitHub repo from git remote" >&2
exit 1
fi
echo ""
echo "--- Creating GitHub release v${VERSION} on ${GITHUB_REPO} ---"
gh release create "v${VERSION}" "$ZIP_NAME" \
--repo "$GITHUB_REPO" \
--title "${PKG_NAME} v${VERSION}" \
--generate-notes
DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${ZIP_NAME}"
echo ""
echo "=== Release created ==="
echo "URL: https://github.com/${GITHUB_REPO}/releases/tag/v${VERSION}"
echo ""
echo "--- Next step: submit to CBAN ---"
echo "Add this entry to packages2.8.xml in https://github.com/CompEvol/CBAN via pull request:"
echo ""
cat <<XMLEOF
<package name="${PKG_NAME}" version="${VERSION}"
url="${DOWNLOAD_URL}"
projectURL="https://github.com/${GITHUB_REPO}"
description="Sampled ancestor trees for BEAST">
<depends on="BEAST.base" atleast="2.8.0"/>
</package>
XMLEOF
fi