1
+ #! /bin/bash
2
+
3
+ # ###
4
+ # Utils
5
+ # ###
6
+ source ${BASH_SOURCE%/* } /utils.sh
7
+
8
+ #
9
+ # Params:
10
+ # - First positional argument: version of the tag
11
+ #
12
+ function tag_repository()
13
+ {
14
+ VERSION=$1
15
+
16
+ if [[ -z $VERSION ]]; then
17
+ echo_error " tag_repository needs VERSION"
18
+ exit 1
19
+ fi
20
+
21
+ git tag -a $VERSION -m " Release $VERSION "
22
+ git push origin --tags
23
+ }
24
+
25
+ #
26
+ # Params:
27
+ # - First positional argument: version of the tag
28
+ #
29
+ function remove_tag()
30
+ {
31
+ VERSION=$1
32
+
33
+ if [[ -z $VERSION ]]; then
34
+ echo_error " remove_tag needs VERSION"
35
+ exit 1
36
+ fi
37
+
38
+ git tag -d $VERSION
39
+ git push --delete origin $VERSION
40
+ }
41
+
42
+ #
43
+ # Needs:
44
+ # - TAG_NAME
45
+ # - PREV_TAG_NAME
46
+ # - RELEASE_NAME
47
+ #
48
+ function generate_github_release_notes_post_data()
49
+ {
50
+ cat << EOF
51
+ {
52
+ "tag_name":"$TAG_NAME ",
53
+ "previous_tag_name":"$PREV_TAG_NAME ",
54
+ "name":"$RELEASE_NAME ",
55
+ "draft":false,
56
+ "prerelease":false,
57
+ "generate_release_notes":false
58
+ }
59
+ EOF
60
+ }
61
+
62
+ #
63
+ # Needs:
64
+ # - TAG_NAME
65
+ # - PREV_TAG_NAME
66
+ # - RELEASE_NAME
67
+ #
68
+ function generate_github_release_post_data()
69
+ {
70
+ cat << EOF
71
+ {
72
+ "tag_name":"$TAG_NAME ",
73
+ "name":"$RELEASE_NAME ",
74
+ "body":"$DESCRIPTION ",
75
+ "draft":false,
76
+ "prerelease":false,
77
+ "generate_release_notes":false
78
+ }
79
+ EOF
80
+ }
81
+
82
+ #
83
+ # Params:
84
+ # - First positional argument: github access token
85
+ #
86
+ function generate_github_release_notes()
87
+ {
88
+ SECRET=$1
89
+
90
+ if [[ -z $SECRET ]]; then
91
+ echo_error " generate_github_release_notes needs SECRET"
92
+ exit 1
93
+ fi
94
+
95
+ curl --silent \
96
+ -X POST \
97
+ -H " Accept: application/vnd.github+json" \
98
+ -H " Authorization: Bearer $SECRET " \
99
+ https://api.github.com/repos/opentensor/bittensor-wallet/releases/generate-notes \
100
+ --data " $( generate_github_release_notes_post_data) "
101
+ }
102
+
103
+ #
104
+ # Params:
105
+ # - github access token
106
+ #
107
+ # Needs:
108
+ # - function 'generate_github_release_post_data' to provide that request data
109
+ # - TAG_NAME which is created within the main github_release script
110
+ # - RELEASE_NAME which is created within the main github_release script
111
+ # - DESCRIPTION which is generated with a previous call of 'generate_github_release_notes'
112
+ #
113
+ function create_github_release()
114
+ {
115
+ SECRET=$1
116
+
117
+ if [[ -z $SECRET ]]; then
118
+ echo_error " create_github_release needs SECRET"
119
+ exit 1
120
+ fi
121
+
122
+ curl --silent \
123
+ -X POST \
124
+ -H " Accept: application/vnd.github+json" \
125
+ -H " Authorization: Bearer $SECRET " \
126
+ https://api.github.com/repos/opentensor/bittensor-wallet/releases \
127
+ --data " $( generate_github_release_post_data) " > /dev/null
128
+ }
0 commit comments