Skip to content

Commit ebe2bb5

Browse files
authored
Merge pull request #151 from python-astrodynamics/feature/modernize-packaging
Modernize packaging
2 parents 3903724 + f06fae3 commit ebe2bb5

13 files changed

Lines changed: 325 additions & 94 deletions

File tree

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ updates:
55
schedule:
66
interval: daily
77
open-pull-requests-limit: 1024
8+
cooldown:
9+
default-days: 7

.github/workflows/ci.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,25 @@ env:
1717
UV_NO_SYNC: "true"
1818

1919
jobs:
20-
pre-commit:
21-
name: "pre-commit"
20+
lint:
21+
name: "lint"
2222
runs-on: ubuntu-latest
2323

2424
steps:
25-
- uses: "actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10" # v6.0.3
25+
- uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" # v7.0.1
2626
with:
2727
persist-credentials: false
28-
- uses: "j178/prek-action@bdca6f102f98e2b4c7029491a53dfd366469e33d" # v2.0.4
28+
- uses: "actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97" # v7.0.0
29+
with:
30+
python-version: "3.12"
31+
- uses: "astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9" # v9.0.0
32+
with:
33+
enable-cache: true
34+
- uses: "j178/prek-action@5337cb91e0fa35a7ff31b9ca345126d8bbbcdf16" # v2.0.6
35+
- name: "Check source distribution contents"
36+
run: |
37+
uv sync --only-group check-sdist
38+
uv run check-sdist
2939
3040
tests:
3141
name: "Python ${{ matrix.python-version }}"
@@ -37,41 +47,41 @@ jobs:
3747
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
3848

3949
steps:
40-
- uses: "actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10" # v6.0.3
50+
- uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" # v7.0.1
4151
with:
4252
persist-credentials: false
43-
- uses: "actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405" # v6.2.0
53+
- uses: "actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97" # v7.0.0
4454
with:
4555
python-version: "${{ matrix.python-version }}"
4656
allow-prereleases: true
47-
- uses: "astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39" # v8.2.0
57+
- uses: "astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9" # v9.0.0
4858
with:
4959
enable-cache: true
5060
- name: "Install dependencies"
5161
run: |
5262
python -VV
5363
python -m site
5464
uv --version
55-
uv sync --only-group nox --only-group coverage
65+
uv sync --only-group nox --only-group coverage --no-install-project
5666
- name: "Run nox targets for ${{ matrix.python-version }}"
5767
run: "uv run nox --python ${{ matrix.python-version }}"
5868
- name: "Convert coverage"
5969
run: |
6070
uv run coverage combine
6171
uv run coverage xml
6272
- name: "Upload coverage to Codecov"
63-
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
73+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
6474
with:
6575
fail_ci_if_error: true
6676
token: ${{ secrets.CODECOV_TOKEN }}
6777

68-
required:
78+
alls-green:
6979
name: "all required checks passed"
7080
runs-on: "ubuntu-latest"
7181
if: always()
7282

7383
needs:
74-
- pre-commit
84+
- lint
7585
- tests
7686

7787
steps:

.github/workflows/publish.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Upload Python Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: publish
16+
url: https://pypi.org/p/spacetrack
17+
permissions:
18+
contents: read
19+
id-token: write
20+
attestations: write
21+
steps:
22+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23+
with:
24+
persist-credentials: false
25+
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
26+
with:
27+
enable-cache: false
28+
- name: Set up Python
29+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
30+
with:
31+
python-version: "3.x"
32+
- name: Build
33+
run: "uv build"
34+
- name: Publish
35+
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
36+
37+
release:
38+
needs: deploy
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: write
42+
steps:
43+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
44+
with:
45+
persist-credentials: false
46+
- name: Extract release notes
47+
run: |
48+
awk -v version="$GITHUB_REF_NAME" '
49+
index($0, "/releases/tag/" version ">`_ - ") { found = 1; skip_underline = 1; next }
50+
found && skip_underline { skip_underline = 0; next }
51+
found && /^[0-9][^ ]*_ - [0-9]{4}-[0-9]{2}-[0-9]{2}$/ { exit }
52+
found && /\/releases\/tag\/[^>]+>`_ - [0-9]{4}-[0-9]{2}-[0-9]{2}$/ { exit }
53+
found { print }
54+
END { if (!found) exit 1 }
55+
' docs/changelog.rst > release-notes.rst
56+
grep -q '[^[:space:]]' release-notes.rst
57+
- name: Create GitHub Release
58+
run: |
59+
gh release create "$GITHUB_REF_NAME" \
60+
--verify-tag \
61+
--title "$GITHUB_REF_NAME" \
62+
--notes-file release-notes.rst
63+
env:
64+
GH_TOKEN: ${{ github.token }}

.github/workflows/python-publish.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

MANIFEST.in

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ spacetrack
33

44
|PyPI Version| |Documentation| |CI Status| |Coverage| |Python Version| |MIT License|
55

6-
spacetrack is a python module for `Space-Track <https://www.space-track.org>`__
6+
spacetrack is a Python client for `Space-Track <https://www.space-track.org>`__.
77

