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

Commit

Permalink
Release/0.0.1 (#2)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
camfairchild authored Jul 5, 2023
1 parent 4bca1c3 commit 14c89ec
Show file tree
Hide file tree
Showing 13 changed files with 668 additions and 9 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

## 0.0.1 / 2023-06-27

## What's Changed
* Fix packaging issues by @camfairchild in https://github.com/opentensor/bittensor-wallet/pull/1

**Full Changelog**: https://github.com/opentensor/bittensor-wallet/compare/v0.0.0...v0.0.1


## 0.0.0 / 2023-06-26

### Initial release

**Full Changelog**: N/A
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BittensorWallet - v0.0.0
# BittensorWallet - v0.0.1

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

Expand All @@ -7,7 +7,7 @@ The purpose of this repo is to separate the concern of keyfile management from t
# Installation
This package can be installed from [PyPi.org](https://pypi.org/project/bittensor-wallet/):
```bash
pip install bittensor-wallet==0.0.0
pip install bittensor-wallet==0.0.1
```
or via this repo (using [gh-cli](https://cli.github.com/)):
```bash
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1
2 changes: 1 addition & 1 deletion bittensor_wallet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__version__ = "0.0.0"
__version__ = "0.0.1"
__ss58_format__ = 42 # Bittensor ss58 format

import argparse
Expand Down
2 changes: 1 addition & 1 deletion bittensor_wallet/_keyfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def __new__( cls, path: str = None ) -> 'keyfile_impl.Keyfile':
Path where this keypair is stored.
"""
path = '~/.bittensor/wallets/default/coldkey' if path == None else path
return keyfile_impl.Keyfile( path = path )
return keyfile_impl.Keyfile( path = path )
96 changes: 96 additions & 0 deletions scripts/release/add_notes_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

####
# Utils
####
source ${BASH_SOURCE%/*}/utils.sh
source ${BASH_SOURCE%/*}/github_utils.sh
###

# 1. Get options

## Defaults
APPLY="false"

while [[ $# -gt 0 ]]; do
case $1 in
-A|--apply)
APPLY="true"
shift # past argument
;;
-P|--previous-version-tag)
PREV_TAG_VERSION="$2"
shift # past argument
shift # past value
;;
-V|--version)
VERSION="$2"
shift # past argument
shift # past value
;;
-T|--github-token)
GITHUB_TOKEN="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done

if [[ -z $GITHUB_TOKEN && $APPLY == "true" ]]; then
echo_error "Github token required (-T, --github-token)"
exit 1
fi

if [[ -z $PREV_TAG_VERSION ]]; then
echo_error "Previous version tag required (-P, --previous-version-tag)"
exit 1
fi

if [[ -z $VERSION ]]; then
echo_error "Version to release required (-V, --version)"
exit 1
fi

DATE=$(date +"%Y-%m-%d")
RELEASE_NAME="$VERSION / $DATE"
TAG_NAME=v$VERSION
PREV_TAG_NAME=v$PREV_TAG_VERSION

# 2.2. Generate release notes
if [[ $APPLY == "true" ]]; then
echo_info "Generating Github release notes"
RESPONSE=$(generate_github_release_notes $GITHUB_TOKEN)
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | gsed "s/\"//g")

if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[0]'
exit 1
fi

if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[1]'
exit 1
fi
fi
else
echo_warning "Dry run execution. Not generating Github release notes"
fi

if [[ $APPLY == "true" ]]; then
echo_info "Adding release notes to CHANGELOG.md"
gsed -i "2 i\\\n## $RELEASE_NAME" CHANGELOG.md
gsed -i "4 i\\\n$DESCRIPTION\n" CHANGELOG.md
else
echo_warning "Dry run execution. Not adding release notes to CHANGELOG.md"
fi
105 changes: 105 additions & 0 deletions scripts/release/github_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

####
# Utils
####
source ${BASH_SOURCE%/*}/utils.sh
source ${BASH_SOURCE%/*}/github_utils.sh
###

# 1. Get options

## Defaults
APPLY="false"

while [[ $# -gt 0 ]]; do
case $1 in
-A|--apply)
APPLY="true"
shift # past argument
;;
-P|--previous-version-tag)
PREV_TAG_VERSION="$2"
shift # past argument
shift # past value
;;
-V|--version)
VERSION="$2"
shift # past argument
shift # past value
;;
-T|--github-token)
GITHUB_TOKEN="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done

if [[ -z $GITHUB_TOKEN && apply == "true" ]]; then
echo_error "Github token required (-T, --github-token)"
exit 1
fi

if [[ -z $PREV_TAG_VERSION ]]; then
echo_error "Previous version tag required (-P, --previous-version-tag)"
exit 1
fi

if [[ -z $VERSION ]]; then
echo_error "Version to release required (-V, --version)"
exit 1
fi

# 2. Github
DATE=$(date +"%Y-%m-%d")
RELEASE_NAME="$VERSION / $DATE"
PREV_TAG_NAME=$PREV_TAG_VERSION
TAG_NAME=v$VERSION

# 2.1 Create Git tag for the repository
if [[ $APPLY == "true" ]]; then
echo_info "Tagging repository"
tag_repository $TAG_NAME
else
echo_warning "Dry run execution. Not tagging Github repo"
fi

# 2.2. Generate release notes
if [[ $APPLY == "true" ]]; then
echo_info "Generating Github release notes"
RESPONSE=$(generate_github_release_notes $GITHUB_TOKEN)
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | gsed "s/\"//g")

if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[0]'
exit 1
fi

if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[1]'
exit 1
fi
fi
else
echo_warning "Dry run execution. Not generating Github release notes"
fi

# 2.3 Create Github release
if [[ $APPLY == "true" ]]; then
echo_info "Generating Github release"
create_github_release $GITHUB_TOKEN
else
echo_warning "Dry run execution. Not creating Github release"
fi
128 changes: 128 additions & 0 deletions scripts/release/github_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/bin/bash

####
# Utils
####
source ${BASH_SOURCE%/*}/utils.sh

#
# Params:
# - First positional argument: version of the tag
#
function tag_repository()
{
VERSION=$1

if [[ -z $VERSION ]]; then
echo_error "tag_repository needs VERSION"
exit 1
fi

git tag -a $VERSION -m "Release $VERSION"
git push origin --tags
}

#
# Params:
# - First positional argument: version of the tag
#
function remove_tag()
{
VERSION=$1

if [[ -z $VERSION ]]; then
echo_error "remove_tag needs VERSION"
exit 1
fi

git tag -d $VERSION
git push --delete origin $VERSION
}

#
# Needs:
# - TAG_NAME
# - PREV_TAG_NAME
# - RELEASE_NAME
#
function generate_github_release_notes_post_data()
{
cat <<EOF
{
"tag_name":"$TAG_NAME",
"previous_tag_name":"$PREV_TAG_NAME",
"name":"$RELEASE_NAME",
"draft":false,
"prerelease":false,
"generate_release_notes":false
}
EOF
}

#
# Needs:
# - TAG_NAME
# - PREV_TAG_NAME
# - RELEASE_NAME
#
function generate_github_release_post_data()
{
cat <<EOF
{
"tag_name":"$TAG_NAME",
"name":"$RELEASE_NAME",
"body":"$DESCRIPTION",
"draft":false,
"prerelease":false,
"generate_release_notes":false
}
EOF
}

#
# Params:
# - First positional argument: github access token
#
function generate_github_release_notes()
{
SECRET=$1

if [[ -z $SECRET ]]; then
echo_error "generate_github_release_notes needs SECRET"
exit 1
fi

curl --silent \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $SECRET" \
https://api.github.com/repos/opentensor/bittensor-wallet/releases/generate-notes \
--data "$(generate_github_release_notes_post_data)"
}

#
# Params:
# - github access token
#
# Needs:
# - function 'generate_github_release_post_data' to provide that request data
# - TAG_NAME which is created within the main github_release script
# - RELEASE_NAME which is created within the main github_release script
# - DESCRIPTION which is generated with a previous call of 'generate_github_release_notes'
#
function create_github_release()
{
SECRET=$1

if [[ -z $SECRET ]]; then
echo_error "create_github_release needs SECRET"
exit 1
fi

curl --silent \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $SECRET" \
https://api.github.com/repos/opentensor/bittensor-wallet/releases \
--data "$(generate_github_release_post_data)" > /dev/null
}
Loading

0 comments on commit 14c89ec

Please sign in to comment.