Skip to content

Commit

Permalink
Merge pull request #185 from phobson/clean-up-publishing
Browse files Browse the repository at this point in the history
try out better publishing GHAs
  • Loading branch information
phobson authored Feb 26, 2024
2 parents fb9121c + c126890 commit 6bec639
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 123 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ insert_final_newline = true
charset = utf-8
end_of_line = lf

[{*.yml,*.yaml,*.json}]
indent_style = space
indent_size = 2

[*.bat]
indent_style = tab
end_of_line = crlf
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/python-publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Publish Python 🐍 distribution 📦 to PyPI
on:
release:
types: [published]

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/paramnormal # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

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

## officially, the python docs want you pushing to TestPyPI
## after every merge and to PyPI with every tag. You push the
## tag, and then this GHA would do the release.
## In practice, I don't like this. You need to alter the version
## number with every PR to get a clean upload to TestPyPI.
##
## My approach is to only upload to TestPyPI with the tag push,
## and then to upload to PyPI with the GitHub release. And so
## I've commented out this sign & release workflow

# github-release:
# name: >-
# Sign the Python 🐍 distribution 📦 with Sigstore
# and upload them to GitHub Release
# needs:
# - publish-to-pypi
# runs-on: ubuntu-latest

# permissions:
# contents: write # IMPORTANT: mandatory for making GitHub Releases
# id-token: write # IMPORTANT: mandatory for sigstore

# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v3
# with:
# name: python-package-distributions
# path: dist/
# - name: Sign the dists with Sigstore
# uses: sigstore/[email protected]
# with:
# inputs: >-
# ./dist/*.tar.gz
# ./dist/*.whl
# - name: Create GitHub Release
# env:
# GITHUB_TOKEN: ${{ github.token }}
# run: >-
# gh release create
# '${{ github.ref_name }}'
# --repo '${{ github.repository }}'
# --notes ""
# - name: Upload artifact signatures to GitHub Release
# env:
# GITHUB_TOKEN: ${{ github.token }}
# # Upload to GitHub Release using the `gh` CLI.
# # `dist/` contains the built packages, and the
# # sigstore-produced signatures and certificates.
# run: >-
# gh release upload
# '${{ github.ref_name }}' dist/**
# --repo '${{ github.repository }}'
57 changes: 57 additions & 0 deletions .github/workflows/python-publish-testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish Python 🐍 distribution 📦 to TestPyPI

on:
push:
# Pattern matched against refs/tags
tags:
- '*' # Push events to every tag not containing /

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/


publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: test
url: https://test.pypi.org/p/paramnormal

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
117 changes: 0 additions & 117 deletions .github/workflows/python-publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion conda.recipes/dev/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: wqio
version: 0.6.0
version: 0.6.1

source:
path: ../../
Expand Down
4 changes: 2 additions & 2 deletions conda.recipes/release/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package:
name: wqio
version: "0.6.0"
version: "0.6.1"

source:
git_url: https://github.com/Geosyntec/wqio.git
git_tag: v0.6.0
git_tag: v0.6.1
# patches:
# List any patch files here
# - fix.patch
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DESCRIPTION = "wqio: Water Quality Inflow/Outflow"
LONG_DESCRIPTION = DESCRIPTION
NAME = "wqio"
VERSION = "0.6.0"
VERSION = "0.6.1"
AUTHOR = "Paul Hobson (Herrera Environmental Consultants)"
AUTHOR_EMAIL = "[email protected]"
URL = "https://github.com/International-BMP-Database/wqio"
Expand Down
12 changes: 10 additions & 2 deletions wqio/tests/test_validate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from datetime import datetime

import numpy
from matplotlib import pyplot
import pandas

import pytest
from matplotlib import pyplot

from wqio import validate
from wqio.tests import helpers
Expand Down Expand Up @@ -64,6 +63,15 @@ def test_axes_with_None():
assert isinstance(fig1, pyplot.Figure)


def test_axes_fallback_current():
fig, ax = pyplot.subplots()
fig1, ax1 = validate.axes(None, fallback="current")
assert isinstance(ax1, pyplot.Axes)
assert isinstance(fig1, pyplot.Figure)
assert ax1 is ax
assert fig1 is fig


@pytest.fixture
def multiindex_df():
dates = range(5)
Expand Down

0 comments on commit 6bec639

Please sign in to comment.