-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (178 loc) · 6.54 KB
/
publish.yml
File metadata and controls
211 lines (178 loc) · 6.54 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# Copyright (c) 2025 Vantage Compute Corporation.
name: Build and Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+a[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+b[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
workflow_dispatch: # Allow manual triggering
permissions:
contents: write # Required for creating releases
id-token: write # Required for PyPI trusted publishing
jobs:
build:
name: Build Distribution
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for proper version detection
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install just
uses: extractions/setup-just@v2
- name: Install git-cliff
run: |
curl -L https://github.com/orhun/git-cliff/releases/download/v2.10.0/git-cliff-2.10.0-x86_64-unknown-linux-gnu.tar.gz | tar xz
sudo mv git-cliff-*/git-cliff /usr/local/bin/
git-cliff --version
- name: Build Python package
run: |
just build-wheel
- name: Check build artifacts
run: |
ls -la dist/
# Basic validation - ensure files exist
test -n "$(find dist -name '*.whl')" || (echo "No wheel files found" && exit 1)
test -n "$(find dist -name '*.tar.gz')" || (echo "No source distribution found" && exit 1)
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: distribution-files
path: dist/
retention-days: 7
test-install:
name: Test Installation
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12', '3.13']
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: distribution-files
path: dist/
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Test wheel installation
run: |
uv venv
uv pip install dist/*.whl
uv run python3 -c "import helm_sdkpy; print('Package imported successfully')"
publish-pypi:
name: Publish to PyPI
needs: [build, test-install]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
environment:
name: pypi
url: https://pypi.org/p/helm-sdkpy
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: distribution-files
path: dist/
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Publish to PyPI
run: uv publish
create-release:
name: Create GitHub Release
needs: [build, test-install]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: distribution-files
path: dist/
- name: Extract version from tag
id: get_version
run: |
TAG=${GITHUB_REF#refs/tags/}
# Strip 'v' prefix for version number (PyPI doesn't use it)
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Generate release notes
id: release_notes
run: |
# Extract release notes from CHANGELOG.md if it exists
if [ -f "CHANGELOG.md" ]; then
# Try to extract notes for this version using git-cliff for consistency
VERSION="${{ steps.get_version.outputs.version }}"
# Use git-cliff to generate notes for this specific version
git-cliff --latest --strip header --strip footer > release_notes.txt || true
# If that fails, fall back to grep method
if [ ! -s release_notes.txt ]; then
grep -A 1000 "^## .*${VERSION}" CHANGELOG.md | grep -B 1000 -m 2 "^## " | head -n -1 | tail -n +2 > release_notes.txt || true
fi
# If no specific version notes found, create generic notes
if [ ! -s release_notes.txt ]; then
echo "Release ${{ steps.get_version.outputs.tag }}" > release_notes.txt
echo "" >> release_notes.txt
echo "### Changes" >> release_notes.txt
echo "- See CHANGELOG.md for detailed changes" >> release_notes.txt
fi
else
echo "Release ${{ steps.get_version.outputs.tag }}" > release_notes.txt
echo "" >> release_notes.txt
echo "### Files" >> release_notes.txt
echo "- Source distribution (tar.gz)" >> release_notes.txt
echo "- Wheel distribution (.whl)" >> release_notes.txt
fi
echo "Release notes:"
cat release_notes.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.get_version.outputs.tag }}
body_path: release_notes.txt
files: |
dist/*.tar.gz
dist/*.whl
draft: false
prerelease: ${{ contains(steps.get_version.outputs.version, 'rc') || contains(steps.get_version.outputs.version, 'beta') || contains(steps.get_version.outputs.version, 'alpha') }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-success:
name: Notify Success
needs: [publish-pypi, create-release]
runs-on: ubuntu-latest
if: success() && startsWith(github.ref, 'refs/tags/')
steps:
- name: Extract version from tag
id: get_version
run: |
TAG=${GITHUB_REF#refs/tags/}
# Strip 'v' prefix for version number (PyPI doesn't use it)
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Success notification
run: |
echo "🎉 Successfully released helm-sdkpy ${{ steps.get_version.outputs.tag }}"
echo "📦 Published to PyPI: https://pypi.org/project/helm-sdkpy/${{ steps.get_version.outputs.version }}/"
echo "🚀 GitHub Release: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.tag }}"