-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-index.sh
More file actions
executable file
·141 lines (116 loc) · 3.97 KB
/
build-index.sh
File metadata and controls
executable file
·141 lines (116 loc) · 3.97 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
#!/bin/sh
set -e
# Function to print text in green color
message() {
printf "\033[0;32m%s\033[0m\n" "$1"
}
warning() {
printf "\033[0;33m%s\033[0m\n" "$1"
}
# Clone the repository if it doesn't exist
if [ ! -d "jumpstarter" ]; then
git clone https://github.com/jumpstarter-dev/jumpstarter.git
fi
# Clean previous build artifacts
rm -rf dist
cd jumpstarter
EXCLUDED_TAGS="0.0.1 v0.0.0 v0.0.1 v0.0.2 v0.0.3 v0.5.0rc1 v0.5.0rc2 v0.7.1"
EXCLUDED_BRANCHES="release-0.5 release-0.6"
# Function to build for a given ref (tag or branch)
build_ref() {
ref=$1
out_dir=$2
message "🛠️ Building for $ref"
git checkout "$ref"
git clean -f -x # clean ignoring .gitignore rules
cd python
# for every directory in the packages/ directory, if it does not contain
# a pyproject.toml file, remove it, otherwise uv fails, this could
# be leftovers from previous branches that git clean does not remove
for dir in packages/*; do
if [ -d "$dir" ] && [ ! -f "$dir/pyproject.toml" ]; then
rm -rf "$dir"
fi
done
# Fix the root path in all pyproject.toml files for setuptools-scm
# Only for release-0.7 branch or v0.7* tags
if [ "$ref" = "release-0.7" ] || echo "$ref" | grep -q "^v0\.7"; then
message "Fixing root path for $ref"
for pyproject in packages/*/pyproject.toml; do
if [ -f "$pyproject" ]; then
sed -i.bak "s/'root' = '\.\.\/\.\.\/'/'root' = '\.\.\/\.\.\/\.\.\/'/g" "$pyproject"
rm -f "$pyproject.bak"
fi
done
fi
uv build --all --out-dir "../$out_dir"
# Restore any modified files before switching to next ref
git restore .
cd ..
}
build_index() {
dist_dir=$1
variant=$2
message "📦 Building index for ${dist_dir}/${variant}"
for f in "${dist_dir}/${variant}/files"/*.whl "${dist_dir}/${variant}/files"/*.tar.gz; do basename "$f"; done > "package-list-${variant}.txt"
cat "package-list-${variant}.txt"
uvx dumb-pypi --package-list "package-list-${variant}.txt" \
--packages-url "https://pkg.jumpstarter.dev/${variant}/files" \
--output-dir "${dist_dir}/${variant}" \
--title "Jumpstarter Python Packages"
}
# Build for tags
message "--- Building tags ---"
git tag | while read tag; do
# Check if the tag is in the excluded list
is_excluded=0
for excluded_tag in $EXCLUDED_TAGS; do
if [ "$tag" = "$excluded_tag" ]; then
is_excluded=1
break
fi
done
# Exclude tags ending with "dev", "dev0", "dev123", etc. Those are just an anchor for the main branch releases
if echo "$tag" | grep -qE "dev[0-9]*$"; then
is_excluded=1
fi
if [ $is_excluded -eq 1 ]; then
warning "Skipping excluded tag: $tag"
continue
fi
# Exclude tags matching the "v*rc*" pattern
if echo "$tag" | grep -q "v.*rc.*"; then
build_ref "$tag" "../dist/rc/files"
continue
fi
build_ref "$tag" ../dist/files
done
message "--- Index for releases ---"
build_index "../dist" ""
message "--- Index for release candidates ---"
build_index "../dist" "rc"
# Build for main branch
build_ref "main" "../dist/main/files"
build_index "../dist" "main"
# Build for release branches
# Fetch latest branches from remote
git fetch origin
# List remote branches matching release-* and strip 'origin/' prefix
git branch -r | grep 'origin/release-' | sed 's/origin\///' | while read branch; do
# Check if the branch is in the excluded list
is_excluded=0
for excluded_branch in $EXCLUDED_BRANCHES; do
if [ "$branch" = "$excluded_branch" ]; then
is_excluded=1
break
fi
done
if [ $is_excluded -eq 1 ]; then
warning "Skipping excluded branch: $branch"
continue
fi
build_ref "${branch}" "../dist/${branch}/files"
build_index "../dist" "${branch}"
done
git checkout main
message "✅ Build process completed"