11---
2- name : Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
3- on :
4- # Only deploy if we're the result of a PR being merged
5- workflow_dispatch :
6- push :
7- branches :
8- - master
9- tags :
10- # Semantic versioning tags
11- - ' v[0-9]+.[0-9]+.[0-9]+'
12- # Date style tags
13- - ' v[0-9]{2}.[0-9]{2}'
14- jobs :
15- deploy :
16- name : Build and publish ${{ matrix.package }} 🐍
17- runs-on : ubuntu-20.04
18- timeout-minutes : 120
19- strategy :
20- fail-fast : true
21- matrix :
22- include :
23- - PACKAGE : pyln-client
24- WORKDIR : contrib/pyln-client
25- - PACKAGE : pyln-testing
26- WORKDIR : contrib/pyln-testing
27- - PACKAGE : pyln-proto
28- WORKDIR : contrib/pyln-proto
29- - PACKAGE : pyln-grpc-proto
30- WORKDIR : contrib/pyln-grpc-proto
31- # Bolt packages are handled differently
32- # - PACKAGE: pyn-bolt1
33- # WORKDIR: contrib/pyln-spec/bolt1/
34- # - PACKAGE: pyn-bolt2
35- # WORKDIR: contrib/pyln-spec/bolt2/
36- # - PACKAGE: pyn-bolt4
37- # WORKDIR: contrib/pyln-spec/bolt4/
38- # - PACKAGE: pyn-bolt7
39- # WORKDIR: contrib/pyln-spec/bolt7/
40- steps :
41- - uses : actions/checkout@v4
42- with :
43- # Need to fetch entire history in order to locate the version tag
44- fetch-depth : 0
45-
46- - name : Set up Python 3.8
47- uses : actions/setup-python@v5
48- with :
49- python-version : 3.8
50-
51- - name : Install pypa/build and poetry
52- run : >-
53- python -m pip install build poetry --user
54-
55- - name : Check version tag
56- run : >-
57- git describe --always --dirty=-modded --abbrev=7
58-
59- - name : Build a binary wheel and a source tarball
60- env :
61- WORKDIR : ${{ matrix.WORKDIR }}
62- run : |
63- export VERSION=$(git describe --abbrev=0).post$(git describe --abbrev=1 | awk -F "-" '{print $2}')
64- cd ${{ env.WORKDIR }}
65- make upgrade-version NEW_VERSION=$VERSION
66- poetry build --no-interaction
67-
68- - name : Publish distribution 📦 to Test PyPI
69- if : github.repository == 'ElementsProject/lightning' && github.ref == 'refs/heads/master'
70- env :
71- POETRY_PYPI_TOKEN_TESTPYPI : ${{ secrets.TEST_PYPI_API_TOKEN }}
72- WORKDIR : ${{ matrix.WORKDIR }}
73- run : |
74- cd ${{ env.WORKDIR }}
75- python3 -m pip config set global.timeout 150
76- poetry config repositories.testpypi https://test.pypi.org/legacy/
77- poetry build --no-interaction
78- poetry publish --repository testpypi --no-interaction --skip-existing
79-
80- - name : Publish distribution 📦 to PyPI
81- if : startsWith(github.ref, 'refs/tags/v') && github.repository == 'ElementsProject/lightning'
82- env :
83- POETRY_PYPI_TOKEN_PYPI : ${{ secrets.PYPI_API_TOKEN }}
84- WORKDIR : ${{ matrix.WORKDIR }}
85- run : |
86- cd ${{ env.WORKDIR }}
87- export VERSION=$(git describe --abbrev=0)
88- make upgrade-version NEW_VERSION=$VERSION
89- python3 -m pip config set global.timeout 150
90- poetry build --no-interaction
91- poetry publish --no-interaction
2+ name : Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
3+ on :
4+ push :
5+ tags :
6+ ' ^v[0-9]{2}\.[0-9]{2}(\.[0-9]{1,2})?$'
7+ workflow_dispatch :
8+ jobs :
9+ deploy :
10+ name : Build and publish ${{ matrix.package }} 🐍
11+ runs-on : ubuntu-20.04
12+ timeout-minutes : 120
13+ strategy :
14+ fail-fast : true
15+ matrix :
16+ include :
17+ - PACKAGE : pyln-client
18+ WORKDIR : contrib/pyln-client
19+ - PACKAGE : pyln-testing
20+ WORKDIR : contrib/pyln-testing
21+ - PACKAGE : pyln-proto
22+ WORKDIR : contrib/pyln-proto
23+ - PACKAGE : pyln-grpc-proto
24+ WORKDIR : contrib/pyln-grpc-proto
25+ steps :
26+ - name : Checkout repository
27+ uses : actions/checkout@v4
28+ with :
29+ # Need to fetch entire history in order to locate the version tag
30+ fetch-depth : 0
31+
32+ - name : Check version tag
33+ run : >-
34+ git describe --always --dirty=-modded --abbrev=7
35+
36+ - name : Setup Version
37+ env :
38+ WORKDIR : ${{ matrix.WORKDIR }}
39+ run : |
40+ echo "VERSION=$(git describe --abbrev=0).post$(git describe --abbrev=1 | awk -F "-" '{print $2}')" >> $GITHUB_ENV
41+
42+ - name : Install Poetry
43+ env :
44+ WORKDIR : ${{ matrix.WORKDIR }}
45+ run : |
46+ curl -sSL https://install.python-poetry.org | python3 -
47+ echo "$HOME/.local/bin" >> $GITHUB_PATH
48+ echo "PATH=$HOME/.local/bin:$PATH"
49+
50+ - name : Publish distribution 📦 to Test PyPI
51+ if : github.event_name == 'workflow_dispatch' && github.repository == 'ElementsProject/lightning'
52+ env :
53+ POETRY_PYPI_TOKEN_TESTPYPI : ${{ secrets.TEST_PYPI_API_TOKEN }}
54+ WORKDIR : ${{ matrix.WORKDIR }}
55+ run : |
56+ echo "POETRY VERSION TEST: $(poetry --version)"
57+ echo "Pyln* VERSION: $VERSION"
58+ cd ${{ env.WORKDIR }}
59+ python3 -m pip config set global.timeout 150
60+ poetry config repositories.testpypi https://test.pypi.org/legacy/
61+ make upgrade-version NEW_VERSION=$VERSION
62+ poetry build --no-interaction
63+ poetry publish --repository testpypi --no-interaction --skip-existing
64+
65+ - name : Publish distribution 📦 to PyPI
66+ if : startsWith(github.ref, 'refs/tags/v') && github.repository == 'ElementsProject/lightning'
67+ env :
68+ POETRY_PYPI_TOKEN_PYPI : ${{ secrets.PYPI_API_TOKEN }}
69+ WORKDIR : ${{ matrix.WORKDIR }}
70+ run : |
71+ echo "POETRY VERSION PUBLISH: $(poetry --version)"
72+ echo "Pyln* VERSION: $VERSION"
73+ cd ${{ env.WORKDIR }}
74+ export VERSION=$(git describe --abbrev=0)
75+ make upgrade-version NEW_VERSION=$VERSION
76+ python3 -m pip config set global.timeout 150
77+ poetry build --no-interaction
78+ poetry publish --no-interaction
79+
0 commit comments