forked from alpacahq/alpaca-trade-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto deployment to pypi (alpacahq#612)
* Add initial workflow file for tagged releases * Fix yaml spacing * temp change trigger type to test * Attempt to fix python 3.10 being turned into 3.1 * Attempt build package run * Add tool to auto bump and tag version * Change trigger back to tag, and add publish step * add v prefix to created tags
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 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,57 @@ | ||
name: Run tests & Publish Python 🐍 distributions 📦 to PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
tests-ci: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# you have to quote any version number ending in a 0 or gh truncates it. ie 3.10 turned into 3.1 | ||
python-version: [ 3.6, 3.8, '3.10' ] | ||
os: [ ubuntu-latest ] #in the future we should add windows here | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: pip install | ||
run: | | ||
pip install -r requirements/requirements.txt | ||
pip install -r requirements/requirements_test.txt | ||
- name: run tests | ||
run: pytest . | ||
|
||
build-n-publish: | ||
name: Build the 🐍 package and push PyPI | ||
runs-on: ubuntu-18.04 | ||
needs: tests-ci | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.10' | ||
- name: Install pypa/build | ||
run: >- | ||
python -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: >- | ||
python -m | ||
build | ||
--sdist | ||
--wheel | ||
--outdir dist/ | ||
. | ||
- name: Publish distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
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,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
VER_FILE="alpaca_trade_api/__init__.py" | ||
|
||
# This script simply sets up the repo for a new tag | ||
echo "Current version number is: " | ||
|
||
grep "__version__" $VER_FILE | ||
|
||
|
||
read -r -p "Please enter a new version number to bump to: " VERSION | ||
|
||
echo -e "Updating init.py to $VERSION\n" | ||
|
||
sed -i -e "s/__version__ = .*/__version__ = '$VERSION'/" $VER_FILE | ||
|
||
read -r -n 1 -p "Would you like to git commit and tag now? (y/N): " YN | ||
|
||
# there are better ways to get this in but 🤷 | ||
echo "" | ||
|
||
case $YN in | ||
y|Y ) | ||
echo "Okay, committing this change"; | ||
git commit -m "Version bump to $VERSION" -m "This commit was auto generated by a tool!" | ||
git tag -a "v$VERSION" -m "Version bump to $VERSION" -m "This tag was auto generated by a tool!" | ||
git tag --sort -refname | head -n 5 | ||
echo "Done!" | ||
;; | ||
* ) | ||
echo -e "Okay exiting now. $VER_FILE has still been edited to contain the new version\nFair warning!" | ||
exit 0 | ||
;; | ||
esac |