@@ -31,12 +31,16 @@ jobs:
3131
3232 - name : Run Bump script
3333 id : bump
34+ shell : bash
3435 run : |
36+ set -e
3537 NEW_VERSION=$(python bump_version.py libcrypto)
3638 echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
3739
3840 - name : Bump version (commit)
41+ shell : bash
3942 run : |
43+ set -e
4044 git config --global user.name 'github-actions'
4145 git config --global user.email '[email protected] ' 4246 git add setup.py pyproject.toml src/libcrypto/__init__.py
@@ -69,10 +73,22 @@ jobs:
6973 run : |
7074 twine check dist/*
7175
76+ - name : Upload distributions
77+ if : success()
78+ uses : actions/upload-artifact@v4
79+ with :
80+ name : python-package-distributions
81+ path : dist/
82+
7283 publish-to-pypi :
73- name : Publish to PyPI
7484 needs : build
85+ name : Publish to PyPI
7586 runs-on : ubuntu-latest
87+ environment :
88+ name : pypi
89+ url : https://pypi.org/p/libcrypto
90+ permissions :
91+ id-token : write
7692 steps :
7793 - name : Download distribution artifacts
7894 uses : actions/download-artifact@v4
@@ -88,16 +104,21 @@ jobs:
88104 verbose : true
89105
90106 create-github-release :
91- name : Create GitHub Release
92107 needs : publish-to-pypi
108+ name : Create GitHub Release
93109 runs-on : ubuntu-latest
94- if : github.event_name == 'workflow_dispatch'
110+ if : github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
95111 permissions :
96112 contents : write
97113 steps :
98114 - name : Checkout repository
99115 uses : actions/checkout@v4
100116
117+ - name : Derive version from tag (optional)
118+ if : github.event_name == 'workflow_dispatch'
119+ run : |
120+ echo "NEW_VERSION=${{ needs.build.outputs.new_version }}" >> $GITHUB_ENV
121+
101122 - name : Create GitHub Release
102123 id : create_release
103124 uses : softprops/action-gh-release@v2
@@ -128,7 +149,7 @@ jobs:
128149 ```bash
129150 pip3 install libcrypto
130151 # or
131- pip3 install libcrypto==${{ needs.build.outputs.new_version }}
152+ pip install libcrypto==${{ needs.build.outputs.new_version }}
132153 ```
133154
134155 ##### upgrade : `pip3 install libcrypto --upgrade`
0 commit comments