Feature logging #9
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
name: Build and Test Python Package | |
on: | |
pull_request: | |
branches: | |
- '**' # Triggers on all branches with open PRs | |
push: | |
branches: | |
- master # Triggers on pushes to the main branch | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
pip install setuptools wheel | |
pip install -r requirements.txt | |
- name: Get current version | |
id: get_version | |
run: | | |
VERSION=$(python -c "from version import __version__; print(__version__)") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Build the package | |
run: | | |
python setup.py sdist bdist_wheel | |
# - name: Run tests | |
# run: | | |
# pip install pytest | |
# pytest | |
publish-and-tag: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
pip install setuptools wheel | |
pip install -r requirements.txt | |
- name: Build the package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
pip install twine | |
twine upload dist/* | |
- name: Create Git tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }} | |
git tag -a v${{ env.VERSION }} -m "Release version ${{ env.VERSION }}" | |
git push origin v${{ env.VERSION }} |