-
Notifications
You must be signed in to change notification settings - Fork 4
169 lines (141 loc) · 4.98 KB
/
release.yml
File metadata and controls
169 lines (141 loc) · 4.98 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
name: Release to PyPI
on:
push:
tags:
- "v*"
permissions:
contents: read
id-token: write
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Check out the tag that triggered the workflow so hatch-vcs sees exact tag
ref: ${{ github.ref }}
# Required for hatch-vcs to detect version from tags
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "latest"
enable-cache: true
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }}
restore-keys: |
${{ runner.os }}-uv-
# Extract version early so it can be used in subsequent steps
- name: Set version from tag
id: set_version
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Install dependencies
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.set_version.outputs.version }}
run: uv sync --group dev --group build
- name: Run linting
run: uv run ruff check
- name: Run formatting check
run: uv run ruff format --check
- name: Run tests
run: uv run pytest
- name: Verify we're on the tag (so hatch-vcs uses tag version)
run: |
git describe --exact-match HEAD || (echo "::error::HEAD is not exactly on tag ${{ github.ref_name }}"; exit 1)
echo "Building version from tag: ${{ github.ref_name }}"
- name: Clean previous builds
run: git clean -fd
- name: Build package
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.set_version.outputs.version }}
run: uv run python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
publish-testpypi:
needs: build-and-test
runs-on: ubuntu-latest
if: startsWith(github.ref_name, 'v')
environment:
name: testpypi
permissions:
contents: read
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
repository-url: https://test.pypi.org/legacy/
print-hash: true
skip-existing: true
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "latest"
- name: Wait for TestPyPI propagation
run: |
echo "⏳ Waiting for package to be available on TestPyPI..."
sleep 30
- name: Test installation from TestPyPI
run: |
# Extract version from tag (remove 'v' prefix)
VERSION="${GITHUB_REF_NAME#v}"
echo "🧪 Testing installation of tabpfn-common-utils==${VERSION} from TestPyPI..."
# Create a temporary directory for testing
TEST_DIR=$(mktemp -d)
cd "$TEST_DIR"
# Create a virtual environment
uv venv
source .venv/bin/activate
# Install from TestPyPI using uv
# Use --index-url for TestPyPI and --extra-index-url for dependencies from PyPI
# (TestPyPI doesn't have all packages, so we need PyPI as fallback for dependencies)
uv pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
--index-strategy unsafe-best-match \
tabpfn-common-utils==${VERSION}
# Verify installation and version
INSTALLED_VERSION=$(python -c "import tabpfn_common_utils; print(tabpfn_common_utils.__version__)")
if [ "$INSTALLED_VERSION" != "${VERSION}" ]; then
echo "❌ Version mismatch! Expected ${VERSION}, got ${INSTALLED_VERSION}"
exit 1
fi
echo "✅ Successfully installed version: ${INSTALLED_VERSION}"
echo "✅ Installation test passed! Version ${VERSION} is correctly installed from TestPyPI"
publish-pypi:
needs: [build-and-test, publish-testpypi]
runs-on: ubuntu-latest
if: startsWith(github.ref_name, 'v')
environment:
name: pypi
permissions:
contents: read
id-token: write
steps:
- name: Waiting for manual approval
run: |
echo "⏳ Waiting for manual approval to publish to PyPI..."
echo "📦 Tag: ${{ github.ref_name }}"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
print-hash: true
skip-existing: true