-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (66 loc) · 2.5 KB
/
release-python.yml
File metadata and controls
80 lines (66 loc) · 2.5 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
name: Release Python Package
on:
push:
tags:
- 'py-v*' # This will trigger on tags like py-v1.0.0
permissions:
contents: write
packages: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./clients/python
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for release notes
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine pytest
- name: Install package in development mode
run: |
pip install -e .
- name: Run tests
run: pytest
- name: Build package
run: python -m build
- name: Generate release notes
id: release
run: |
VERSION=${GITHUB_REF#refs/tags/py-}
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Extract changes from CHANGELOG if available, otherwise from git log
if [ -f "../../CHANGELOG.md" ]; then
CHANGES=$(awk -v ver="$VERSION" '/^## \['"$VERSION"'\]/{flag=1; next} /^## \[/{flag=0} flag' ../../CHANGELOG.md)
if [ -z "$CHANGES" ]; then
CHANGES=$(git log --pretty=format:"* %s (%h)" $(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD -- ./clients/python || echo "Initial release")
fi
else
CHANGES=$(git log --pretty=format:"* %s (%h)" $(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD -- ./clients/python || echo "Initial release")
fi
echo "CHANGES<<EOF" >> $GITHUB_ENV
echo "$CHANGES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: ./clients/python/dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: Python Release ${{ steps.release.outputs.version }}
body: |
## Changes in this Python release
${{ env.CHANGES }}
For full details, see the [CHANGELOG](https://github.com/lightfeed/sdk/blob/main/CHANGELOG.md).
draft: false
prerelease: false