Skip to content

Commit 2241beb

Browse files
authored
Update publish-to-pypi.yml
1 parent 9a93662 commit 2241beb

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,38 @@ name: Publish Package to PyPI and TestPyPI
33
on:
44
workflow_dispatch:
55
push:
6-
tags:
7-
- '*'
6+
paths:
7+
- pyproject.toml
8+
9+
jobs:
10+
create-tag:
11+
name: Create tag from new version
12+
runs-on: "ubuntu-latest"
13+
needs:
14+
- build
15+
steps:
16+
- name: Check out package
17+
uses: actions/checkout@v4
18+
19+
- name: Get package version
20+
run: |
21+
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)
22+
echo "pyproject.toml version: $VERSION"
23+
git config user.name github-actions
24+
git config user.email [email protected]
25+
MSG=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline)
26+
echo "Creating tag $VERSION with message:"
27+
echo "$MSG"
28+
git tag -a "$VERSION" -m "$MSG"
29+
30+
- name: Publish tags
31+
run: git push --tags
832

9-
jobs:
1033
build:
1134
name: Build Package
1235
runs-on: ubuntu-latest
13-
36+
needs:
37+
- create-tag
1438
steps:
1539
- uses: actions/checkout@v4
1640
with:
@@ -32,7 +56,7 @@ jobs:
3256
with:
3357
name: python-package-distributions
3458
path: dist/
35-
59+
3660
publish-to-pypi:
3761
name: >-
3862
Publish Package to PyPI

0 commit comments

Comments
 (0)