Skip to content

Commit 7605490

Browse files
authored
update GitHub action upload to pypi
1 parent 9945470 commit 7605490

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

.github/workflows/pypi-package-upload-pypi.yml

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,43 @@ on:
88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11-
11+
environment: all
1212
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v2
15-
16-
- name: Set up Python
17-
uses: actions/setup-python@v2
18-
with:
19-
python-version: 3.8
20-
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install --upgrade setuptools wheel build twine
25-
26-
- name: Get current version from pyproject.toml
27-
id: get_version
28-
run: echo "::set-output name=version::$(grep -oP '(?<=version = ")[^"]*' pyproject.toml)"
29-
30-
- name: Increment version
31-
id: increment_version
32-
run: echo "::set-output name=version::$(python -c "version='${{ steps.get_version.outputs.version }}'.split('.'); version[-1] = str(int(version[-1]) + 1); print('.'.join(version))")"
33-
34-
- name: Update version in pyproject.toml
35-
run: sed -i "s/version = \".*\"/version = \"${{ steps.increment_version.outputs.version }}\"/" pyproject.toml
36-
37-
- name: Commit and push changes of pyproject.toml
38-
run: |
39-
git config user.name github-actions and push
40-
git config user.email [email protected]
41-
git add pyproject.toml
42-
git commit -m "Bump version to ${{ steps.increment_version.outputs.version }}"
43-
git push origin HEAD:${{ github.ref }}
44-
45-
46-
- name: Build and upload to PyPI
47-
run: |
48-
python -m build
49-
twine upload --password ${{ secrets.PYPI_TOKEN }} dist/*
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: 3.8
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install --upgrade setuptools wheel build twine
27+
28+
- name: Get current version from pyproject.toml
29+
id: get_version
30+
run: echo "::set-output name=version::$(grep -oP '(?<=version = ")[^"]*' pyproject.toml)"
31+
32+
- name: Increment version
33+
id: increment_version
34+
run: echo "::set-output name=version::$(python -c "version='${{ steps.get_version.outputs.version }}'.split('.'); version[-1] = str(int(version[-1]) + 1); print('.'.join(version))")"
35+
36+
- name: Update version in pyproject.toml
37+
run: sed -i "s/version = \".*\"/version = \"${{ steps.increment_version.outputs.version }}\"/" pyproject.toml
38+
39+
- name: Commit and push changes of pyproject.toml
40+
run: |
41+
git config user.name github-actions
42+
git config user.email [email protected]
43+
git add pyproject.toml
44+
git commit -m "Bump version to ${{ steps.increment_version.outputs.version }}"
45+
git push origin HEAD:${{ github.ref }}
46+
47+
- name: Build and upload to PyPI
48+
run: |
49+
python -m build
50+
twine upload --password ${{ secrets.PYPI_TOKEN }} dist/*

0 commit comments

Comments
 (0)