Skip to content

Commit 510ed7d

Browse files
authored
Update repository metadata (#86)
* Update repository metadata * Update repository metadata * Rename test workflow file * Update repository metadata * Update repository metadata
1 parent 72753e5 commit 510ed7d

6 files changed

Lines changed: 145 additions & 19 deletions

File tree

.github/workflows/publish.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Publish package
2+
3+
# based on https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
4+
5+
on:
6+
push:
7+
tags:
8+
- '*'
9+
- "!latest"
10+
11+
jobs:
12+
test-and-build:
13+
uses: ./.github/workflows/test.yml
14+
15+
check_version:
16+
name: Check version
17+
if: startsWith(github.ref, 'refs/tags/') # only publish on tag pushes
18+
needs: test-and-build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.13'
25+
- name: Read version from pyproject.toml
26+
run: echo VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") >> "$GITHUB_ENV"
27+
- run: echo $GITHUB_REF_NAME
28+
- run: echo $VERSION
29+
- name: Check that version and tag are identical
30+
run: test $GITHUB_REF_NAME = $VERSION
31+
32+
publish-to-pypi:
33+
name: Publish to PyPI
34+
if: startsWith(github.ref, 'refs/tags/') # only publish on tag pushes
35+
needs:
36+
- check_version
37+
runs-on: ubuntu-latest
38+
environment:
39+
name: pypi
40+
url: https://pypi.org/p/blaupause
41+
permissions:
42+
id-token: write
43+
steps:
44+
- name: Download all the dists
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
- name: Publish to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
52+
github-release:
53+
name: GitHub Release
54+
needs:
55+
- publish-to-pypi
56+
runs-on: ubuntu-latest
57+
permissions:
58+
contents: write # IMPORTANT: mandatory for making GitHub Releases
59+
id-token: write # IMPORTANT: mandatory for sigstore
60+
steps:
61+
- name: Download all the dists
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: python-package-distributions
65+
path: dist/
66+
- name: Sign the dists with Sigstore
67+
uses: sigstore/gh-action-sigstore-python@v3.0.0
68+
with:
69+
inputs: >-
70+
./dist/*.tar.gz
71+
./dist/*.whl
72+
- name: Create GitHub Release
73+
env:
74+
GITHUB_TOKEN: ${{ github.token }}
75+
run: >-
76+
gh release create
77+
"$GITHUB_REF_NAME"
78+
--repo "$GITHUB_REPOSITORY"
79+
--notes ""
80+
- name: Upload artifact signatures to GitHub Release
81+
env:
82+
GITHUB_TOKEN: ${{ github.token }}
83+
# Upload to GitHub Release using the `gh` CLI.
84+
# `dist/` contains the built packages, and the
85+
# sigstore-produced signatures and certificates.
86+
run: >-
87+
gh release upload
88+
"$GITHUB_REF_NAME" dist/**
89+
--repo "$GITHUB_REPOSITORY"
90+
91+
latest-tag:
92+
needs:
93+
- publish-to-pypi
94+
name: Update latest tag
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v4
99+
- name: Run latest-tag
100+
uses: EndBug/latest-tag@latest
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: workflow
1+
name: tests
22

33
on:
44
push:
@@ -7,50 +7,69 @@ on:
77
pull_request:
88
schedule:
99
- cron: '0 0 * * 1' # run every Monday
10+
workflow_call:
1011
workflow_dispatch:
1112

1213
env:
1314
PYTEST_ADDOPTS: "--color=yes"
1415

1516
jobs:
16-
workflow:
17+
tests:
1718
runs-on: ${{ matrix.os }}
1819
strategy:
1920
matrix:
2021
os: [ubuntu-latest, macos-13, windows-latest]
21-
python-version: ["3.8", "3.10"]
22+
python-version: ["3.13"]
23+
include:
24+
- os: ubuntu-latest
25+
python-version: "3.9"
2226
defaults:
2327
run:
2428
shell: bash -l {0}
25-
2629
steps:
2730
- name: Initialisation
2831
uses: actions/checkout@v4
29-
3032
- name: Set up conda
3133
uses: conda-incubator/setup-miniconda@v3
3234
with:
3335
python-version: ${{ matrix.python-version }}
3436
auto-update-conda: true
3537
activate-environment: conda-environment
3638
environment-file: .github/environment.yml
37-
3839
- name: Install package
3940
run: python -m pip install .[dev]
40-
4141
- name: Unit tests
4242
run: invoke test.unittest
43-
43+
if: matrix.os != 'ubuntu-latest'
4444
- name: Unit tests with coverage
4545
run: invoke test.coverage
4646
if: matrix.os == 'ubuntu-latest'
47-
4847
- name: Documentation tests
4948
run: invoke test.docs
50-
5149
- name: Jupyter notebook tests
5250
run: invoke test.ipynb
53-
5451
- name: Upload coverage to Codecov.io
5552
uses: codecov/codecov-action@v1
5653
if: matrix.os == 'ubuntu-latest'
54+
55+
build:
56+
needs: tests
57+
name: Build wheel and sdist
58+
runs-on: ubuntu-latest
59+
defaults:
60+
run:
61+
shell: bash -l {0}
62+
steps:
63+
- uses: actions/checkout@v2
64+
- uses: actions/setup-python@v5
65+
with:
66+
python-version: '3.13'
67+
- name: Install pypa/build
68+
run: python -m pip install --user build
69+
- name: Build wheel and source tarball
70+
run: python -m build
71+
- name: Store the distribution packages
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: python-package-distributions
75+
path: dist/

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ exclude: 'dev'
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.5.0
5+
rev: v5.0.0
66
hooks:
77
- id: check-merge-conflict # checks for files that contain merge conflict strings
88
- id: check-toml # checks toml files for parseable syntax
99
- id: debug-statements # checks for debugger imports and py37+ `breakpoint()` calls in python source
1010

1111
- repo: https://github.com/astral-sh/ruff-pre-commit
12-
rev: v0.4.4
12+
rev: v0.11.12
1313
hooks:
1414
# Run the linter.
1515
- id: ruff

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
| Description | Badge |
1313
| --- | --- |
14-
| Tests | [![Build status](https://github.com/ubermag/micromagneticdata/workflows/workflow/badge.svg)](https://github.com/ubermag/micromagneticdata/actions?query=workflow%3Aworkflow) |
14+
| Tests | [![tests](https://github.com/ubermag/micromagneticdata/actions/workflows/test.yml/badge.svg)](https://github.com/ubermag/micromagneticdata/actions/workflows/test.yml) |
1515
| Linting | [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ubermag/micromagneticdata/master.svg)](https://results.pre-commit.ci/latest/github/ubermag/micromagneticdata/master) |
1616
| | [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) |
1717
| Releases | [![PyPI version](https://badge.fury.io/py/micromagneticdata.svg)](https://badge.fury.io/py/micromagneticdata) |
@@ -72,7 +72,7 @@ Licensed under the BSD 3-Clause "New" or "Revised" License. For details, please
7272

7373
2. M. Beg, R. A. Pepper, and H. Fangohr. User interfaces for computational science: A domain specific language for OOMMF embedded in Python. [*AIP Advances* **7**, 56025](http://aip.scitation.org/doi/10.1063/1.4977225) (2017).
7474

75-
3. Marijan Beg, Martin Lang, Samuel Holt, Swapneel Amit Pathak, and Hans Fangohr. micromagneticdata: Python tools for the analysis of computational magnetism data DOI: [10.5281/zenodo.4624869](http://doi.org/10.5281/zenodo.4624869) (2023).
75+
3. Marijan Beg, Martin Lang, Samuel Holt, Swapneel Amit Pathak, and Hans Fangohr. micromagneticdata: Python tools for the analysis of computational magnetism data DOI: [10.5281/zenodo.4624869](http://doi.org/10.5281/zenodo.4624869) (2025).
7676

7777
## Acknowledgements
7878

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "micromagneticdata"
77
version = "0.65.3"
88
description = "Python tools for the analysis of computational magnetism data"
99
readme = "README.md"
10-
requires-python = ">=3.8"
10+
requires-python = ">=3.9"
1111
license = {file = "LICENSE"}
1212

1313
authors = [
@@ -46,7 +46,8 @@ dev = [
4646
"nbval",
4747
"pre-commit",
4848
"pytest-cov",
49-
"twine"
49+
"twine",
50+
"tomli; python_version < '3.11'",
5051
]
5152

5253
[project.urls]

tasks.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
import os
44
import shutil
5+
import sys
56

67
import pytest
7-
import tomli
8+
9+
if sys.version_info.minor < 11:
10+
import tomli as tomllib
11+
else:
12+
import tomllib
813
from invoke import Collection, Exit, task
914

1015
PYTHON = "python"
@@ -78,6 +83,7 @@ def build_dists(c):
7883
if os.path.exists("dist"):
7984
shutil.rmtree("dist")
8085
c.run(f"{PYTHON} -m build")
86+
c.run("twine check dist/*")
8187

8288

8389
@task(build_dists)
@@ -113,7 +119,7 @@ def release(c):
113119
raise e
114120

115121
with open("pyproject.toml", "rb") as f:
116-
version = tomli.load(f)["project"]["version"]
122+
version = tomllib.load(f)["project"]["version"]
117123

118124
c.run(f"git tag {version}") # fails if the tag exists
119125
c.run("git tag -f latest") # `latest` tag for binder

0 commit comments

Comments
 (0)