Skip to content

Commit

Permalink
Merge pull request #90 from MetOffice/packaging
Browse files Browse the repository at this point in the history
Package on PyPI.
  • Loading branch information
jfrost-mo authored Apr 24, 2023
2 parents c1c06f6 + 126a671 commit 9067157
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 3 deletions.
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: Publish packages

on:
release:
types: [released]

# Allow only one concurrent deployment
concurrency:
group: "release"
cancel-in-progress: false

jobs:
build-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install dependencies
run: python3 -m pip install tox tox-conda

- uses: actions/cache@v3
with:
key: tox|build-package|${{ runner.os }}-${{ runner.arch}}|${{ hashFiles('requirements/locks/*') }}
path: .tox

- name: Build package
run: tox -e build-package

- uses: actions/upload-artifact@v3
with:
name: packages
path: dist/
retention-days: 10
if-no-files-found: error

pypi-publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build-package
environment:
name: release
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: packages
path: dist/

# External actions are disabled via organization policies therefore we
# must instead manually implement it.
# https://docs.pypi.org/trusted-publishers/using-a-publisher/#the-manual-way
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1

- uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install dependencies
run: python -m pip install twine

- name: Check package metadata
run: python -m twine check --strict dist/*

- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: python3 -m twine upload --disable-progress-bar --verbose --non-interactive dist/*
Binary file added docs/source/working-practices/release_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions docs/source/working-practices/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,34 @@ Some things to consider:
* How long depreciation periods should be for different sizes of change.
* How the changes will be communicated with users.
* Guidance on avoiding making backwards incompatible changes where possible.

Making a Release
----------------

Making a release is mostly automated. The only thing that needs to be done in
the code is to ensure that the version number in ``pyproject.toml`` has been
incremented since the last release.

To create a release you should use the GitHub web UI. Go to the `Releases`_
page, and press `Draft a new release`_.

.. image:: release_page.png
:alt: The GitHub release making page.

On this page you will need to add several things.

* A human readable release title, which should include the version number.
* The target branch to create the release from. (This might be ``main`` most of
the time.)
* A tag, which should be the version number prefixed with the letter ``v``. For
example version 1.2.3 should have the tag ``v1.2.3``.
* A description of the changes in the release. Pressing the "Generate release
notes" button will include the titles of all merged pull requests, which is a
good starting point. It is especially important to highlight any changes that
might break backwards compatibility.

Once that is all written you simply need to press "Publish release". A release
will be automatically made, and the package will be pushed to PyPI and beyond.

.. _Releases: https://github.com/MetOffice/CSET/releases
.. _Draft a new release: https://github.com/MetOffice/CSET/releases/new
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "CSET"
version = "0.0.2"
version = "0.1.0"
description = "Convective Scale Evaluation Tool for evaluation and investigation of regional models."
authors = [{ name = "Met Office" }, { name = "NIWA" }]
readme = "README.md"
license = { file = "LICENCE" }
license = { text = "Apache-2.0" }
requires-python = ">=3.8"
classifiers = [
"License :: OSI Approved :: Apache Software License",
Expand Down Expand Up @@ -92,6 +92,12 @@ conda_spec =
usedevelop = true
commands = sphinx-build -d "docs/build/doctree" docs/source "docs/build/html" --color -W -bhtml {posargs}
[testenv:build-package]
description = Build sdist and wheel packages.
deps = build
skip_install = true
commands = python3 -m build
[testenv:coverage-clean]
deps = coverage
skip_install = true
Expand Down
2 changes: 1 addition & 1 deletion src/CSET/operators/RECIPES/extract_instant_air_temp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Extracts out the instantaneous 1.5m air temperature from a file and writes it
to a new one.
"""
section = "Grid Stat"
major_cat ="Major Category 1"
major_cat = "Major Category 1"
minor_cat = "Minor Category 1"

[[steps]]
Expand Down

0 comments on commit 9067157

Please sign in to comment.