Skip to content

Commit 9bdfeed

Browse files
committed
update python release doc logic
1 parent 164e79a commit 9bdfeed

1 file changed

Lines changed: 45 additions & 4 deletions

File tree

.github/workflows/python_release.yaml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,42 @@ jobs:
110110
cd python
111111
pip install -e .[docs]
112112
113-
- name: Extract version from tag
113+
- name: Extract version and check if stable
114114
id: version
115115
run: |
116116
# Extract version from tag (everything after 'python/')
117-
VERSION=${GITHUB_REF#refs/tags/python/}
117+
FULL_VERSION=${GITHUB_REF#refs/tags/python/}
118+
echo "Full version from tag: $FULL_VERSION"
119+
120+
# Extract major.minor from version (drop patch)
121+
if [[ "$FULL_VERSION" =~ ^v?([0-9]+)\.([0-9]+)\.[0-9]+(.*)?$ ]]; then
122+
MAJOR=${BASH_REMATCH[1]}
123+
MINOR=${BASH_REMATCH[2]}
124+
SUFFIX=${BASH_REMATCH[3]}
125+
VERSION="v${MAJOR}.${MINOR}"
126+
127+
# Check if this is a stable release (no suffix like -alpha, -beta, -rc)
128+
if [[ -z "$SUFFIX" ]]; then
129+
# Stable release - use 'latest' alias and make visible
130+
ALIAS="latest"
131+
HIDDEN="false"
132+
echo "Stable release detected: $FULL_VERSION -> $VERSION"
133+
else
134+
# Pre-release (alpha, beta, rc) - no 'latest' alias and hide from dropdown
135+
VERSION="${VERSION}${SUFFIX}"
136+
ALIAS=""
137+
HIDDEN="true"
138+
echo "Pre-release detected: $FULL_VERSION -> $VERSION"
139+
fi
140+
else
141+
echo "Error: Could not parse version format: $FULL_VERSION"
142+
exit 1
143+
fi
144+
118145
echo "version=$VERSION" >> $GITHUB_OUTPUT
119-
echo "Extracted version: $VERSION"
146+
echo "alias=$ALIAS" >> $GITHUB_OUTPUT
147+
echo "hidden=$HIDDEN" >> $GITHUB_OUTPUT
148+
echo "Final - Version: $VERSION, Alias: $ALIAS, Hidden: $HIDDEN"
120149
121150
- name: Configure Git
122151
run: |
@@ -126,6 +155,18 @@ jobs:
126155
- name: Deploy docs with mike
127156
run: |
128157
cd python
129-
mike deploy ${{ steps.version.outputs.version }} latest --push --update-aliases
158+
VERSION="${{ steps.version.outputs.version }}"
159+
ALIAS="${{ steps.version.outputs.alias }}"
160+
HIDDEN="${{ steps.version.outputs.hidden }}"
161+
162+
# Always deploy the full version first, but hide it
163+
echo "Deploying full version $FULL_VERSION (hidden)"
164+
mike deploy "$FULL_VERSION" --push --prop-set hidden=true
165+
166+
if [[ "$HIDDEN" == "false" ]]; then
167+
# Stable release: deploy abbreviated version with latest alias, visible in dropdown
168+
echo "Deploying stable release $VERSION with $ALIAS alias"
169+
mike deploy "$VERSION" "$ALIAS" --push --update-aliases
170+
fi
130171
env:
131172
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)