-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (130 loc) · 4.3 KB
/
Copy pathrelease.yml
File metadata and controls
159 lines (130 loc) · 4.3 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
validate-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Validate tag matches package versions
run: |
python - <<'PY'
import re
import tomllib
from pathlib import Path
import os
tag = os.environ["GITHUB_REF_NAME"]
assert tag.startswith("v"), f"Expected version tag, got: {tag}"
tag_version = tag[1:]
pyproject = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))
pyproject_version = pyproject["project"]["version"]
init_text = Path("src/ecs_agent/__init__.py").read_text(encoding="utf-8")
match = re.search(r'__version__\s*=\s*"([^"]+)"', init_text)
if match is None:
raise SystemExit("Could not find __version__ in src/ecs_agent/__init__.py")
init_version = match.group(1)
if tag_version != pyproject_version or tag_version != init_version:
raise SystemExit(
f"Version mismatch: tag={tag_version}, pyproject.toml={pyproject_version}, src/ecs_agent/__init__.py={init_version}"
)
PY
test:
runs-on: ubuntu-latest
needs: validate-version
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set up uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --group dev
- name: Run pytest
run: uv run pytest
live-tests:
runs-on: ubuntu-latest
needs: test
env:
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
ANTHROPIC_LIVE_API_KEY: ${{ secrets.ANTHROPIC_LIVE_API_KEY }}
IMAGE_URL: ${{ secrets.IMAGE_URL }}
LLM_BASE_URL: ${{ vars.LLM_BASE_URL }}
LLM_MODEL: ${{ vars.LLM_MODEL }}
LLM_API_FORMAT: ${{ vars.LLM_API_FORMAT }}
ANTHROPIC_LIVE_BASE_URL: ${{ vars.ANTHROPIC_LIVE_BASE_URL }}
ANTHROPIC_LIVE_MODEL: ${{ vars.ANTHROPIC_LIVE_MODEL }}
ALIYUN_LIVE_CHAT_BASE_URL: ${{ vars.ALIYUN_LIVE_CHAT_BASE_URL }}
ALIYUN_LIVE_RESPONSES_BASE_URL: ${{ vars.ALIYUN_LIVE_RESPONSES_BASE_URL }}
ALIYUN_LIVE_MODEL: ${{ vars.ALIYUN_LIVE_MODEL }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install tmux
run: sudo apt-get update && sudo apt-get install -y tmux
- name: Set up uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --group dev
- name: Run full live test suite
run: uv run pytest tests/live -v
build-and-release:
runs-on: ubuntu-latest
needs: live-tests
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Validate release notes file
run: |
RELEASE_NOTES_PATH="docs/releases/${GITHUB_REF_NAME}.md"
test -f "$RELEASE_NOTES_PATH"
test -s "$RELEASE_NOTES_PATH"
printf 'RELEASE_NOTES_PATH=%s\n' "$RELEASE_NOTES_PATH" >> "$GITHUB_ENV"
- name: Install build backend
run: python -m pip install build
- name: Build distributions
run: python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-artifacts
path: dist/*
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: ${{ env.RELEASE_NOTES_PATH }}
files: dist/*
publish-pypi:
runs-on: ubuntu-latest
needs: build-and-release
permissions:
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-artifacts
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1