1
- # This workflow will upload a Python Package using Twine when a release is created
2
- # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3
-
4
- # This workflow uses actions that are not certified by GitHub.
5
- # They are provided by a third-party and are governed by
6
- # separate terms of service, privacy policy, and support
7
- # documentation.
8
-
9
- name : Upload Python Package
1
+ name : Release
10
2
11
3
on :
12
4
release :
13
5
types : [published]
6
+ push :
7
+ tags :
8
+ - ' *.*.*'
9
+
10
+ env :
11
+ # Change these for your project's URLs
12
+ PYPI_URL : https://pypi.org/p/django-tasks-scheduler
13
+ PYPI_TEST_URL : https://test.pypi.org/p/django-tasks-scheduler
14
14
15
15
jobs :
16
- publish :
16
+
17
+ build :
18
+ name : Build distribution 📦
17
19
runs-on : ubuntu-latest
18
- permissions :
19
- id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
20
20
21
21
steps :
22
22
- uses : actions/checkout@v4
23
-
24
23
- name : Set up Python
25
24
uses : actions/setup-python@v5
26
25
with :
27
- python-version : ' 3.12'
28
- cache-dependency-path : poetry.lock
26
+ python-version : " 3.12"
27
+ - name : Install pypa/build
28
+ run :
29
+ python3 -m pip install build --user
30
+ - name : Build a binary wheel and a source tarball
31
+ run : python3 -m build
32
+ - name : Store the distribution packages
33
+ uses : actions/upload-artifact@v4
34
+ with :
35
+ name : python-package-distributions
36
+ path : dist/
29
37
30
- - name : Install dependencies
31
- run : |
32
- python -m pip install --upgrade pip
33
- pip install build
38
+ publish-to-pypi :
39
+ name : >-
40
+ Publish Python 🐍 distribution 📦 to PyPI
41
+ if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
42
+ needs :
43
+ - build
44
+ runs-on : ubuntu-latest
45
+ environment :
46
+ name : pypi
47
+ url : ${{ env.PYPI_URL }}
48
+ permissions :
49
+ id-token : write # IMPORTANT: mandatory for trusted publishing
50
+ steps :
51
+ - name : Download all the dists
52
+ uses : actions/download-artifact@v4
53
+ with :
54
+ name : python-package-distributions
55
+ path : dist/
56
+ - name : Publish distribution 📦 to PyPI
57
+ uses : pypa/gh-action-pypi-publish@release/v1
58
+
59
+ publish-to-testpypi :
60
+ name : Publish Python 🐍 distribution 📦 to TestPyPI
61
+ needs :
62
+ - build
63
+ runs-on : ubuntu-latest
34
64
35
- - name : Build package
36
- run : python -m build
65
+ environment :
66
+ name : testpypi
67
+ url : ${{ env.PYPI_TEST_URL }}
37
68
38
- - name : Publish package to pypi
39
-
69
+ permissions :
70
+ id-token : write # IMPORTANT: mandatory for trusted publishing
71
+
72
+ steps :
73
+ - name : Download all the dists
74
+ uses : actions/download-artifact@v4
75
+ with :
76
+ name : python-package-distributions
77
+ path : dist/
78
+ - name : Publish distribution 📦 to TestPyPI
79
+ uses : pypa/gh-action-pypi-publish@release/v1
40
80
with :
41
- print-hash : true
81
+ repository-url : https://test.pypi.org/legacy/
82
+ skip-existing : true
0 commit comments