88
Installation
99
~~~~~~~~~~~~
@@ -63,22 +63,22 @@ Documentation
6363
~~~~~~~~~~~~~
6464

6565
For in-depth information, `visit the
66-
documentation <http://spacetrack.readthedocs.org/en/latest/>`__!
66+
documentation <https://spacetrack.readthedocs.io/en/latest/>`__!
6767

6868
Development
6969
~~~~~~~~~~~
7070

71-
spacetrack uses `semantic versioning <http://semver.org>`__
72-
73-
.. |CI Status| image:: https://github.com/python-astrodynamics/spacetrack/workflows/CI/badge.svg?branch=master
74-
:target: https://github.com/python-astrodynamics/spacetrack/actions?workflow=CI
75-
.. |PyPI Version| image:: http://img.shields.io/pypi/v/spacetrack.svg?style=flat-square
76-
:target: https://pypi.python.org/pypi/spacetrack/
77-
.. |Python Version| image:: https://img.shields.io/badge/python-3.6%2B-brightgreen.svg?style=flat-square
78-
:target: https://www.python.org/downloads/
79-
.. |MIT License| image:: http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
80-
:target: https://raw.githubusercontent.com/python-astrodynamics/spacetrack/master/LICENSE.txt
81-
.. |Coverage| image:: https://img.shields.io/codecov/c/github/python-astrodynamics/spacetrack/master.svg?style=flat-square
82-
:target: https://codecov.io/github/python-astrodynamics/spacetrack?branch=master
83-
.. |Documentation| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat-square
84-
:target: http://spacetrack.readthedocs.org/en/latest/
71+
spacetrack uses `semantic versioning <https://semver.org>`__.
72+
73+
.. |CI Status| image:: https://github.com/python-astrodynamics/spacetrack/actions/workflows/ci.yml/badge.svg?branch=main
74+
:target: https://github.com/python-astrodynamics/spacetrack/actions/workflows/ci.yml
75+
.. |PyPI Version| image:: https://img.shields.io/pypi/v/spacetrack.svg?style=flat-square
76+
:target: https://pypi.org/project/spacetrack/
77+
.. |Python Version| image:: https://img.shields.io/pypi/pyversions/spacetrack.svg?style=flat-square
78+
:target: https://pypi.org/project/spacetrack/
79+
.. |MIT License| image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
80+
:target: https://raw.githubusercontent.com/python-astrodynamics/spacetrack/main/LICENSE.txt
81+
.. |Coverage| image:: https://codecov.io/gh/python-astrodynamics/spacetrack/branch/main/graph/badge.svg
82+
:target: https://codecov.io/gh/python-astrodynamics/spacetrack
83+
.. |Documentation| image:: https://readthedocs.org/projects/spacetrack/badge/?version=latest
84+
:target: https://spacetrack.readthedocs.io/en/latest/

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Change Log
22
==========
33

4+
.. towncrier release notes start
5+
46
1.4.0_ - 2025-02-21
57
-------------------
68

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Modernize the packaging, test, documentation, and release tooling.

newsfragments/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.gitignore

noxfile.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from collections.abc import Iterator
2+
from contextlib import contextmanager
3+
14
import nox
25

36
nox.options.reuse_existing_virtualenvs = True
@@ -36,3 +39,42 @@ def tests(session: nox.Session) -> None:
3639
)
3740

3841
session.run("coverage", "run", "-m", "pytest", *session.posargs)
42+
43+
44+
@nox.session(name="test-min-deps", python=PYTHON_VERSIONS)
45+
def test_min_deps(session: nox.Session) -> None:
46+
with restore_file("uv.lock"):
47+
session.run_install(
48+
"uv",
49+
"sync",
50+
"--no-default-groups",
51+
"--group=test",
52+
"--resolution=lowest-direct",
53+
)
54+
55+
session.run("pytest", *session.posargs)
56+
57+
58+
@nox.session(name="test-latest", python=PYTHON_VERSIONS)
59+
def test_latest(session: nox.Session) -> None:
60+
session.run_install(
61+
"uv",
62+
"sync",
63+
"--no-default-groups",
64+
"--group=test",
65+
"--no-install-project",
66+
)
67+
session.run_install("uv", "pip", "install", "--upgrade", ".")
68+
69+
session.run("pytest", *session.posargs)
70+
71+
72+
@contextmanager
73+
def restore_file(path: str) -> Iterator[None]:
74+
with open(path, "rb") as f:
75+
original = f.read()
76+
try:
77+
yield
78+
finally:
79+
with open(path, "wb") as f:
80+
f.write(original)

0 commit comments

Comments
 (0)