-
Notifications
You must be signed in to change notification settings - Fork 793
74 lines (62 loc) · 2.16 KB
/
release.yml
File metadata and controls
74 lines (62 loc) · 2.16 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
name: Release
on:
pull_request:
types: [closed]
branches: [main]
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv venv
uv pip install -e .
uv pip install hatch
- name: Build package
run: uv run hatch build
- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create git tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag v${{ steps.get_version.outputs.VERSION }}
git push origin v${{ steps.get_version.outputs.VERSION }}
- name: Publish draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Check if draft release exists and publish it
if gh release view v${{ steps.get_version.outputs.VERSION }} --json isDraft | jq -r '.isDraft' | grep -q true; then
gh release edit v${{ steps.get_version.outputs.VERSION }} --draft=false
else
echo "::error::No draft release found for v${{ steps.get_version.outputs.VERSION }}"
exit 1
fi
- name: Upload assets to release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload v${{ steps.get_version.outputs.VERSION }} dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_ART_TOKEN }}