diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml new file mode 100644 index 0000000..9c1b696 --- /dev/null +++ b/.github/workflows/pypi-release.yml @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index b7d417f..22cdfcc 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,17 @@ test: # Style lint: - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics \ No newline at end of file + 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/* + diff --git a/axiom/pyproject.toml b/pyproject.toml similarity index 100% rename from axiom/pyproject.toml rename to pyproject.toml diff --git a/axiom/requirements.txt b/requirements.txt similarity index 85% rename from axiom/requirements.txt rename to requirements.txt index 2eb0152..be9cbda 100644 --- a/axiom/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ tabulate >= 0.8.9 dask >= 2022.8.1 distributed >= 2022.8.1 tqdm >= 4.64.1 -Jinja2 >= 3.1.2 \ No newline at end of file +Jinja2 >= 3.1.2 +importlib-metadata >= 6.6.0 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 90e2e3a..f23db5a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,7 +4,7 @@ author = Ben Schreoter author_email = ben.schroeter@csiro.au 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 = @@ -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