1+ name : Publish to PyPI and TestPyPI
2+
3+ on : push
4+
5+ jobs :
6+ build :
7+ name : Build Distribution Package
8+ runs-on : ubuntu-latest
9+ steps :
10+ - uses : actions/checkout@v4
11+ - name : Set up Python 3.12
12+ uses : actions/setup-python@v2
13+ with :
14+ python-version : 3.12
15+ - name : Install dependencies and build package
16+ run : |
17+ python3 -m pip install --upgrade pip
18+ python3 -m pip install poetry
19+ python3 -m poetry install
20+ python3 -m poetry build
21+ - name : Store the distribution packages
22+ uses : actions/upload-artifact@v4
23+ with :
24+ name : python-distribution-packages
25+ path : dist/*
26+ publish-testpypi :
27+ name : Publish to TestPyPI
28+ needs : build
29+ runs-on : ubuntu-latest
30+ environment :
31+ name : testpypi
32+ url : https://test.pypi.org/p/torchvinecopulib/
33+ permissions :
34+ id-token : write
35+ # contents: write
36+
37+ steps :
38+ - name : Download the distribution packages
39+ uses : actions/download-artifact@v4
40+ with :
41+ name : python-distribution-packages
42+ path : dist/
43+ - name : Publish distribution
44+ uses : pypa/gh-action-pypi-publish@release/v1
45+ with :
46+ verbose : true
47+ skip-existing : true
48+ repository-url : https://test.pypi.org/legacy/
49+
50+ publish-pypi :
51+ name : Publish to PyPI
52+ if : startsWith(github.ref, 'refs/tags/')
53+ needs : publish-testpypi
54+ runs-on : ubuntu-latest
55+ environment :
56+ name : pypi
57+ url : https://pypi.org/project/torchvinecopulib/
58+ permissions :
59+ id-token : write
60+ # contents: write
61+
62+ steps :
63+ - name : Download the distribution packages
64+ uses : actions/download-artifact@v4
65+ with :
66+ name : python-distribution-packages
67+ path : dist/
68+ - name : Publish distribution
69+ uses : pypa/gh-action-pypi-publish@release/v1
70+ with :
71+ verbose : true
72+ skip-existing : true
73+
74+ github-release :
75+ name : Create GitHub Release
76+ if : startsWith(github.ref, 'refs/tags/')
77+ needs : publish-testpypi
78+ runs-on : ubuntu-latest
79+ permissions :
80+ id-token : write
81+ contents : write
82+
83+ steps :
84+ - name : Download the distribution packages
85+ uses : actions/download-artifact@v4
86+ with :
87+ name : python-distribution-packages
88+ path : dist/
89+ - name : Sign the distribution packages
90+ 91+ with :
92+ inputs : >-
93+ ./dist/*.tar.gz
94+ ./dist/*.whl
95+ - name : Github Release
96+ env :
97+ GITHUB_TOKEN : ${{ github.token }}
98+ run : >-
99+ gh release create
100+ '${{ github.ref_name }}'
101+ --repo '${{ github.repository }}'
102+ --notes ""
0 commit comments