Skip to content

Commit dad88af

Browse files
authored
Fix upload issue when package already existed on PyPI (#297)
* update Makefile * fix an upload issue where package already existed on PyPi * missed one place * adjust order * fix a bug
1 parent 3a88875 commit dad88af

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.github/workflows/upload.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,36 @@ jobs:
9797
run_id: ${{ inputs.run_id }}
9898
asset_identifier: 'compressed*.whl'
9999

100+
- name: check if whl is new
101+
id: check-whl
102+
uses: neuralmagic/nm-actions/actions/check-whl-on-pypi@scm
103+
with:
104+
whl: ${{ steps.find-asset-whl.outputs.asset }}
105+
100106
- name: upload whl to "nm-pypi"
101-
if: ${{ inputs.push_to_pypi }}
107+
if: ${{ inputs.push_to_pypi && steps.check-whl.outputs.status }}
102108
uses: neuralmagic/nm-actions/actions/gcp-upload-asset@v1.1.0
103109
with:
104110
bucket_target: ${{ secrets.GCP_NM_PYPI_DIST }}
105111
asset: ${{ steps.find-asset-whl.outputs.asset }}
106112

107113
- name: find tar.gz
114+
if: ${{ steps.check-whl.outputs.status }}
108115
id: find-asset-targz
109116
uses: neuralmagic/nm-actions/actions/find-asset@v1.1.0
110117
with:
111118
run_id: ${{ inputs.run_id }}
112119
asset_identifier: 'compressed*.tar.gz'
113120

114121
- name: upload tar.gz to "nm-pypi"
115-
if: ${{ inputs.push_to_pypi }}
122+
if: ${{ inputs.push_to_pypi && steps.check-whl.outputs.status }}
116123
uses: neuralmagic/nm-actions/actions/gcp-upload-asset@v1.1.0
117124
with:
118125
bucket_target: ${{ secrets.GCP_NM_PYPI_DIST }}
119126
asset: ${{ steps.find-asset-targz.outputs.asset }}
120127

121128
- name: update "nm-pypi" index
129+
if: ${{ steps.check-whl.outputs.status }}
122130
uses: actions/github-script@v6
123131
with:
124132
github-token: ${{ secrets.NM_PYPI_WORKFLOW }}
@@ -133,7 +141,7 @@ jobs:
133141
134142
# publish the wheel file to public pypi
135143
- name: push wheel to pypi.org
136-
if: ${{ inputs.push_to_pypi }}
144+
if: ${{ inputs.push_to_pypi && steps.check-whl.outputs.status }}
137145
uses: neuralmagic/nm-actions/actions/publish-whl@v1.0.0
138146
with:
139147
username: ${{ secrets.PYPI_PUBLIC_USER }}
@@ -142,7 +150,7 @@ jobs:
142150

143151
# publish the tar.gz file to public pypi
144152
- name: push wheel to pypi.org
145-
if: ${{ inputs.push_to_pypi }}
153+
if: ${{ inputs.push_to_pypi && steps.check-whl.outputs.status }}
146154
uses: neuralmagic/nm-actions/actions/publish-whl@v1.0.0
147155
with:
148156
username: ${{ secrets.PYPI_PUBLIC_USER }}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build docs test
22

3-
BUILD_ARGS := dev # set nightly to build nightly release
3+
BUILD_TYPE ?= dev # set nightly to build nightly release
44
PYCHECKDIRS := src tests
55
PYCHECKGLOBS := 'src/**/*.py' 'tests/**/*.py' 'utils/**/*.py' 'examples/**/*.py' setup.py
66
# run checks on all files for the repo
@@ -28,7 +28,7 @@ test:
2828
# creates wheel file
2929
build:
3030
@echo "Building the wheel for the repository";
31-
BUILD_TYPE=$(BUILD_ARGS) python3 setup.py sdist bdist_wheel;
31+
BUILD_TYPE=$(BUILD_TYPE) python3 setup.py sdist bdist_wheel;
3232

3333
# clean package
3434
clean:

0 commit comments

Comments
 (0)