|
4 | 4 | ## |
5 | 5 | --- |
6 | 6 |
|
| 7 | +name: Publish test-pypi |
| 8 | + |
7 | 9 | on: |
8 | 10 | push: |
9 | 11 | branches: |
10 | 12 | - main |
11 | 13 | pull_request: |
12 | 14 |
|
13 | 15 | jobs: |
14 | | - build: |
15 | | - name: Build distribution |
| 16 | + build-and-publish: |
| 17 | + name: Build and Publish to TestPyPI |
16 | 18 | runs-on: ubuntu-latest |
17 | | - steps: |
18 | 19 |
|
19 | | - - name: Checkout code |
| 20 | + steps: |
| 21 | + - name: 📥 Checkout repository |
20 | 22 | uses: actions/checkout@v4 |
21 | 23 | with: |
22 | | - fetch-depth: 0 |
| 24 | + fetch-depth: 0 # Fetch the entire history to avoid shallow repository issues |
23 | 25 |
|
24 | | - - name: Set up Python |
| 26 | + - name: 🐍 Set up Python |
25 | 27 | uses: actions/setup-python@v4 |
26 | 28 | with: |
27 | | - python-version: '3.9' |
28 | | - |
29 | | - - name: Install Poetry |
30 | | - run: | |
31 | | - python -m pip install --upgrade pip |
32 | | - pip install poetry |
33 | | - pip install poetry-dynamic-versioning |
34 | | -
|
35 | | - - name: Build |
36 | | - run: | |
37 | | - poetry build |
| 29 | + python-version: "3.9" |
38 | 30 |
|
39 | | - - name: Save build artifacts |
40 | | - uses: actions/upload-artifact@v4 |
| 31 | + - name: 💾 Cache Poetry dependencies |
| 32 | + uses: actions/cache@v3 |
41 | 33 | with: |
42 | | - name: dist-artifact |
43 | | - path: dist/ |
| 34 | + path: ~/.cache/pypoetry |
| 35 | + key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 36 | + restore-keys: | |
| 37 | + poetry-${{ runner.os }}- |
44 | 38 |
|
45 | | - test: |
46 | | - name: Test |
47 | | - needs: build |
48 | | - runs-on: ubuntu-latest |
49 | | - steps: |
50 | | - |
51 | | - - name: Set up Python |
52 | | - uses: actions/setup-python@v4 |
| 39 | + - name: 📦 Install poetry |
| 40 | + uses: abatilo/actions-poetry@v4 |
53 | 41 | with: |
54 | | - python-version: '3.9' |
| 42 | + poetry-version: '2.1.1' |
55 | 43 |
|
56 | | - - name: Checkout code |
57 | | - uses: actions/checkout@v4 |
58 | | - with: |
59 | | - fetch-depth: 0 |
60 | | - |
61 | | - - name: Get build artifacts |
62 | | - uses: actions/download-artifact@v4 |
63 | | - with: |
64 | | - name: dist-artifact |
65 | | - path: dist/ |
| 44 | + - name: 📦 Install poetry-dynamic-versioning |
| 45 | + run: poetry self add "poetry-dynamic-versioning[plugin]" |
66 | 46 |
|
67 | | - - name: Install from build |
68 | | - run: | |
69 | | - python -m pip install --upgrade pip |
70 | | - pip install pytest-mock |
71 | | - pip install etpproto --pre --target=dist --find-links=dist/ |
| 47 | + - name: 📥 Install dependencies |
| 48 | + run: poetry install --no-interaction --no-root |
72 | 49 |
|
73 | | - - name: Copy tests and example data to dist folder for testing against artifacts |
| 50 | + - name: Configure Poetry with PyPI repository and token |
74 | 51 | run: | |
75 | | - cp -R tests dist/ |
76 | | - # cp -R example_data dist/ |
77 | | - |
78 | | - - name: Run tests |
79 | | - run: pytest dist/tests |
80 | | - |
81 | | - publish: |
82 | | - name: Publish to PyPI |
83 | | - needs: [build, test] |
84 | | - runs-on: ubuntu-latest |
85 | | - steps: |
| 52 | + poetry config repositories.test-pypi https://test.pypi.org/legacy/ |
| 53 | + poetry config pypi-token.test-pypi ${{ secrets.POETRY_PYPI_TEST_TOKEN_VALUE }} |
86 | 54 |
|
87 | | - - name: Set up Python |
88 | | - uses: actions/setup-python@v4 |
89 | | - with: |
90 | | - python-version: '3.9' |
| 55 | + - name: 🛠️ Build the package |
| 56 | + run: poetry build |
91 | 57 |
|
92 | | - # Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload |
93 | | - - name: Checkout code |
94 | | - uses: actions/checkout@v4 |
95 | | - with: |
96 | | - fetch-depth: 0 |
97 | | - |
98 | | - - name: Get build artifacts |
99 | | - uses: actions/download-artifact@v4 |
100 | | - with: |
101 | | - name: dist-artifact |
102 | | - path: dist/ |
103 | | - |
104 | | - - name: Install Poetry |
105 | | - run: | |
106 | | - python -m pip install --upgrade pip |
107 | | - pip install poetry |
108 | | - pip install poetry-dynamic-versioning |
109 | | -
|
110 | | - - name: Upload to PyPI TEST |
111 | | - run: | |
112 | | - poetry config repositories.test https://test.pypi.org/legacy/ |
113 | | - poetry config http-basic.test ${{ secrets.POETRY_PYPI_TOKEN_USERNAME}} ${{ secrets.POETRY_TEST_PYPI_TOKEN_PASSWORD}} |
114 | | - poetry publish --repository test |
| 58 | + - name: 🚀 Publish to PyPI |
| 59 | + run: |
| 60 | + poetry publish --repository test-pypi |
0 commit comments