Skip to content

Commit

Permalink
Merge pull request #112 from AusClimateService/34-package-for-pip
Browse files Browse the repository at this point in the history
34 package for pip
  • Loading branch information
bschroeter authored Apr 29, 2023
2 parents ef412b3 + 2d76544 commit 4a5f14b
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 3 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Build and upload to PyPI

on:
release:
types:
- published

jobs:

build-artifacts:

runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install PyPi dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build tarball and wheels
run: |
git clean -xdf
git restore -SW .
python -m build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: releases
path: dist

publish_pypi_test:

needs: build-artifacts
runs-on: ubuntu-latest
environment:
name: release
url: https://test.pypi.org/project/acs-axiom
permissions:
id-token: write

steps:

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: releases
path: dist

- name: Install PyPi dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Check build artifacts
run: |
python -m twine check dist/*
pwd
if [ -f dist/axiom-0.0.0.tar.gz ]; then
echo "INVALID VERSION NUMBER"
exit 1
fi
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish_pypi_prod:

needs: publish_pypi_test
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/acs-axiom
permissions:
id-token: write

steps:

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: releases
path: dist

- name: Install PyPi dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Check build artifacts
run: |
python -m twine check dist/*
pwd
if [ -f dist/axiom-0.0.0.tar.gz ]; then
echo "INVALID VERSION NUMBER"
exit 1
fi
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@ test:

# Style
lint:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

# Build for PyPi
pypi_build:
python3 -m build

# Publish to PyPi (test)
test_pypi_publish: pypi_build
python3 -m twine upload --repository testpypi dist/*

# Publish to PyPi (production)
pypi_publish: pypi_build
python3 -m twine upload dist/*

File renamed without changes.
3 changes: 2 additions & 1 deletion axiom/requirements.txt → requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ tabulate >= 0.8.9
dask >= 2022.8.1
distributed >= 2022.8.1
tqdm >= 4.64.1
Jinja2 >= 3.1.2
Jinja2 >= 3.1.2
importlib-metadata >= 6.6.0
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author = Ben Schreoter
author_email = [email protected]
license = MIT
description = A prototype utility for validating/applying metadata templates for scientific data.
long_description = file: README.md
long_description = A prototype utility for validating/applying metadata templates for scientific data.

url = https://github.com/AusClimateService/axiom
classifiers =
Expand Down Expand Up @@ -34,6 +34,7 @@ install_requires =
distributed >= 2022.8.1
tqdm >= 4.64.1
Jinja2 >= 3.1.2
importlib-metadata >= 6.6.0

[aliases]
test = pytest
Expand Down

0 comments on commit 4a5f14b

Please sign in to comment.