1 file changed
+19
.github/workflows/release-pypi.yml
+19
@@ -183,6 +183,17 @@ jobs:
183
- name: Checkout
184
uses: actions/checkout@v6
185
186
+ - name: Set the release version
187
+ shell: bash
188
+ run: |
189
+ if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
190
+ release_version="${GITHUB_REF_NAME#v}"
191
+ else
192
+ release_version="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/cli/Cargo.toml | head -n 1)"
193
+ fi
194
+
195
+ echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV"
196
+
197
- name: Download distribution artifacts
198
uses: actions/download-artifact@v4
199
with:
@@ -190,5 +201,13 @@ jobs:
201
path: dist
202
merge-multiple: true
203
204
+ - name: Check whether release already exists on PyPI
205
+ shell: bash
206
+ run: |
207
+ if curl -fsS "https://pypi.org/pypi/smbcloud-cli/${RELEASE_VERSION}/json" >/dev/null 2>&1; then
208
+ echo "smbcloud-cli ${RELEASE_VERSION} already exists on PyPI, skipping publish"
209
+ exit 0
210
+ fi
211
+
212
- name: Publish distribution
213
uses: pypa/gh-action-pypi-publish@release/v1