Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 14c89ec

Browse files
authored
Release/0.0.1 (#2)
* Fix packaging (#1) * use find packages * bump version * add 0.0.0 changelog * update changelog * add VERSION file * fix version in readme * add ddt to test reqs * Revert "add ddt to test reqs" This reverts commit ff6e636. * Add release scripts (#3)
1 parent 4bca1c3 commit 14c89ec

File tree

13 files changed

+668
-9
lines changed

13 files changed

+668
-9
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
## 0.0.1 / 2023-06-27
4+
5+
## What's Changed
6+
* Fix packaging issues by @camfairchild in https://github.com/opentensor/bittensor-wallet/pull/1
7+
8+
**Full Changelog**: https://github.com/opentensor/bittensor-wallet/compare/v0.0.0...v0.0.1
9+
10+
11+
## 0.0.0 / 2023-06-26
12+
13+
### Initial release
14+
15+
**Full Changelog**: N/A

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# BittensorWallet - v0.0.0
1+
# BittensorWallet - v0.0.1
22

33
BittensorWallet is a library for managing wallet keypairs, keyfiles, etc. for the [Bittensor Python API](https://github.com/opentensor/bittensor).
44

@@ -7,7 +7,7 @@ The purpose of this repo is to separate the concern of keyfile management from t
77
# Installation
88
This package can be installed from [PyPi.org](https://pypi.org/project/bittensor-wallet/):
99
```bash
10-
pip install bittensor-wallet==0.0.0
10+
pip install bittensor-wallet==0.0.1
1111
```
1212
or via this repo (using [gh-cli](https://cli.github.com/)):
1313
```bash

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.0.1

bittensor_wallet/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1818
# DEALINGS IN THE SOFTWARE.
1919

20-
__version__ = "0.0.0"
20+
__version__ = "0.0.1"
2121
__ss58_format__ = 42 # Bittensor ss58 format
2222

2323
import argparse

bittensor_wallet/_keyfile/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def __new__( cls, path: str = None ) -> 'keyfile_impl.Keyfile':
2828
Path where this keypair is stored.
2929
"""
3030
path = '~/.bittensor/wallets/default/coldkey' if path == None else path
31-
return keyfile_impl.Keyfile( path = path )
31+
return keyfile_impl.Keyfile( path = path )
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
####
4+
# Utils
5+
####
6+
source ${BASH_SOURCE%/*}/utils.sh
7+
source ${BASH_SOURCE%/*}/github_utils.sh
8+
###
9+
10+
# 1. Get options
11+
12+
## Defaults
13+
APPLY="false"
14+
15+
while [[ $# -gt 0 ]]; do
16+
case $1 in
17+
-A|--apply)
18+
APPLY="true"
19+
shift # past argument
20+
;;
21+
-P|--previous-version-tag)
22+
PREV_TAG_VERSION="$2"
23+
shift # past argument
24+
shift # past value
25+
;;
26+
-V|--version)
27+
VERSION="$2"
28+
shift # past argument
29+
shift # past value
30+
;;
31+
-T|--github-token)
32+
GITHUB_TOKEN="$2"
33+
shift # past argument
34+
shift # past value
35+
;;
36+
-*|--*)
37+
echo "Unknown option $1"
38+
exit 1
39+
;;
40+
*)
41+
POSITIONAL_ARGS+=("$1") # save positional arg
42+
shift # past argument
43+
;;
44+
esac
45+
done
46+
47+
if [[ -z $GITHUB_TOKEN && $APPLY == "true" ]]; then
48+
echo_error "Github token required (-T, --github-token)"
49+
exit 1
50+
fi
51+
52+
if [[ -z $PREV_TAG_VERSION ]]; then
53+
echo_error "Previous version tag required (-P, --previous-version-tag)"
54+
exit 1
55+
fi
56+
57+
if [[ -z $VERSION ]]; then
58+
echo_error "Version to release required (-V, --version)"
59+
exit 1
60+
fi
61+
62+
DATE=$(date +"%Y-%m-%d")
63+
RELEASE_NAME="$VERSION / $DATE"
64+
TAG_NAME=v$VERSION
65+
PREV_TAG_NAME=v$PREV_TAG_VERSION
66+
67+
# 2.2. Generate release notes
68+
if [[ $APPLY == "true" ]]; then
69+
echo_info "Generating Github release notes"
70+
RESPONSE=$(generate_github_release_notes $GITHUB_TOKEN)
71+
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | gsed "s/\"//g")
72+
73+
if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
74+
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
75+
echo_error "Something went wrong generating Github release notes"
76+
echo $RESPONSE | jq --slurp '.[0]'
77+
exit 1
78+
fi
79+
80+
if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
81+
echo_error "Something went wrong generating Github release notes"
82+
echo $RESPONSE | jq --slurp '.[1]'
83+
exit 1
84+
fi
85+
fi
86+
else
87+
echo_warning "Dry run execution. Not generating Github release notes"
88+
fi
89+
90+
if [[ $APPLY == "true" ]]; then
91+
echo_info "Adding release notes to CHANGELOG.md"
92+
gsed -i "2 i\\\n## $RELEASE_NAME" CHANGELOG.md
93+
gsed -i "4 i\\\n$DESCRIPTION\n" CHANGELOG.md
94+
else
95+
echo_warning "Dry run execution. Not adding release notes to CHANGELOG.md"
96+
fi

scripts/release/github_release.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
3+
####
4+
# Utils
5+
####
6+
source ${BASH_SOURCE%/*}/utils.sh
7+
source ${BASH_SOURCE%/*}/github_utils.sh
8+
###
9+
10+
# 1. Get options
11+
12+
## Defaults
13+
APPLY="false"
14+
15+
while [[ $# -gt 0 ]]; do
16+
case $1 in
17+
-A|--apply)
18+
APPLY="true"
19+
shift # past argument
20+
;;
21+
-P|--previous-version-tag)
22+
PREV_TAG_VERSION="$2"
23+
shift # past argument
24+
shift # past value
25+
;;
26+
-V|--version)
27+
VERSION="$2"
28+
shift # past argument
29+
shift # past value
30+
;;
31+
-T|--github-token)
32+
GITHUB_TOKEN="$2"
33+
shift # past argument
34+
shift # past value
35+
;;
36+
-*|--*)
37+
echo "Unknown option $1"
38+
exit 1
39+
;;
40+
*)
41+
POSITIONAL_ARGS+=("$1") # save positional arg
42+
shift # past argument
43+
;;
44+
esac
45+
done
46+
47+
if [[ -z $GITHUB_TOKEN && apply == "true" ]]; then
48+
echo_error "Github token required (-T, --github-token)"
49+
exit 1
50+
fi
51+
52+
if [[ -z $PREV_TAG_VERSION ]]; then
53+
echo_error "Previous version tag required (-P, --previous-version-tag)"
54+
exit 1
55+
fi
56+
57+
if [[ -z $VERSION ]]; then
58+
echo_error "Version to release required (-V, --version)"
59+
exit 1
60+
fi
61+
62+
# 2. Github
63+
DATE=$(date +"%Y-%m-%d")
64+
RELEASE_NAME="$VERSION / $DATE"
65+
PREV_TAG_NAME=$PREV_TAG_VERSION
66+
TAG_NAME=v$VERSION
67+
68+
# 2.1 Create Git tag for the repository
69+
if [[ $APPLY == "true" ]]; then
70+
echo_info "Tagging repository"
71+
tag_repository $TAG_NAME
72+
else
73+
echo_warning "Dry run execution. Not tagging Github repo"
74+
fi
75+
76+
# 2.2. Generate release notes
77+
if [[ $APPLY == "true" ]]; then
78+
echo_info "Generating Github release notes"
79+
RESPONSE=$(generate_github_release_notes $GITHUB_TOKEN)
80+
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | gsed "s/\"//g")
81+
82+
if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
83+
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
84+
echo_error "Something went wrong generating Github release notes"
85+
echo $RESPONSE | jq --slurp '.[0]'
86+
exit 1
87+
fi
88+
89+
if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
90+
echo_error "Something went wrong generating Github release notes"
91+
echo $RESPONSE | jq --slurp '.[1]'
92+
exit 1
93+
fi
94+
fi
95+
else
96+
echo_warning "Dry run execution. Not generating Github release notes"
97+
fi
98+
99+
# 2.3 Create Github release
100+
if [[ $APPLY == "true" ]]; then
101+
echo_info "Generating Github release"
102+
create_github_release $GITHUB_TOKEN
103+
else
104+
echo_warning "Dry run execution. Not creating Github release"
105+
fi

scripts/release/github_utils.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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

Comments
 (0)