-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (55 loc) · 1.9 KB
/
build.yml
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
name: Python package
permissions:
contents: write
on:
push:
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'
- name: Install dependencies
run: poetry install
- name: Run linting
run: poetry run pre-commit run --all-files
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry self add "poetry-dynamic-versioning[plugin]" --no-interaction
poetry config pypi-token.pypi $PYPI_TOKEN
# Split package name and version by space
read -r PACKAGE_NAME PACKAGE_VERSION <<< "$(poetry version --no-ansi)"
echo "PACKAGE_NAME=$PACKAGE_NAME" >> "$GITHUB_ENV"
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_ENV"
poetry publish --build --no-interaction && echo "published=1" >> "$GITHUB_ENV" || echo "published=0" >> "$GITHUB_ENV"
- name: Check if published
run: |
if [ "$published" = "1" ]; then
echo "Published to PyPI"
else
echo "Failed to publish to PyPI"
exit 1
fi
- name: Make release with docset
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body: |
This is a release for the ${{ github.ref }} tag.
PyPi package: [${{ env.PACKAGE_NAME }}==${{ env.PACKAGE_VERSION }}](https://pypi.org/project/${{ env.PACKAGE_NAME }}/${{ env.PACKAGE_VERSION }})
draft: false
prerelease: false
generate_release_notes: true
append_body: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}