This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
4bca1c3
commit 14c89ec
Showing
13 changed files
with
668 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.