Skip to content

Commit 18385e4

Browse files
add GitHub workflow
1 parent fbc060c commit 18385e4

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/publish.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- v**
8+
9+
jobs:
10+
pypi:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.x"
21+
22+
- name: Set up Poetry
23+
uses: abatilo/actions-poetry@v2
24+
with:
25+
poetry-version: "1.8.3"
26+
27+
- name: Get version
28+
id: get_version
29+
run: echo "VERSION=$(echo ${GITHUB_REF/refs\/tags\//})" >> $GITHUB_ENV
30+
31+
- name: Set version
32+
run: poetry version ${{ env.VERSION }}
33+
34+
- name: Publish PyPI package
35+
env:
36+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.LIVESYNC_PYPI_API_TOKEN }}
37+
run: poetry publish --build
38+
39+
- name: Create GitHub release entry
40+
uses: softprops/action-gh-release@v1
41+
id: create_release
42+
with:
43+
draft: true
44+
prerelease: false
45+
name: ${{ env.VERSION }}
46+
tag_name: ${{ env.VERSION }}
47+
env:
48+
GITHUB_TOKEN: ${{ github.token }}
49+
50+
- name: Update version in pyproject.toml
51+
run: python .github/workflows/update_pyproject.py $(echo ${GITHUB_REF/refs\/tags\//})
52+
53+
- name: Commit and push changes
54+
run: |
55+
git config --global user.name "github-actions[bot]"
56+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
57+
git add pyproject.toml
58+
git commit -m "Update pyproject.toml"
59+
git push origin HEAD:main

.github/workflows/update_pyproject.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
import re
3+
import sys
4+
from pathlib import Path
5+
6+
if __name__ == '__main__':
7+
path = Path('pyproject.toml')
8+
content = path.read_text(encoding='utf-8')
9+
version = sys.argv[1].removeprefix('v')
10+
content = re.sub(r'version = "[0-9]+\.[0-9]+\.[0-9]+-dev"', f'version = "{version}-dev"', content)
11+
path.write_text(content, encoding='utf-8')

0 commit comments

Comments
 (0)