Skip to content

Commit ed7e687

Browse files
committed
Add publish job
1 parent 0ea5c02 commit ed7e687

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
jobs:
8+
build-and-publish:
9+
name: Build and Publish
10+
environment: protected
11+
permissions:
12+
contents: read
13+
id-token: write
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
21+
with:
22+
python-version: "3.10"
23+
24+
- name: Install Poetry
25+
uses: abatilo/actions-poetry@e78f54a89cb052fff327414dd9ff010b5d2b4dbd
26+
27+
- name: Configure Poetry
28+
run: |
29+
poetry config virtualenvs.create true --local
30+
poetry config virtualenvs.in-project true --local
31+
32+
- name: Install package
33+
run: poetry install
34+
35+
- name: Validate version
36+
run: |
37+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
38+
POETRY_VERSION=$(poetry version -s)
39+
40+
if [ "$TAG_VERSION" != "$POETRY_VERSION" ]; then
41+
echo "Tag ($TAG_VERSION) doesn't match pyproject.toml ($POETRY_VERSION)"
42+
exit 1
43+
fi
44+
45+
- name: Build package
46+
run: poetry build
47+
48+
- name: Publish to PyPI
49+
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc

0 commit comments

Comments
 (0)