Skip to content

Update python-ci.yml #4

Update python-ci.yml

Update python-ci.yml #4

Workflow file for this run

name: Python CI/CD
on:
push:
branches:
- main # Change this to your default branch if it's not 'main'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests with pytest
run: pytest
bump_version:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install GitHub CLI
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh
- name: Bump version and create a pull request
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Create a new branch
git checkout -b bump-version
NEW_VERSION=$(python -c 'version = open("VERSION").read().strip().split("."); version[-1] = str(int(version[-1]) + 1); print(".".join(version))')
echo $NEW_VERSION > VERSION
git add VERSION
git commit -m "Bump version to $NEW_VERSION"
git push origin bump-version
# Create a pull request using GitHub CLI
gh pr create --base main --head bump-version --title "Bump version to $NEW_VERSION" --body "Automatic version bump to $NEW_VERSION"
create_release:
needs: bump_version
runs-on: ubuntu-latest
steps:
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
deploy-pypi:
needs: create_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install twine
run: pip install twine
- name: Build and Publish
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD
deploy-conda:
needs: create_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Conda
run: |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
source "$HOME/miniconda/etc/profile.d/conda.sh"
conda config --set always_yes yes --set changeps1 no
conda update -q conda
- name: Build and Publish to Anaconda
env:
ANACONDA_USERNAME: ${{ secrets.ANACONDA_USERNAME }}
ANACONDA_PASSWORD: ${{ secrets.ANACONDA_PASSWORD }}
run: |
conda build .
anaconda login --user $ANACONDA_USERNAME --password $ANACONDA_PASSWORD
anaconda upload $HOME/miniconda/conda-bld/**/artifician*.tar.bz2