Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up automated package build and release to PyPI & GitHub #275

Merged
merged 13 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
name: build-package-release

on: [push, pull_request]

jobs:
build:
name: Build Python Distribution
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Build source and wheel distributions
run: |
python -m pip install --upgrade build twine
python -m build
twine check --strict dist/*
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

pypi-publish:
name: Upload release to Test PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/catalystcoop.cheshire
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-publish:
name: Release package on GitHub
needs:
- pypi-publish
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign dist with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.0.1
with:
inputs: ./dist/*.tar.gz ./dist/*.whl
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create '${{ github.ref_name }}' ./dist/*.tar.gz ./dist/*.whl
--generate-notes
--repo '${{ github.repository }}'
19 changes: 0 additions & 19 deletions .github/workflows/repo2docker.yml

This file was deleted.

28 changes: 16 additions & 12 deletions .github/workflows/tox-pytest.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: tox-pytest

on: [push, pull_request]
Expand All @@ -7,25 +8,28 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11"]
fail-fast: false
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up conda environment for testing
uses: conda-incubator/setup-miniconda@v2.2.0
uses: mamba-org/setup-micromamba@v1
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
python-version: ${{ matrix.python-version }}
activate-environment: cheshire
environment-file: environment.yml
cache-environment: true
condarc: |
channels:
- conda-forge
- defaults
channel_priority: strict

- shell: bash -l {0}
run: |
conda info
Expand All @@ -45,10 +49,10 @@ jobs:

- name: Run PyTest with Tox
run: |
conda run -n cheshire tox
tox

- name: Upload test coverage report to CodeCov
uses: codecov/codecov-action@v3.1.4
uses: codecov/codecov-action@v3

ci-notify:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Catalyst specific files
*.swp
commit.txt
**~

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ channels:
dependencies:
# Packages required for setting up the environment
- pip>=21,<24
- python>=3.8,<3.12
- setuptools>=66,<68
- python>=3.10,<3.12
- setuptools>=66,<69

# Packages specified in setup.py that need or benefit from binary conda packages
# - geopandas>=0.9,<0.11
Expand Down
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=66,<68",
"setuptools>=66,<69",
"setuptools_scm[toml]>=3.5.0",
"wheel",
]
Expand All @@ -14,11 +14,11 @@ readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [
{name = "Catalyst Cooperative", email = "pudl@catalyst.coop"}
]
requires-python = ">=3.8,<3.12"
requires-python = ">=3.10,<3.12"
dynamic = ["version"]
license = {file = "LICENSE.txt"}
dependencies = [
"pandas>=1.5,<3.0",
"pandas>=1.5,<2.2",
"sqlalchemy>=1.4,<3.0",
]
classifiers = [
Expand All @@ -30,8 +30,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
Expand All @@ -49,7 +47,7 @@ winston = "cheshire.cli:main"

[project.optional-dependencies]
dev = [
"build>=0.10,<1.1", # The setuptools package builder
"build>=1.0,<1.1", # The setuptools package builder
"black>=22.0,<23.10", # A deterministic code formatter
"isort>=5.0,<5.13", # Standardized import sorting
"tox>=4.0,<4.12", # Python test environment manager
Expand Down Expand Up @@ -102,7 +100,7 @@ where = ["src"]

[tool.black]
line-length = 88
target-version = ["py38", "py39", "py310", "py311"]
target-version = ["py310", "py311"]
include = "\\.pyi?$"

[tool.isort]
Expand Down
112 changes: 0 additions & 112 deletions setup.py

This file was deleted.

35 changes: 0 additions & 35 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -148,41 +148,6 @@ commands =
{[testenv:integration]commands}
{[testenv]covreport}

#######################################################################################
# Software Package Build & Release
#######################################################################################
[testenv:build]
description = Prepare Python source and binary packages for release.
basepython = python3
skip_install = false
extras =
dev
commands =
bash -c 'rm -rf build/* dist/* src/*.egg-info'
python -m build

[testenv:testrelease]
description = Do a dry run of Python package release using the PyPI test server.
basepython = python3
skip_install = false
extras =
dev
commands =
{[testenv:build]commands}
twine check dist/*
twine upload --verbose --repository testpypi --skip-existing dist/*

[testenv:release]
description = Release the package to the production PyPI server.
basepython = python3
skip_install = false
extras =
dev
commands =
{[testenv:build]commands}
twine check dist/*
twine upload --verbose --skip-existing dist/*

#######################################################################################
# Configuration for various tools.
#######################################################################################
Expand Down