Skip to content

Commit d768eed

Browse files
committed
CI is updated.
1 parent 5d2d605 commit d768eed

5 files changed

Lines changed: 62 additions & 16 deletions

File tree

.github/workflows/CI.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@
66
name: CI
77

88
on:
9-
push:
10-
branches:
11-
- main
12-
- master
13-
tags:
14-
- '*'
15-
pull_request:
16-
workflow_dispatch:
9+
release:
10+
types: [released]
1711

1812
permissions:
1913
contents: read
@@ -41,6 +35,9 @@ jobs:
4135
- uses: actions/setup-python@v6
4236
with:
4337
python-version: 3.x
38+
- name: Setting correct version
39+
run: |
40+
python ./scripts/version_bumper.py "${{ github.ref_name }}"
4441
- name: Build wheels
4542
uses: PyO3/maturin-action@v1
4643
with:
@@ -74,6 +71,9 @@ jobs:
7471
- uses: actions/setup-python@v6
7572
with:
7673
python-version: 3.x
74+
- name: Setting correct version
75+
run: |
76+
python ./scripts/version_bumper.py "${{ github.ref_name }}"
7777
- name: Build wheels
7878
uses: PyO3/maturin-action@v1
7979
with:
@@ -110,6 +110,9 @@ jobs:
110110
with:
111111
python-version: 3.13
112112
architecture: ${{ matrix.platform.python_arch }}
113+
- name: Setting correct version
114+
run: |
115+
python ./scripts/version_bumper.py "${{ github.ref_name }}"
113116
- name: Build wheels
114117
uses: PyO3/maturin-action@v1
115118
with:
@@ -136,6 +139,9 @@ jobs:
136139
- uses: actions/setup-python@v6
137140
with:
138141
python-version: 3.x
142+
- name: Setting correct version
143+
run: |
144+
python ./scripts/version_bumper.py "${{ github.ref_name }}"
139145
- name: Build wheels
140146
uses: PyO3/maturin-action@v1
141147
with:
@@ -152,6 +158,12 @@ jobs:
152158
runs-on: ubuntu-latest
153159
steps:
154160
- uses: actions/checkout@v6
161+
- uses: actions/setup-python@v6
162+
with:
163+
python-version: 3.x
164+
- name: Setting correct version
165+
run: |
166+
python ./scripts/version_bumper.py "${{ github.ref_name }}"
155167
- name: Build sdist
156168
uses: PyO3/maturin-action@v1
157169
with:
@@ -166,7 +178,6 @@ jobs:
166178
release:
167179
name: Release
168180
runs-on: ubuntu-latest
169-
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
170181
needs: [linux, musllinux, windows, macos, sdist]
171182
permissions:
172183
# Use to sign the release artifacts
@@ -180,12 +191,10 @@ jobs:
180191
- name: Generate artifact attestation
181192
uses: actions/attest-build-provenance@v3
182193
with:
183-
subject-path: 'wheels-*/*'
194+
subject-path: "wheels-*/*"
184195
- name: Install uv
185-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
186196
uses: astral-sh/setup-uv@v7
187197
- name: Publish to PyPI
188-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
189198
run: uv publish 'wheels-*/*'
190199
env:
191-
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
200+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "natsrpy"
3-
version = "0.1.0"
3+
version = "0.0.1"
44
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ dynamic = ["version"]
1212
requires = ["maturin>=1.12,<2.0"]
1313
build-backend = "maturin"
1414

15-
1615
[tool.maturin]
1716
bindings = "pyo3"
1817
python-source = "python"

scripts/bump_version.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import re
2+
import argparse
3+
from pathlib import Path
4+
5+
6+
def parse_args() -> argparse.Namespace:
7+
"""Parse command line arguments."""
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument(
10+
"--target",
11+
"-t",
12+
dest="target",
13+
type=Path,
14+
default="Cargo.toml",
15+
)
16+
parser.add_argument("version", type=str)
17+
return parser.parse_args()
18+
19+
20+
def main() -> None:
21+
"""Main function."""
22+
args = parse_args()
23+
with args.target.open("r") as f:
24+
contents = f.read()
25+
26+
contents = re.sub(
27+
r"version\s*=\s*\"(.*)\"",
28+
f'version = "{args.version}"',
29+
contents,
30+
count=1,
31+
)
32+
33+
with args.target.open("w") as f:
34+
f.write(contents)
35+
36+
37+
if __name__ == "__main__":
38+
main()

0 commit comments

Comments
 (0)