Skip to content

Commit dc21f11

Browse files
Merge pull request #195 from petrobras/other_improvements
Other improvements
2 parents ff03e03 + 6fc98fd commit dc21f11

8 files changed

Lines changed: 3285 additions & 8 deletions

File tree

.github/workflows/publish.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Publish to PyPI on version change
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- pyproject.toml
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
environment:
14+
name: pypi
15+
url: https://pypi.org/p/threewtoolkit
16+
permissions:
17+
id-token: write
18+
19+
steps:
20+
- name: Check out main branch
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
- name: Check if project version changed
26+
id: version_changed
27+
run: |
28+
OLD_VERSION=$(git show HEAD^:pyproject.toml | sed -n 's/^version = "\(.*\)"/\1/p' | head -n 1 || true)
29+
NEW_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml | head -n 1)
30+
31+
echo "Old version: $OLD_VERSION"
32+
echo "New version: $NEW_VERSION"
33+
34+
if [ -z "$NEW_VERSION" ]; then
35+
echo "Could not find version line in pyproject.toml"
36+
exit 1
37+
fi
38+
39+
if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
40+
echo "Version did not change. Skipping publish."
41+
echo "changed=false" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "Version changed. Continuing publish."
44+
echo "changed=true" >> "$GITHUB_OUTPUT"
45+
fi
46+
47+
- name: Validate package version
48+
if: steps.version_changed.outputs.changed == 'true'
49+
run: |
50+
python3 <<'PY'
51+
import re
52+
import sys
53+
from pathlib import Path
54+
from packaging.version import Version
55+
56+
text = Path("pyproject.toml").read_text()
57+
58+
match = re.search(r'(?m)^version = "([^"]+)"', text)
59+
if not match:
60+
sys.exit('Could not find a line starting with: version = "..." in pyproject.toml')
61+
62+
version = match.group(1)
63+
64+
try:
65+
Version(version)
66+
except Exception as exc:
67+
sys.exit(f"Invalid PEP 440 version {version!r}: {exc}")
68+
69+
print(f"Publishing version: {version!r}")
70+
PY
71+
72+
- name: Set up Python
73+
if: steps.version_changed.outputs.changed == 'true'
74+
uses: actions/setup-python@v5
75+
with:
76+
python-version: "3.11"
77+
78+
- name: Install build tools
79+
if: steps.version_changed.outputs.changed == 'true'
80+
run: python -m pip install --upgrade pip build packaging
81+
82+
- name: Build distribution
83+
if: steps.version_changed.outputs.changed == 'true'
84+
run: python -m build
85+
86+
- name: Publish to PyPI
87+
if: steps.version_changed.outputs.changed == 'true'
88+
uses: pypa/gh-action-pypi-publish@release/v1
89+
with:
90+
password: ${{ secrets.PYPI_API_TOKEN }}

lychee.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ exclude_path = [
77
"CODE_OF_CONDUCT.md"
88
]
99

10-
accept = [
11-
200, # request succeeded
12-
201, # resource successfully created
13-
202, # request accepted, processing not completed yet
14-
204, # request succeeded, no response body
15-
429 # too many requests
16-
]
10+
accept = ["100..=103", "200..=299", "403", "429"]
1711

18-
user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
12+
user_agent = "Mozilla/5.0"
139 KB
Loading

0 commit comments

Comments
 (0)