-
Notifications
You must be signed in to change notification settings - Fork 28
75 lines (63 loc) · 2.17 KB
/
main.yml
File metadata and controls
75 lines (63 loc) · 2.17 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
# .github/workflows/main.yml (Python)
name: Release Python SDK
on:
push:
branches: [master]
paths:
- '.changelog/v*.md'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for PyPI trusted publishing
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Extract Version
id: version
run: |
VERSION=$(grep -oP "version\s*=\s*['\"]?\K[^'\"]+" pyproject.toml 2>/dev/null)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build Package
run: python -m build
- name: Create Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a ${{ steps.version.outputs.tag }} -m "Release ${{ steps.version.outputs.tag }}"
git push origin ${{ steps.version.outputs.tag }}
- name: Read Changelog
id: changelog
run: |
CHANGELOG_FILE=".changelog/${{ steps.version.outputs.tag }}.md"
if [ -f "$CHANGELOG_FILE" ]; then
delimiter="$(openssl rand -hex 8)"
echo "content<<$delimiter" >> $GITHUB_OUTPUT
cat "$CHANGELOG_FILE" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
else
echo "content=Release ${{ steps.version.outputs.tag }}" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.tag }}
body: ${{ steps.changelog.outputs.content }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}