-
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (111 loc) · 3.69 KB
/
publish-pypi.yml
File metadata and controls
118 lines (111 loc) · 3.69 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Publish Stable to PyPI
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Stable tag to publish (example: v1.2.3). Defaults to current ref name."
required: false
type: string
permissions:
contents: read
concurrency:
group: stable-pypi-${{ github.ref }}
cancel-in-progress: false
jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
RADIOSHAQ_LICENSE_ACCEPTED: "1"
DATABASE_URL: postgresql://radioshaq:radioshaq@127.0.0.1:5434/radioshaq
TEST_DATABASE_URL: postgresql+asyncpg://radioshaq:radioshaq@127.0.0.1:5434/radioshaq
services:
postgres:
image: postgis/postgis:16-3.4
env:
POSTGRES_USER: radioshaq
POSTGRES_PASSWORD: radioshaq
POSTGRES_DB: radioshaq
ports:
- 5434:5432
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag != '' && inputs.tag || github.ref }}
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: cd radioshaq && uv sync --extra dev --extra test --extra sdr
- name: Wait for Postgres
run: |
for i in $(seq 1 30); do
if python -c "import socket; s=socket.socket(); s.settimeout(2); s.connect(('127.0.0.1',5434)); s.close()" 2>/dev/null; then
echo "Postgres is ready on 127.0.0.1:5434"
break
fi
echo "Waiting for Postgres... ($i/30)"
sleep 2
done
python -c "import socket; s=socket.socket(); s.settimeout(5); s.connect(('127.0.0.1',5434)); s.close(); print('Postgres port open')"
- name: Run database migrations
run: cd radioshaq && uv run alembic-upgrade
- name: Run test suite
run: cd radioshaq && uv run pytest tests/unit tests/integration -v
verify-tag-source:
name: Verify tag points to main history
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ inputs.tag != '' && inputs.tag || github.ref }}
- name: Ensure tagged commit is reachable from origin/main
run: |
git fetch origin +refs/heads/main:refs/remotes/origin/main
TAG_SHA=$(git rev-parse HEAD)
if ! git branch -r --contains "$TAG_SHA" | grep -q "origin/main"; then
echo "Stable publish is only allowed for tags on main history."
exit 1
fi
build-and-publish:
name: Build and publish stable artifact
needs: [test, verify-tag-source]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag != '' && inputs.tag || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
cache-dependency-path: radioshaq/web-interface/package-lock.json
- name: Build web UI
working-directory: radioshaq/web-interface
run: |
npm ci --no-audit --no-fund
npm run build
- name: Stage web UI for wheel
run: |
mkdir -p radioshaq/radioshaq/web_ui
cp -r radioshaq/web-interface/dist/. radioshaq/radioshaq/web_ui/
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- uses: astral-sh/setup-uv@v7
- name: Build wheel and sdist
run: |
cd radioshaq
uv run --with build python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: radioshaq/dist