Skip to content

Commit 53ffa96

Browse files
committed
add release gh action
add tag on release restrict action to main
1 parent eadd76b commit 53ffa96

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
id-token: write
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
if: github.ref == 'refs/heads/main'
14+
environment: pypi
15+
steps:
16+
- uses: actions/checkout@v6
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v8.0.0
22+
with:
23+
python-version: "3.12"
24+
25+
- name: Get version
26+
id: version
27+
run: |
28+
VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
29+
echo "version=$VERSION" >> $GITHUB_OUTPUT
30+
31+
- name: Check version not already published
32+
run: |
33+
VERSION="${{ steps.version.outputs.version }}"
34+
if uv pip index versions designer-plugin 2>/dev/null | grep -q "$VERSION"; then
35+
echo "Version $VERSION already exists on PyPI. Aborting."
36+
exit 1
37+
fi
38+
39+
- name: Build package
40+
run: uv build
41+
42+
- name: Tag release
43+
run: |
44+
git config user.name "github-actions[bot]"
45+
git config user.email "github-actions[bot]@users.noreply.github.com"
46+
git tag "v${{ steps.version.outputs.version }}" || echo "Tag already exists, skipping"
47+
git push origin "v${{ steps.version.outputs.version }}" || echo "Tag already pushed, skipping"
48+
49+
- name: Publish to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)