Fix Go and Python package publishing workflows
This commit is contained in:
1 parent
72a5e289f6
commit
752f3ba433
2 files changed
+56
-6
No files matched your search
@@ -37,6 +37,38 @@ jobs:
|
||||
python -m pip install --disable-pip-version-check --no-cache-dir build twine
|
||||
package_directory="$RUNNER_TEMP/gitea-pypi-package"
|
||||
python -m build packages/python-backend --outdir "$package_directory"
|
||||
package_index_url="${TWINE_REPOSITORY_URL%/}/simple/gabriel20xx-shared-backend/"
|
||||
package_index_file="$(mktemp)"
|
||||
package_index_status="$(curl --silent --show-error --fail-with-body \
|
||||
--user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
|
||||
--output "$package_index_file" \
|
||||
--write-out '%{http_code}' \
|
||||
"$package_index_url" || true)"
|
||||
package_files=("$package_directory"/*)
|
||||
files_to_upload=()
|
||||
case "$package_index_status" in
|
||||
200)
|
||||
for package_file in "${package_files[@]}"; do
|
||||
if ! grep -Fq "$(basename "$package_file")" "$package_index_file"; then
|
||||
files_to_upload+=("$package_file")
|
||||
fi
|
||||
done
|
||||
;;
|
||||
404)
|
||||
files_to_upload=("${package_files[@]}")
|
||||
;;
|
||||
*)
|
||||
cat "$package_index_file" >&2
|
||||
echo "Gitea PyPI package lookup failed with HTTP status $package_index_status." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if [ "${#files_to_upload[@]}" -eq 0 ]; then
|
||||
echo 'Python package version already exists with all build artifacts; leaving it unchanged.'
|
||||
exit 0
|
||||
fi
|
||||
TWINE_USERNAME="$PACKAGE_REGISTRY_USERNAME" \
|
||||
TWINE_PASSWORD="$PACKAGE_REGISTRY_TOKEN" \
|
||||
python -m twine upload --non-interactive --skip-existing "$package_directory"/*
|
||||
python -m twine upload --non-interactive \
|
||||
--repository-url "$TWINE_REPOSITORY_URL" \
|
||||
"${files_to_upload[@]}"
|
||||
Reference in new issue
Block a user