-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·116 lines (103 loc) · 3.21 KB
/
release.sh
File metadata and controls
executable file
·116 lines (103 loc) · 3.21 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
# Release a new version of hyper_fingerprints.
#
# Usage:
# ./release.sh patch # 0.1.0 -> 0.1.1
# ./release.sh minor # 0.1.0 -> 0.2.0
# ./release.sh major # 0.1.0 -> 1.0.0
#
# What this does:
# 1. Checks that the working directory is clean
# 2. Builds a wheel and runs the full test suite (via nox)
# 3. Bumps the version (via bump-my-version)
# 4. Commits the version bump
# 5. Creates a git tag (v0.2.0 etc.)
# 6. Pushes the commit and tag to origin
# 7. Creates a GitHub release (triggers Zenodo archival)
# 8. GitHub Actions CI then automatically builds all platform wheels
# and publishes to PyPI
set -euo pipefail
PART="${1:-}"
if [[ -z "$PART" ]]; then
echo "Usage: ./release.sh <patch|minor|major>"
echo ""
echo "Current version: $(cat hyper_fingerprints/VERSION)"
exit 1
fi
if [[ "$PART" != "patch" && "$PART" != "minor" && "$PART" != "major" ]]; then
echo "ERROR: argument must be 'patch', 'minor', or 'major' (got '$PART')"
exit 1
fi
echo "============================================"
echo " hyper_fingerprints release"
echo "============================================"
echo ""
# --- Step 1: Check clean working directory ---
echo "[1/7] Checking working directory..."
if [[ -n "$(git status --porcelain)" ]]; then
echo " ERROR: working directory is not clean. Commit or stash changes first."
echo ""
git status --short
exit 1
fi
echo " OK — working directory is clean."
echo ""
# --- Step 2: Build and test ---
echo "[2/7] Building wheel and running test suite (nox -s build_test)..."
echo " This builds a release wheel, installs it in a clean venv,"
echo " and runs all tests against it."
echo ""
if ! nox -s build_test; then
echo ""
echo " ERROR: build_test failed! Aborting release."
echo " No changes were made to the repository."
exit 1
fi
echo ""
echo " All tests passed."
echo ""
# --- Step 3: Bump version ---
echo "[3/7] Bumping version ($PART)..."
echo " Current version: $(cat hyper_fingerprints/VERSION)"
bump-my-version bump "$PART"
NEW_VERSION="$(cat hyper_fingerprints/VERSION)"
TAG="v$NEW_VERSION"
echo " New version: $NEW_VERSION"
echo ""
# --- Step 4: Commit version bump ---
echo "[4/7] Committing version bump..."
git add -A
git commit -m "Bump version to $NEW_VERSION"
echo " Committed."
echo ""
# --- Step 5: Tag ---
echo "[5/7] Creating tag $TAG..."
if git rev-parse "$TAG" &>/dev/null; then
echo " ERROR: tag $TAG already exists!"
exit 1
fi
git tag "$TAG"
echo " Tagged."
echo ""
# --- Step 6: Push ---
echo "[6/7] Pushing to origin..."
git push origin master --tags
echo " Pushed."
echo ""
# --- Step 7: Create GitHub release (triggers Zenodo) ---
echo "[7/7] Creating GitHub release..."
gh release create "$TAG" --title "$TAG" --notes "Release $NEW_VERSION"
echo " GitHub release created."
echo ""
echo "============================================"
echo " Released $TAG"
echo "============================================"
echo ""
echo " CI will now build wheels for all platforms"
echo " and publish to PyPI."
echo ""
echo " Zenodo will archive this release and mint a DOI."
echo ""
echo " Watch progress:"
echo " https://github.com/the16thpythonist/hyper-fingerprints/actions"
echo ""