Skip to content

Commit b8037d2

Browse files
authored
publish to PyPI (#48)
* talk only about the package in the readme * delete the action * lower-pin the versions * lint for python 3.11 * register as a script * rename the project * add zizmor * autoupdate hooks * add a cooldown to dependabot * follow `zizmor`'s recommendations * remove the e2e tests * replace `setup-python` + pip with `setup-uv` * workflow to publish to pypi * ignore the lock file * add a readme
1 parent 3db8e1c commit b8037d2

File tree

9 files changed

+159
-241
lines changed

9 files changed

+159
-241
lines changed

.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
# Check for updates once a week
77
interval: "weekly"
8+
cooldown:
9+
default-days: 7

.github/workflows/ci.yml

Lines changed: 7 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111

12+
permissions: {}
13+
1214
jobs:
1315
ci:
1416
name: tests
@@ -21,106 +23,12 @@ jobs:
2123
steps:
2224
- name: clone the repository
2325
uses: actions/checkout@v6
24-
- name: setup python
25-
uses: actions/setup-python@v6
26+
with:
27+
persist-credentials: false
28+
- name: setup environment
29+
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # 7.1.6
2630
with:
2731
python-version: "${{ matrix.python-version }}"
28-
- name: upgrade pip
29-
run: |
30-
python -m pip install --upgrade pip
31-
- name: install dependencies
32-
run: |
33-
python -m pip install -r requirements.txt
34-
python -m pip install .
35-
python -m pip install pytest
3632
- name: run tests
3733
run: |
38-
python -m pytest -rf
39-
40-
e2e:
41-
name: end-to-end
42-
runs-on: [ubuntu-latest]
43-
44-
strategy:
45-
fail-fast: false
46-
matrix:
47-
envs:
48-
- "envs/env1.yaml"
49-
- "envs/env2.yaml"
50-
- |
51-
envs/env1.yaml
52-
envs/env2.yaml
53-
expected-failure: ["false"]
54-
policy-file: ["policy.yaml"]
55-
include:
56-
- envs: |
57-
envs/failing-env1.yaml
58-
policy-file: "policy.yaml"
59-
expected-failure: "true"
60-
- envs: |
61-
envs/env1.yaml
62-
envs/failing-env1.yaml
63-
policy-file: "policy.yaml"
64-
expected-failure: "true"
65-
- envs: "envs/env1.yaml"
66-
policy-file: "policy_no_extra_options.yaml"
67-
expected-failure: "false"
68-
- envs: "pixi:env1"
69-
manifest-path: "envs/pixi.toml"
70-
policy-file: "policy.yaml"
71-
expected-failure: "false"
72-
- envs: |
73-
pixi:env1
74-
pixi:env2
75-
manifest-path: "envs/pixi.toml"
76-
policy-file: "policy.yaml"
77-
expected-failure: "false"
78-
- envs: |
79-
pixi:env1
80-
conda:envs/env2.yaml
81-
manifest-path: "envs/pixi.toml"
82-
policy-file: "policy.yaml"
83-
expected-failure: "false"
84-
- envs: "pixi:failing-env"
85-
manifest-path: "envs/pixi.toml"
86-
policy-file: "policy.yaml"
87-
expected-failure: "true"
88-
89-
steps:
90-
- name: clone the repository
91-
uses: actions/checkout@v6
92-
- name: run action
93-
uses: ./
94-
id: action-run
95-
continue-on-error: true
96-
with:
97-
policy: ${{ matrix.policy-file }}
98-
environments: ${{ matrix.envs }}
99-
today: 2024-12-20
100-
manifest-path: ${{ matrix.manifest-path }}
101-
- name: detect outcome
102-
if: always()
103-
shell: bash -l {0}
104-
run: |
105-
if [[ "${{ steps.action-run.outcome }}" == "success" && ${{ matrix.expected-failure }} == "true" ]]; then
106-
# unexpected pass
107-
echo "workflow xpassed"
108-
export STATUS=1
109-
elif [[ "${{ steps.action-run.outcome }}" == "failure" && ${{ matrix.expected-failure }} == "false" ]]; then
110-
# unexpected failure
111-
echo "workflow failed"
112-
export STATUS=2
113-
elif [[ "${{ steps.action-run.outcome }}" == "success" && ${{ matrix.expected-failure }} == "false" ]]; then
114-
# normal pass
115-
echo "workflow passed"
116-
export STATUS=0
117-
elif [[ "${{ steps.action-run.outcome }}" == "failure" && ${{ matrix.expected-failure }} == "true" ]]; then
118-
# expected failure
119-
echo "workflow xfailed"
120-
export STATUS=0
121-
else
122-
# cancelled
123-
echo "workflow cancelled"
124-
export STATUS=3
125-
fi
126-
exit $STATUS
34+
uv run -m pytest -rf --cov=minimum_versions

.github/workflows/pypi.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions: {}
8+
9+
jobs:
10+
build:
11+
name: Build packages
12+
runs-on: ubuntu-latest
13+
if: github.owner == 'xarray-contrib'
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
with:
18+
fetch-depth: 0
19+
persist-credentials: false
20+
- name: Set up Python
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version: "3.x"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install build twine
28+
- name: Build
29+
run: |
30+
python -m build --outdir dist/ .
31+
- name: Check the built archives
32+
run: |
33+
twine check dist/*
34+
pip install dist/*.whl
35+
minimum-versions --help
36+
- name: Upload build artifacts
37+
uses: actions/upload-artifact@v5
38+
with:
39+
name: packages
40+
path: dist/*
41+
42+
publish:
43+
name: Upload to PyPI
44+
runs-on: ubuntu-latest
45+
needs: build
46+
if: github.event_name == 'release'
47+
48+
environment:
49+
name: pypi
50+
url: https://pypi.org/p/xarray-minimum-dependency-policy
51+
permissions:
52+
id-token: write
53+
54+
steps:
55+
- name: Download build artifacts
56+
uses: actions/download-artifact@v6
57+
with:
58+
name: packages
59+
path: dist/
60+
61+
- name: Publish to PyPI
62+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
63+
with:
64+
verify_metadata: true
65+
verbose: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
__pycache__/
44
.coverage
5+
6+
uv.lock

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ repos:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- repo: https://github.com/psf/black-pre-commit-mirror
8-
rev: 25.11.0
8+
rev: 25.12.0
99
hooks:
1010
- id: black
1111
- repo: https://github.com/astral-sh/ruff-pre-commit
12-
rev: v0.14.7
12+
rev: v0.14.10
1313
hooks:
1414
- id: ruff
1515
args: ["--fix"]
1616
- repo: https://github.com/rbubley/mirrors-prettier
17-
rev: v3.7.3
17+
rev: v3.7.4
1818
hooks:
1919
- id: prettier
2020
args: ["--cache-location=.prettier_cache"]
@@ -29,6 +29,10 @@ repos:
2929
rev: v0.24.1
3030
hooks:
3131
- id: validate-pyproject
32+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
33+
rev: v1.19.0
34+
hooks:
35+
- id: zizmor
3236

3337
ci:
3438
autofix_prs: true

0 commit comments

Comments
 (0)