-
Notifications
You must be signed in to change notification settings - Fork 7
69 lines (58 loc) · 2.01 KB
/
pypi.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 Python Package
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+a[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+.dev[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+a[0-9]+.dev[0-9]+'
workflow_dispatch:
env:
POETRY_VERSION: "2.1.1"
jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/agntcy-acp
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '>=3.9'
update-environment: true
- name: Install Poetry
run: |
pipx install poetry==${{ env.POETRY_VERSION }}
- name: Validate version if tag
if: github.event_name == 'push' && github.ref_type == 'tag'
env:
TAG_NAME: ${{ github.ref_name }}
run: |
TAG="${TAG_NAME#v}"
PYPROJECT_VERSION=$(awk '/version/ { gsub("\"", ""); print $3; exit; }' pyproject.toml)
if [ ! "${PYPROJECT_VERSION}" = "${TAG%.dev*}" ]; then
echo "You created the \"${{ github.ref_name }}\" git tag; it is fine, BUT it does not match the pyproject.toml file"
exit 1
fi
# Update version to match in case it is a dev version
if [ ! "${TAG%.dev*}" = "${TAG}" ]; then
sed "s/version = \"${TAG%.dev*}\"/version = \"${TAG}\"/" pyproject.toml >pyproject.toml.bak \
&& mv pyproject.toml.bak pyproject.toml
fi
echo "Building and publishing version: ${TAG}" >> $GITHUB_STEP_SUMMARY
- name: Build package
env:
POETRY_VIRTUALENVS_IN_PROJECT: "true"
run: |
poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1