File tree 2 files changed +26
-8
lines changed
2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 4
4
import json
5
5
import subprocess
6
6
7
+ def git (cmd ):
8
+ return subprocess .run (cmd , text = True , stdout = subprocess .PIPE ).stdout .strip ().splitlines ()
9
+
7
10
def git_tags ():
8
11
cmd = ['git' , 'tag' , '--list' , '--sort=version:refname' ]
9
12
10
- return subprocess .run (cmd , text = True , stdout = subprocess .PIPE ).stdout .strip ().splitlines ()
13
+ return git (cmd )
14
+
15
+ def git_branches ():
16
+ cmd = ['git' , 'branch' , '--list' , '--format=%(refname:short)' ]
11
17
18
+ return git (cmd )
12
19
13
20
def main ():
14
21
parser = argparse .ArgumentParser ()
22
+ parser .add_argument ('--tags' , action = 'store_true' )
23
+ parser .add_argument ('--branches' , action = 'store_true' )
15
24
parser .add_argument ('--latest' , action = 'store_true' )
16
25
args = parser .parse_args ()
17
26
18
- tags = git_tags ()
19
-
20
27
if args .latest :
21
- print (tags [- 1 ])
28
+ print (git_tags () [- 1 ])
22
29
return
23
30
24
- tags = [ { 'ref' : tag , 'name' : tag } for tag in tags ]
25
- tags += [ { 'ref' : 'main' , 'name' : 'testing' } ]
31
+ refs = []
32
+
33
+ if args .tags :
34
+ refs += git_tags ()
35
+
36
+ if args .branches :
37
+ refs += git_branches ()
38
+ refs = [ ref for ref in refs if '/' not in ref ]
39
+
40
+ refs = [ { 'ref' : ref , 'name' : ref } for ref in refs ]
26
41
27
42
matrix = {
28
- 'include' : tags ,
43
+ 'include' : refs ,
29
44
}
30
45
31
46
print (json .dumps (matrix ))
Original file line number Diff line number Diff line change 13
13
with :
14
14
fetch-depth : 0
15
15
- id : version-matrix
16
- run : echo "matrix=$(.github/config.py)" | tee $GITHUB_OUTPUT
16
+ run : echo "matrix=$(.github/config.py --tags --branches )" | tee $GITHUB_OUTPUT
17
17
- id : latest
18
18
run : echo "latest=$(.github/config.py --latest)" | tee $GITHUB_OUTPUT
19
19
69
69
- run : |
70
70
mkdir stable
71
71
echo "<meta http-equiv=\"refresh\" content=\"0; url=../v0.1.0\" />" > stable/index.html
72
+ - run : |
73
+ mkdir testing
74
+ echo "<meta http-equiv=\"refresh\" content=\"0; url=../main\" />" > testing/index.html
72
75
- run : find
73
76
- uses : actions/configure-pages@v1
74
77
- uses : actions/upload-pages-artifact@v1
You can’t perform that action at this time.
0 commit comments