Skip to content

Commit 1d0de65

Browse files
authored
Add a GitHub Action to publish releases on PyPI (#65)
* dependabot GHA updates * add GHA PyPI * simplify and cleanup * try to restrict linting to py310
1 parent cea8764 commit 1d0de65

File tree

3 files changed

+80
-30
lines changed

3 files changed

+80
-30
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/keeping-your-actions-up-to-date-with-dependabot
2+
3+
version: 2
4+
updates:
5+
6+
- package-ecosystem: "github-actions"
7+
directory: "/"
8+
schedule:
9+
interval: "daily"
10+
labels:
11+
- "Bot"
12+
groups:
13+
github-actions:
14+
patterns:
15+
- '*'

.github/workflows/pypi.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
pull_request:
5+
push:
6+
release:
7+
types:
8+
- published
9+
10+
jobs:
11+
pypi-publish:
12+
name: Upload release to PyPI
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: pypi
16+
url: https://pypi.org/p/xarray_subset_grid/
17+
permissions:
18+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
19+
steps:
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
# Should be enough for setuptools-scm
23+
fetch-depth: 100
24+
persist-credentials: false
25+
26+
- name: Get tags
27+
run: git fetch origin 'refs/tags/*:refs/tags/*'
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
31+
with:
32+
python-version: "3.x"
33+
34+
- name: Install build tools
35+
run: |
36+
python -m pip install --upgrade pip build twine
37+
38+
- name: Build binary wheel
39+
run: python -m build --sdist --wheel . --outdir dist
40+
41+
- name: CheckFiles
42+
run: |
43+
ls -lh dist
44+
45+
- name: Test wheels
46+
run: |
47+
cd dist && python -m pip install xarray_subset_grid*.whl
48+
python -m twine check *
49+
50+
- name: Publish package distributions to PyPI
51+
if: success() && github.event_name == 'release'
52+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

.github/workflows/test.yaml

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
21
name: test
32

43
on: [push, pull_request]
54

6-
env:
7-
PIXI_VERSION: v0.47.0
8-
9-
# # Gave up -- could not figure out how to use environment variables :-(
10-
# env:
11-
# # I got these from: https://github.com/prefix-dev/setup-pixi/blob/main/README.md
12-
# # they seem to keep it pretty up to date
13-
# SETUP_PIXI_VERSION: v0.8.1
14-
# PIXI_VERSION: v0.29.0
15-
165
jobs:
176
test:
187
runs-on: ${{ matrix.os }}
@@ -21,28 +10,22 @@ jobs:
2110
matrix:
2211
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
2312
environment: [test310, test311, test312, test313]
13+
2414
steps:
25-
- uses: actions/checkout@v4
26-
- uses: prefix-dev/[email protected]
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
- name: Setup pixi
17+
uses: prefix-dev/setup-pixi@19eac09b398e3d0c747adc7921926a6d802df4da # v0.8.8
2718
with:
28-
pixi-version: latest
2919
cache: true
30-
# auth-host: prefix.dev
31-
# auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
32-
- run: pixi run --environment ${{ matrix.environment }} test
33-
lint:
34-
runs-on: ubuntu-latest
35-
strategy:
36-
fail-fast: false
37-
steps:
38-
- uses: actions/checkout@v4
39-
- uses: prefix-dev/[email protected]
40-
with:
41-
pixi-version: latest
42-
cache: true
43-
# auth-host: prefix.dev
44-
# auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
45-
- run: pixi run --environment test310 lint
20+
21+
- name: Tests
22+
run: >
23+
pixi run --environment ${{ matrix.environment }} test
24+
25+
- name: Lint
26+
if: contains(${{ matrix.os }}, "ubuntu") && ${{ matrix.environment }} == "test310"
27+
run: >
28+
pixi run --environment test310 lint
4629
4730
4831

0 commit comments

Comments
 (0)