-
Notifications
You must be signed in to change notification settings - Fork 8
102 lines (86 loc) · 2.86 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Build
env:
PYTHON_VERSION: "3.12"
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
branches:
- main
jobs:
build-and-publish:
name: Publish test release
runs-on: ubuntu-latest
outputs:
build-version: ${{ steps.build.outputs.version }}
if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'test-build')
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Publish to Test PyPI
id: build
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
version=$(./scripts/version dev)
echo "version=$version" >> $GITHUB_OUTPUT
sed -i -e "s/0.0.0/$version/" pyproject.toml
uv tool run -- hatchling build
uv tool run -- twine upload -r testpypi dist/*
test-install:
# We test the install on a clean machine to avoid poetry behavior attempting to
# install the project root when it is checked out
name: Test install
runs-on: ubuntu-latest
needs: build-and-publish
timeout-minutes: 5
steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Wait for package to be available
run: >
until
curl --silent "https://test.pypi.org/simple/packse/"
| grep --quiet "${{ needs.build-and-publish.outputs.build-version }}";
do sleep 10;
done
&&
sleep 180
# We sleep for an additional 180 seconds as it seems to take a bit longer for
# the package to be consistently available
# Note: The above will not sleep forever due to the job level timeout
- name: Install release from Test PyPI
run: |
uv pip install \
--system \
--extra-index-url https://test.pypi.org/simple/ \
--index-strategy unsafe-best-match \
packse==${{ needs.build-and-publish.outputs.build-version }}
- name: Check release version
run: |
installed=$(python3 -c "import pkg_resources; print(pkg_resources.get_distribution('packse').version)")
test $installed = ${{ needs.build-and-publish.outputs.build-version }}
- name: Check CLI help
run: |
packse --help