Skip to content

Commit 382fe2d

Browse files
authored
Add auto deployment to pypi (#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
1 parent a9055b9 commit 382fe2d

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Run tests & Publish Python 🐍 distributions 📦 to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
tests-ci:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
# you have to quote any version number ending in a 0 or gh truncates it. ie 3.10 turned into 3.1
14+
python-version: [ 3.6, 3.8, '3.10' ]
15+
os: [ ubuntu-latest ] #in the future we should add windows here
16+
runs-on: ${{ matrix.os }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: pip install
23+
run: |
24+
pip install -r requirements/requirements.txt
25+
pip install -r requirements/requirements_test.txt
26+
- name: run tests
27+
run: pytest .
28+
29+
build-n-publish:
30+
name: Build the 🐍 package and push PyPI
31+
runs-on: ubuntu-18.04
32+
needs: tests-ci
33+
steps:
34+
- uses: actions/checkout@master
35+
- name: Set up Python 3.9
36+
uses: actions/setup-python@v1
37+
with:
38+
python-version: '3.10'
39+
- name: Install pypa/build
40+
run: >-
41+
python -m
42+
pip install
43+
build
44+
--user
45+
- name: Build a binary wheel and a source tarball
46+
run: >-
47+
python -m
48+
build
49+
--sdist
50+
--wheel
51+
--outdir dist/
52+
.
53+
- name: Publish distribution 📦 to PyPI
54+
if: startsWith(github.ref, 'refs/tags')
55+
uses: pypa/gh-action-pypi-publish@master
56+
with:
57+
password: ${{ secrets.PYPI_API_TOKEN }}

tools/tag.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
VER_FILE="alpaca_trade_api/__init__.py"
4+
5+
# This script simply sets up the repo for a new tag
6+
echo "Current version number is: "
7+
8+
grep "__version__" $VER_FILE
9+
10+
11+
read -r -p "Please enter a new version number to bump to: " VERSION
12+
13+
echo -e "Updating init.py to $VERSION\n"
14+
15+
sed -i -e "s/__version__ = .*/__version__ = '$VERSION'/" $VER_FILE
16+
17+
read -r -n 1 -p "Would you like to git commit and tag now? (y/N): " YN
18+
19+
# there are better ways to get this in but 🤷
20+
echo ""
21+
22+
case $YN in
23+
y|Y )
24+
echo "Okay, committing this change";
25+
git commit -m "Version bump to $VERSION" -m "This commit was auto generated by a tool!"
26+
git tag -a "v$VERSION" -m "Version bump to $VERSION" -m "This tag was auto generated by a tool!"
27+
git tag --sort -refname | head -n 5
28+
echo "Done!"
29+
;;
30+
* )
31+
echo -e "Okay exiting now. $VER_FILE has still been edited to contain the new version\nFair warning!"
32+
exit 0
33+
;;
34+
esac

0 commit comments

Comments
 (0)