Skip to content

Commit

Permalink
Try to use Git Action to Release and Publish Package (#12)
Browse files Browse the repository at this point in the history
* 📦 Update Actions for Build/Install/Test

Prepare for v0.3.5
  • Loading branch information
cuicaihao committed Mar 23, 2024
1 parent 68e0d3c commit 3484023
Show file tree
Hide file tree
Showing 12 changed files with 1,027 additions and 1,307 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/python-CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: SplitRaster Package Release and Publish

on:
push:
branches: [master]
tags:
- v*
pull_request:
branches: [master]
jobs:
format_and_check:
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 black flake8
- name: Format with Black
run: |
black --check .
build:
needs: format_and_check
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install setuptools
run: |
pip install setuptools wheel
- name: Build Python package
run: |
python setup.py sdist bdist_wheel
- name: Install Python Package
run: |
pip install dist/*.whl
- name: Test with pytest
run: |
pytest test.py -v
deploy:
needs: build
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 twine
run: |
python -m pip install --upgrade pip
pip install twine
- name: Upload to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m twine upload dist/*
release:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

deploy_docs:
needs: release
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 mkdocs
- name: Deploy to GitHub Pages
run: |
mkdocs gh-deploy --force
57 changes: 57 additions & 0 deletions .github/workflows/python-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: SplitRaster Developmnet Build Install and Test

on:
push:
branches: [develop]
pull_request:
branches: [develop]
jobs:
format_and_check:
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 black flake8
- name: Format with Black
run: |
black --check .
build:
needs: format_and_check
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install setuptools
run: |
pip install setuptools wheel
- name: Build Python package
run: |
python setup.py sdist bdist_wheel
- name: Install Python Package
run: |
pip install dist/*.whl
- name: Test with pytest
run: |
pytest test.py -v
31 changes: 0 additions & 31 deletions .github/workflows/python-app.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/python-publish.yml

This file was deleted.

7 changes: 2 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
repos:
# Run black
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
# Run unit test on mlcc library
- id: black
language_version: python3.9
# args: ["--config", "simple-cancer-prediction/linter/.black"]
# exclude: "(.*\\/)*(__init__\\.py|template\\/.*)"
language_version: python3.10
35 changes: 1 addition & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean data lint requirements sync_data_to_s3 sync_data_from_s3
.PHONY: clean data lint requirements test_environment help

#################################################################################
# GLOBALS #
Expand Down Expand Up @@ -54,39 +54,6 @@ gh-pages:
lint:
black src

# ## Upload Data to S3
# sync_data_to_s3:
# ifeq (default,$(PROFILE))
# aws s3 sync data/ s3://$(BUCKET)/data/
# else
# aws s3 sync data/ s3://$(BUCKET)/data/ --profile $(PROFILE)
# endif

# ## Download Data from S3
# sync_data_from_s3:
# ifeq (default,$(PROFILE))
# aws s3 sync s3://$(BUCKET)/data/ data/
# else
# aws s3 sync s3://$(BUCKET)/data/ data/ --profile $(PROFILE)
# endif

# ## Set up python interpreter environment
# create_environment:
# ifeq (True,$(HAS_CONDA))
# @echo ">>> Detected conda, creating conda environment."
# ifeq (3,$(findstring 3,$(PYTHON_INTERPRETER)))
# conda create --name $(PROJECT_NAME) python=3.8
# else
# conda create --name $(PROJECT_NAME) python=2.7
# endif
# @echo ">>> New conda env created. Activate with:\nsource activate $(PROJECT_NAME)"
# else
# $(PYTHON_INTERPRETER) -m pip install -q virtualenv virtualenvwrapper
# @echo ">>> Installing virtualenvwrapper if not already installed.\nMake sure the following lines are in shell startup file\n\
# export WORKON_HOME=$$HOME/.virtualenvs\nexport PROJECT_HOME=$$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n"
# @bash -c "source `which virtualenvwrapper.sh`;mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)"
# @echo ">>> New virtualenv created. Activate with:\nworkon $(PROJECT_NAME)"
# endif

## Test python environment is setup correctly
test_environment:
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ tqdm = "*"
numpy = "*"
scikit-image = "*"
splitraster = {editable = true, path = "."}
ipykernel = "*"

[dev-packages]
ipykernel = "*"
mkdocs = "*"
black = "*"
pre-commit = "*"
Expand All @@ -21,4 +21,4 @@ matplotlib = "*"
torchvision = "*"

[requires]
python_version = "3.9"
python_version = "3.10"

0 comments on commit 3484023

Please sign in to comment.