Repository navigation
97 lines (89 loc) · 2.98 KB
/
Copy pathpython_redeploy_docs.yml
File metadata and controls
97 lines (89 loc) · 2.98 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
name: Redeploy Python Docs
on:
workflow_dispatch:
inputs:
version:
description: 'Version or custom alias to deploy under (e.g., v0.14, staging, preview). Leave empty to derive from the latest stable python/v*.*.* tag.'
required: false
type: string
update_latest:
description: 'Also update the "latest" alias'
required: false
default: true
type: boolean
hidden:
description: 'Hide from the version dropdown. "auto" hides custom aliases and shows vX.Y versions.'
required: false
default: 'auto'
type: choice
options:
- auto
- 'true'
- 'false'
jobs:
redeploy_docs:
name: Redeploy Documentation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest stable tag
id: latest_tag
if: inputs.version == ''
run: |
LATEST_TAG=$(git tag -l 'python/v*' | grep -E '^python/v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1 || true)
if [[ -z "$LATEST_TAG" ]]; then
echo "Error: No stable python/v*.*.* tag found. Provide the 'version' input."
exit 1
fi
echo "tag=$LATEST_TAG" >> "$GITHUB_OUTPUT"
echo "Found latest stable tag: $LATEST_TAG"
- name: Parse latest tag
id: parsed
if: inputs.version == ''
uses: ./.github/actions/python-version-info
with:
version: ${{ steps.latest_tag.outputs.tag }}
- name: Resolve version and visibility
id: resolve
env:
INPUT_VERSION: ${{ inputs.version }}
DERIVED_VERSION: ${{ steps.parsed.outputs.major_minor }}
HIDDEN_INPUT: ${{ inputs.hidden }}
run: |
if [[ -n "$INPUT_VERSION" ]]; then
VERSION="$INPUT_VERSION"
echo "Using provided version: $VERSION"
else
VERSION="$DERIVED_VERSION"
echo "Using version derived from latest stable tag: $VERSION"
fi
case "$HIDDEN_INPUT" in
auto)
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+$ ]]; then
HIDDEN="false"
else
HIDDEN="true"
fi
echo "hidden=auto resolved to $HIDDEN for version $VERSION"
;;
true|false)
HIDDEN="$HIDDEN_INPUT"
;;
*)
echo "Error: unexpected hidden value '$HIDDEN_INPUT'"
exit 1
;;
esac
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "hidden=$HIDDEN" >> "$GITHUB_OUTPUT"
- name: Deploy docs
uses: ./.github/actions/python-mike-deploy
with:
version: ${{ steps.resolve.outputs.version }}
aliases: ${{ inputs.update_latest && 'latest' || '' }}
hidden: ${{ steps.resolve.outputs.hidden }}