Skip to content

Commit 06eac15

Browse files
Update publish-to-pypi.yml
1 parent 67c3225 commit 06eac15

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

publish-to-pypi.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ on:
6060
#
6161
env:
6262

63-
# relative path to your file, e.g.
63+
# relative path to the file containing your version info, e.g.
6464
# ./MyLib/MyLib.py
6565
SOURCE_FILE: ./REPLACE/ME
6666

@@ -94,13 +94,13 @@ jobs:
9494
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
9595
- uses: actions/checkout@v5
9696

97-
# Read source file
97+
# Read source file with version info
9898
- name: Read source file
9999
id: reader
100100
uses: juliangruber/read-file-action@v1
101101
with:
102102
path: ${{ env.SOURCE_FILE }}
103-
# Run regex on content and try to get the version data
103+
# Run regex on file content and try to get the version data
104104
- name: get version via regex
105105
id: regex
106106
uses: kaisugi/action-regex-match@v1.0.1
@@ -171,10 +171,16 @@ jobs:
171171
run: |
172172
python -m pip install --upgrade pip
173173
pip install build
174+
175+
# Export the program version; content will be picked up by the setup.py script
176+
- name: Export program version
177+
run: echo GITHUB_PROGRAM_VERSION='${{ needs.get-python-version-info.outputs.my-program-version }}' >> $GITHUB_ENV
178+
174179
# Build the package. The export MUST be part of THIS step
175180
# Otherwise, the Python setup job will not see this information
176181
- name: Build package
177-
run: export GITHUB_PROGRAM_VERSION='${{ needs.get-python-version-info.outputs.my-program-version }}';python -m build
182+
run: python -m build
183+
178184
# Publish everything to Test PyPi
179185
# Unlike for the Prod branch, we will push both releases and prerelease to PyPi Test
180186
- name: Publish package to Test PyPi
@@ -184,6 +190,7 @@ jobs:
184190
user: __token__
185191
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
186192
repository-url: https://test.pypi.org/legacy/
193+
187194
# Publish everything to Prod PyPi but only if it is not a prerelease
188195
- name: Publish package to Prod PyPi
189196
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease
@@ -194,4 +201,3 @@ jobs:
194201
#
195202
# END of Job 2
196203
#
197-

0 commit comments

Comments
 (0)