forked from sirkirby/unifi-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (166 loc) · 5.31 KB
/
Copy pathrelease-network.yml
File metadata and controls
193 lines (166 loc) · 5.31 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: "Network: Release (test → PyPI + GHCR in parallel → GitHub Release)"
# Triggered on network/v* and legacy v*.*.* tags. The release is atomic:
#
# test ──┬── publish-pypi ──┐
# └── publish-docker ┴── github-release
#
# Both publishes must succeed before the GitHub Release is created — a tag
# without a green PyPI + GHCR pair is not "released."
on:
push:
tags:
- 'network/v*.*.*'
- 'v*.*.*' # Legacy tag format
permissions:
contents: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/unifi-network-mcp
jobs:
# ----------------------------------------------------------------------- 1
test:
name: Run unifi-network-mcp tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install workspace
run: uv sync --all-packages
- name: Run tests
run: uv run --package unifi-network-mcp pytest apps/network/tests -n auto -q
# ----------------------------------------------------------------------- 2a
publish-pypi:
name: Build wheel + publish to PyPI
needs: test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/unifi-network-mcp
permissions:
id-token: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Build wheel
run: uv build --package unifi-network-mcp
- name: Upload distributions for github-release
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/*
- name: Publish to PyPI via OIDC
uses: pypa/gh-action-pypi-publish@release/v1
# ----------------------------------------------------------------------- 2b
publish-docker:
name: Build + push Docker image
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
with:
platforms: linux/amd64,linux/arm64
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Derive version + image tag list
id: version
env:
REF_NAME: ${{ github.ref_name }}
IMAGE_REF: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
# network/v0.14.12 -> 0.14.12; v0.14.12 -> 0.14.12 (legacy)
VERSION="${REF_NAME#network/v}"
VERSION="${VERSION#v}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
if echo "${VERSION}" | grep -qE -- '-(rc|alpha|beta|dev)'; then
{
echo "tags<<EOF"
echo "${IMAGE_REF}:${VERSION}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
else
{
echo "tags<<EOF"
echo "${IMAGE_REF}:${VERSION}"
echo "${IMAGE_REF}:latest"
echo "EOF"
} >> "$GITHUB_OUTPUT"
fi
- name: Build and push image
uses: docker/build-push-action@v7
with:
context: .
file: apps/network/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.version.outputs.tags }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ----------------------------------------------------------------------- 3
github-release:
name: Create GitHub Release
needs: [publish-pypi, publish-docker]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Generate path-scoped release notes
env:
REF_NAME: ${{ github.ref_name }}
run: python3 scripts/generate_release_notes.py --tag "${REF_NAME}" --output /tmp/release-notes.md
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REF_NAME: ${{ github.ref_name }}
run: |
# network/v0.14.12 or legacy v0.14.12 -> 0.14.12
VERSION="${REF_NAME#network/v}"
VERSION="${VERSION#v}"
if echo "${VERSION}" | grep -qE -- '-(rc|alpha|beta|dev)'; then
PRERELEASE_FLAG="--prerelease"
else
PRERELEASE_FLAG=""
fi
gh release create "${REF_NAME}" \
--title "UniFi Network MCP v${VERSION}" \
--notes-file /tmp/release-notes.md \
--latest=false \
--verify-tag \
${PRERELEASE_FLAG} \
dist/*