Repository navigation
Expand file tree
/
Copy pathbuild_release.sh
More file actions
executable file
·186 lines (152 loc) · 5.17 KB
/
Copy pathbuild_release.sh
File metadata and controls
executable file
·186 lines (152 loc) · 5.17 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
#
# Build a release tarball of PlanetScale Discovery Tools
# Usage: ./build_release.sh [version]
#
# If version is not provided, reads from VERSION file
#
set -e
# Get version
if [ -n "$1" ]; then
VERSION="$1"
else
if [ ! -f VERSION ]; then
echo "❌ Error: VERSION file not found and no version provided"
echo "Usage: $0 [version]"
exit 1
fi
VERSION=$(cat VERSION | tr -d '\n')
fi
echo "🚀 Building PlanetScale Discovery Tools Release v${VERSION}"
echo "=============================================="
# Validate version format (semver: X.Y.Z)
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Error: Invalid version format. Must be semantic version (e.g., 1.0.0)"
exit 1
fi
# Clean previous builds
echo "🧹 Cleaning previous builds..."
rm -rf dist/ps-discovery-${VERSION}
rm -f dist/ps-discovery-${VERSION}.zip
mkdir -p dist
# Create release directory structure
RELEASE_DIR="dist/ps-discovery-${VERSION}"
echo "📦 Creating release structure at ${RELEASE_DIR}..."
mkdir -p "${RELEASE_DIR}"
# Copy source code
echo "📋 Copying source code..."
cp -r planetscale_discovery "${RELEASE_DIR}/"
# Copy documentation
echo "📚 Copying documentation..."
cp README.md "${RELEASE_DIR}/"
cp LICENSE "${RELEASE_DIR}/"
cp CONTRIBUTING.md "${RELEASE_DIR}/"
cp -r docs "${RELEASE_DIR}/" 2>/dev/null || echo "⚠️ No docs/ directory found"
cp -r config-examples "${RELEASE_DIR}/"
# Copy setup scripts and wrapper
echo "🔧 Copying setup and installation scripts..."
cp setup.py "${RELEASE_DIR}/"
cp setup.sh "${RELEASE_DIR}/"
cp ps-discovery "${RELEASE_DIR}/"
cp requirements.txt "${RELEASE_DIR}/"
cp pyproject.toml "${RELEASE_DIR}/"
cp MANIFEST.in "${RELEASE_DIR}/"
cp VERSION "${RELEASE_DIR}/"
# Copy configuration files
echo "⚙️ Copying configuration files..."
cp pytest.ini "${RELEASE_DIR}/" 2>/dev/null || true
cp mypy.ini "${RELEASE_DIR}/" 2>/dev/null || true
cp .bandit "${RELEASE_DIR}/" 2>/dev/null || true
# Note: Tests are not included in release artifacts
# They are available in the source repository for developers
# Create installation instructions
echo "📝 Creating INSTALL.txt..."
cat > "${RELEASE_DIR}/INSTALL.txt" << 'EOF'
PlanetScale Discovery Tools - Installation Instructions
========================================================
Quick Start:
-----------
1. Ensure Python 3.10 or higher is installed:
python3 --version
2. Run the setup script:
chmod +x setup.sh
./setup.sh
3. Fill in config.yaml (created by setup.sh) with your credentials,
then run discovery:
./ps-discovery
Running ./ps-discovery with no arguments uses ./config.yaml. See README.md
to run a specific scope or point at a different config file.
No virtual environment activation required — the wrapper script
handles it automatically.
For full documentation, see README.md
For cloud provider setup, see docs/providers/ directory
EOF
# Create release notes template
echo "📰 Creating RELEASE_NOTES.txt..."
# Extract the latest version's section from CHANGELOG.md so release notes
# stay in sync without manual edits. Falls back to a pointer at CHANGELOG.md
# if no matching section is found (e.g. version mismatch or missing file).
CHANGELOG_SECTION=""
if [ -f CHANGELOG.md ]; then
CHANGELOG_SECTION=$(awk -v ver="${VERSION}" '
$0 ~ "^## \\[" ver "\\]" { capture=1; next }
capture && /^## \[/ { exit }
capture { print }
' CHANGELOG.md)
fi
if [ -z "${CHANGELOG_SECTION// }" ]; then
echo "⚠️ No CHANGELOG.md section found for v${VERSION}; using fallback notes"
CHANGELOG_SECTION="See CHANGELOG.md for changes in this release."
fi
cat > "${RELEASE_DIR}/RELEASE_NOTES.txt" << EOF
PlanetScale Discovery Tools v${VERSION}
Release Date: $(date +%Y-%m-%d)
## Quick Start
1. Extract the archive:
\`\`\`
unzip ps-discovery-${VERSION}.zip
cd ps-discovery-${VERSION}
\`\`\`
2. Run the setup script:
\`\`\`
chmod +x setup.sh
./setup.sh
\`\`\`
3. Fill in config.yaml (created by setup.sh), then run discovery
(see INSTALL.txt for options):
\`\`\`
./ps-discovery
\`\`\`
## What's New in v${VERSION}
${CHANGELOG_SECTION}
For detailed usage instructions, see [README.md](https://github.com/planetscale/ps-discovery/blob/main/README.md)
For provider-specific setup, see [docs/providers/](https://github.com/planetscale/ps-discovery/tree/main/docs/providers)
Report issues: https://github.com/planetscale/ps-discovery/issues
EOF
# Create zip file
echo "📦 Creating zip file..."
cd dist
zip -r "ps-discovery-${VERSION}.zip" "ps-discovery-${VERSION}"
cd ..
# Calculate checksum
echo "🔐 Generating checksums..."
cd dist
sha256sum "ps-discovery-${VERSION}.zip" > "ps-discovery-${VERSION}.zip.sha256"
cd ..
# Display results
echo ""
echo "✅ Release build complete!"
echo ""
echo "📦 Release artifacts:"
echo " - dist/ps-discovery-${VERSION}.zip"
echo " - dist/ps-discovery-${VERSION}.zip.sha256"
echo ""
echo "Zip file size: $(du -h "dist/ps-discovery-${VERSION}.zip" | cut -f1)"
echo ""
echo "To verify:"
echo " cd dist && sha256sum -c ps-discovery-${VERSION}.zip.sha256"
echo ""
echo "To extract:"
echo " unzip ps-discovery-${VERSION}.zip"
echo " cd ps-discovery-${VERSION}"
echo " ./setup.sh"