Skip to content

Commit ff5a3ca

Browse files
committed
feat: add publish-to-test-pypi.yml
Signed-off-by: Milad Makdesi <milad@id8-engineering.io>
1 parent 1a8fcb4 commit ff5a3ca

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: publish-to-test-pypi
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
jobs:
8+
build:
9+
name: Build distribution
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
18+
with:
19+
python-version: "3.x"
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
23+
24+
- name: Set dynamic version
25+
run: |
26+
BASE_VERSION="0.0.1"
27+
VERSION="${BASE_VERSION}.post${{ github.run_number }}"
28+
echo "Using version: $VERSION"
29+
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
30+
grep '^version =' pyproject.toml
31+
32+
- name: Build distributions with uv
33+
run: uv build
34+
35+
- name: Validate metadata
36+
run: |
37+
uv pip install twine
38+
twine check dist/*
39+
40+
- name: Verify installability
41+
run: uv pip install dist/*.whl
42+
43+
- name: Test import
44+
run: python -c "import em511"
45+
46+
- name: Run tests
47+
run: |
48+
uv pip install pytest
49+
pytest
50+
51+
- name: Upload distributions as artifact
52+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
53+
with:
54+
name: dist-files
55+
path: dist/
56+
57+
publish-to-test-pypi:
58+
name: Publish Python distribution to TestPyPI
59+
needs: [build]
60+
runs-on: ubuntu-latest
61+
62+
environment:
63+
name: testpypi
64+
url: https://test.pypi.org/p/python-em511
65+
66+
permissions:
67+
id-token: write
68+
69+
steps:
70+
- name: Download all build artifacts
71+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
72+
with:
73+
name: dist-files
74+
path: dist/
75+
76+
- name: Publish distribution to TestPyPI
77+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
78+
with:
79+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)