Skip to content

Commit 90fc20e

Browse files
authored
Add Github Action to manually release package on Pypi
1 parent c8c0f74 commit 90fc20e

File tree

2 files changed

+64
-8
lines changed

2 files changed

+64
-8
lines changed

.github/workflows/release.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
name: Upload Python Package
1+
name: Manually Upload Python Package to Pypi
22

3-
on:
4-
release:
5-
types: [published]
3+
on: workflow_dispatch
64

75
permissions:
86
contents: read
@@ -44,8 +42,8 @@ jobs:
4442
id-token: write
4543

4644
environment:
47-
name: test_pypi
48-
url: https://test.pypi.org/p/toggl_python
45+
name: pypi
46+
url: https://pypi.org/p/toggl_python
4947

5048
steps:
5149
- name: Retrieve release distributions
@@ -56,5 +54,3 @@ jobs:
5654

5755
- name: Publish release distributions to PyPI
5856
uses: pypa/gh-action-pypi-publish@release/v1
59-
with:
60-
repository-url: https://test.pypi.org/legacy/

.github/workflows/test_release.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Upload Python Package to Test Pypi
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
PYTHON_VERSION: "3.8"
12+
POETRY_CORE_VERSION: "1.9.0"
13+
14+
jobs:
15+
release-build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ env.PYTHON_VERSION }}
24+
25+
- name: Build release distributions
26+
run: |
27+
python -m pip install build poetry-core==${{ env.POETRY_CORE_VERSION }}
28+
python -m build
29+
30+
- name: Upload distributions
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: release-dists
34+
path: dist/
35+
36+
pypi-publish:
37+
runs-on: ubuntu-latest
38+
39+
needs:
40+
- release-build
41+
42+
permissions:
43+
# IMPORTANT: this permission is mandatory for trusted publishing
44+
id-token: write
45+
46+
environment:
47+
name: test_pypi
48+
url: https://test.pypi.org/p/toggl_python
49+
50+
steps:
51+
- name: Retrieve release distributions
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: release-dists
55+
path: dist/
56+
57+
- name: Publish release distributions to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1
59+
with:
60+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)