File tree 2 files changed +46
-0
lines changed
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 76
76
cd docs
77
77
make fallback-videos
78
78
79
+ - name : Update version switcher (on new release)
80
+ if : ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev'))
81
+ run : |
82
+ python docs/_scripts/update_switcher.py ${{ github.event.inputs.target_directory || github.event.release.tag_name }}
83
+
84
+ - name : Commit new version switcher
85
+ run : |
86
+ git config --local user.email "[email protected] "
87
+ git config --local user.name "GitHub Action"
88
+ git add docs/_static/version_switcher.json
89
+ git commit -m "Update version switcher for release" --allow-empty
90
+
79
91
- name : Build Docs
80
92
uses : aganders3/headless-gui@v2
81
93
env :
Original file line number Diff line number Diff line change
1
+ import sys
2
+ import json
3
+
4
+
5
+ def update_version_switcher (new_version ):
6
+ """Update version_switcher.json after a new release."""
7
+ with open ("docs/_static/version_switcher.json" , "r" ) as f :
8
+ switcher = json .load (f )
9
+ oldstable = switcher [1 ]
10
+
11
+ newstable = oldstable .copy ()
12
+ newstable ["version" ] = new_version
13
+ newstable ["name" ] = f"stable ({ new_version } )"
14
+
15
+ oldstable ["name" ] = f"{ oldstable ['version' ]} "
16
+ del oldstable ["preferred" ]
17
+ oldstable ["url" ] = oldstable ["url" ].replace ("stable" , oldstable ["version" ])
18
+
19
+ switcher [1 ] = oldstable
20
+ switcher .insert (1 , newstable )
21
+ with open ("docs/_static/version_switcher.json" , "w" ) as f :
22
+ json .dump (switcher , f , indent = 4 )
23
+
24
+ print (f"Version switcher updated to { new_version } " )
25
+ print (f"Old stable version: { switcher [2 ]} " )
26
+ print (f"New stable version: { switcher [1 ]} " )
27
+
28
+
29
+ if __name__ == "__main__" :
30
+ if len (sys .argv ) != 2 :
31
+ print ("Usage: python update_switcher.py <new_version>" )
32
+ sys .exit ()
33
+ new_version = sys .argv [1 ]
34
+ update_version_switcher (new_version )
You can’t perform that action at this time.
0 commit comments