-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (65 loc) · 2.04 KB
/
release.yml
File metadata and controls
79 lines (65 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Release
on:
push:
tags:
- "*"
jobs:
build-wheels:
name: Build wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Get current git tag
id: tag
run: |
TAG=$(git describe --tags --abbrev=0)
# Remove the leading 'v' from the tag (e.g., 'v1.2.3' -> '1.2.3')
GIT_VERSION=${TAG#v}
echo "Current git tag version: $GIT_VERSION"
echo "GIT_VERSION=$GIT_VERSION" >> $GITHUB_ENV
- name: Check if git tag matches version
run: |
# Extract version from pyproject.toml
PY_VERSION=$(grep '^version = "' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "Version from pyproject.toml: $PY_VERSION"
echo "Current git tag version: $GIT_VERSION"
if [ "$PY_VERSION" != "$GIT_VERSION" ]; then
echo "Git tag does not match version in pyproject.toml."
exit 1
else
echo "Git tag matches version in pyproject.toml."
fi
- name: Setup uv
uses: astral-sh/setup-uv@v7
- name: Build wheels
run: |
uv build
- name: Test build
run: |
python3 -m venv fresh_env
. fresh_env/bin/activate
pip install dist/*.whl
fresh_env/bin/python -c "import xarray_validate; print(xarray_validate.__version__)"
- name: Store distribution packages
uses: actions/upload-artifact@v6
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish Python distribution to PyPI
needs:
- build-wheels
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/xarray-validate
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1