generated from samuelint/python-poetry-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (60 loc) · 1.72 KB
/
publish.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
name: Publish to PyPI
env:
PYPI_PACKAGE_NAME: langchain_llamacpp_chat_model
on:
release:
types:
- created
jobs:
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
steps:
- name: Extract version from tag
id: extract_version
run: |
TAG_NAME=${{ github.event.release.tag_name }}
if [[ $TAG_NAME =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
VERSION=${BASH_REMATCH[1]}
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "The tag $TAG_NAME is not in the expected format 'v<MAJOR>.<MINOR>.<PATCH>'"
exit 1
fi
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Update version in pyproject.toml
run: |
poetry version ${{ env.VERSION }}
# Models should be stored using LFS or downloaded in the pipeline for tests to be run
# - name: Run tests
# run: |
# poetry run pytest
- name: Build
run: |
poetry build
- uses: actions/upload-artifact@v4
with:
path: ./dist
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Bump version to ${{ env.VERSION }}
branch: main
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist