Skip to content

Commit 67bab94

Browse files
committed
fix: ci script
1 parent 512961c commit 67bab94

File tree

1 file changed

+98
-98
lines changed

1 file changed

+98
-98
lines changed

.github/workflows/python-publish.yml

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: Build and Publish to PyPI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
tags:
7-
- 'v*'
7+
- "v*"
88
pull_request:
9-
branches: [ main ]
9+
branches: [main]
1010
release:
1111
types: [created]
1212

@@ -20,106 +20,106 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
python-version: ['3.10', '3.11', '3.12']
23+
python-version: ["3.10", "3.11", "3.12"]
2424

2525
steps:
26-
- uses: actions/checkout@v3
27-
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v4
29-
with:
30-
python-version: ${{ matrix.python-version }}
31-
32-
- name: Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install pytest
36-
pip install -e .
37-
38-
- name: Generate models
39-
run: |
40-
python scripts/generate_models.py
41-
42-
- name: Run tests
43-
run: |
44-
python run_tests.py
26+
- uses: actions/checkout@v3
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install pytest
36+
pip install -e .
37+
38+
- name: Generate models
39+
run: |
40+
python scripts/generate_models.py
41+
42+
- name: Run tests
43+
run: |
44+
python run_tests.py
4545
4646
build-and-publish:
4747
needs: test
4848
runs-on: ubuntu-latest
4949
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v')
50-
50+
5151
steps:
52-
- uses: actions/checkout@v3
53-
54-
- name: Set up Python
55-
uses: actions/setup-python@v4
56-
with:
57-
python-version: '3.10'
58-
59-
- name: Install dependencies
60-
run: |
61-
python -m pip install --upgrade pip
62-
pip install -e .[dev]
63-
64-
- name: Generate models
65-
run: |
66-
python run.py run_all
67-
echo "Generated $(find msgspec_schemaorg/models -type f -name "*.py" | wc -l) model files"
68-
69-
- name: Build package
70-
run: |
71-
# Build the package
72-
python -m build
73-
74-
# Verify package contents
75-
echo "Verifying package contents..."
76-
77-
# Check source distribution
78-
mkdir -p /tmp/check-sdist
79-
tar -xf dist/*.tar.gz -C /tmp/check-sdist
80-
MODEL_COUNT=$(find /tmp/check-sdist -name "*.py" | grep models | wc -l)
81-
echo "Source distribution contains $MODEL_COUNT model files"
82-
if [ "$MODEL_COUNT" -lt 900 ]; then
83-
echo "ERROR: Not enough model files in source distribution"
84-
exit 1
85-
fi
86-
87-
# Install and verify the wheel
88-
pip install dist/*.whl
89-
python -c "import msgspec_schemaorg.models; count = len(msgspec_schemaorg.models.__all__); print(f'Wheel contains {count} importable models'); assert count > 900, 'Not enough models'"
90-
91-
- name: Upload distributions
92-
uses: actions/upload-artifact@v4
93-
with:
94-
name: python-package-distributions
95-
path: dist/
96-
97-
- name: Publish to PyPI
98-
uses: pypa/gh-action-pypi-publish@release/v1
99-
with:
100-
password: ${{ secrets.PYPI_API_TOKEN }}
101-
skip-existing: true
102-
103-
- name: Sign with Sigstore
104-
uses: sigstore/[email protected]
105-
with:
106-
inputs: ./dist/*.tar.gz ./dist/*.whl
107-
108-
- name: Upload to GitHub Release
109-
env:
110-
GITHUB_TOKEN: ${{ github.token }}
111-
run: >-
112-
gh release create
113-
"$GITHUB_REF_NAME"
114-
--repo "$GITHUB_REPOSITORY"
115-
--notes "This release was automatically created by the GitHub Actions workflow."
116-
- name: Upload artifact signatures to GitHub Release
117-
env:
118-
GITHUB_TOKEN: ${{ github.token }}
119-
# Upload to GitHub Release using the `gh` CLI.
120-
# `dist/` contains the built packages, and the
121-
# sigstore-produced signatures and certificates.
122-
run: >-
123-
gh release upload
124-
"$GITHUB_REF_NAME" dist/**
125-
--repo "$GITHUB_REPOSITORY"
52+
- uses: actions/checkout@v3
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v4
56+
with:
57+
python-version: "3.10"
58+
59+
- name: Install dependencies
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install -e .[dev]
63+
64+
- name: Generate models
65+
run: |
66+
python run.py all
67+
echo "Generated $(find msgspec_schemaorg/models -type f -name "*.py" | wc -l) model files"
68+
69+
- name: Build package
70+
run: |
71+
# Build the package
72+
python -m build
73+
74+
# Verify package contents
75+
echo "Verifying package contents..."
76+
77+
# Check source distribution
78+
mkdir -p /tmp/check-sdist
79+
tar -xf dist/*.tar.gz -C /tmp/check-sdist
80+
MODEL_COUNT=$(find /tmp/check-sdist -name "*.py" | grep models | wc -l)
81+
echo "Source distribution contains $MODEL_COUNT model files"
82+
if [ "$MODEL_COUNT" -lt 900 ]; then
83+
echo "ERROR: Not enough model files in source distribution"
84+
exit 1
85+
fi
86+
87+
# Install and verify the wheel
88+
pip install dist/*.whl
89+
python -c "import msgspec_schemaorg.models; count = len(msgspec_schemaorg.models.__all__); print(f'Wheel contains {count} importable models'); assert count > 900, 'Not enough models'"
90+
91+
- name: Upload distributions
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: python-package-distributions
95+
path: dist/
96+
97+
- name: Publish to PyPI
98+
uses: pypa/gh-action-pypi-publish@release/v1
99+
with:
100+
password: ${{ secrets.PYPI_API_TOKEN }}
101+
skip-existing: true
102+
103+
- name: Sign with Sigstore
104+
uses: sigstore/[email protected]
105+
with:
106+
inputs: ./dist/*.tar.gz ./dist/*.whl
107+
108+
- name: Upload to GitHub Release
109+
env:
110+
GITHUB_TOKEN: ${{ github.token }}
111+
run: >-
112+
gh release create
113+
"$GITHUB_REF_NAME"
114+
--repo "$GITHUB_REPOSITORY"
115+
--notes "This release was automatically created by the GitHub Actions workflow."
116+
- name: Upload artifact signatures to GitHub Release
117+
env:
118+
GITHUB_TOKEN: ${{ github.token }}
119+
# Upload to GitHub Release using the `gh` CLI.
120+
# `dist/` contains the built packages, and the
121+
# sigstore-produced signatures and certificates.
122+
run: >-
123+
gh release upload
124+
"$GITHUB_REF_NAME" dist/**
125+
--repo "$GITHUB_REPOSITORY"

0 commit comments

Comments
 (0)