-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6827ec1
commit c698c5f
Showing
4 changed files
with
80 additions
and
4 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,72 @@ | ||
name: Build and Publish bittensor-cli | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to release' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build: | ||
name: Build Python distribution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build wheel twine | ||
- name: Build package | ||
run: python setup.py sdist bdist_wheel | ||
|
||
- name: Check if package version already exists | ||
run: | | ||
PACKAGE_NAME=$(python setup.py --name) | ||
PACKAGE_VERSION=${{ github.event.inputs.version }} | ||
if twine check dist/*; then | ||
if pip install $PACKAGE_NAME==$PACKAGE_VERSION; then | ||
echo "Error: Version $PACKAGE_VERSION of $PACKAGE_NAME already exists on PyPI" | ||
exit 1 | ||
else | ||
echo "Version $PACKAGE_VERSION of $PACKAGE_NAME does not exist on PyPI. Proceeding with upload." | ||
fi | ||
else | ||
echo "Error: Twine check failed." | ||
exit 1 | ||
fi | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
approve-and-publish: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: release | ||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
verbose: true | ||
print-hash: true |
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