Make package publishing idempotent [skip ci]
This commit is contained in:
@@ -112,6 +112,14 @@ jobs:
|
|||||||
package_url="$package_server/api/packages/$GITEA_OWNER/generic/bdrclone/$package_version"
|
package_url="$package_server/api/packages/$GITEA_OWNER/generic/bdrclone/$package_version"
|
||||||
|
|
||||||
for package_file in dist/*.tar.gz dist/SHA256SUMS; do
|
for package_file in dist/*.tar.gz dist/SHA256SUMS; do
|
||||||
|
package_file_url="$package_url/$(basename "$package_file")"
|
||||||
|
if curl --fail --silent --head \
|
||||||
|
--header "Authorization: token $GITEA_TOKEN" \
|
||||||
|
--header "Host: $gitea_host" \
|
||||||
|
"$package_file_url" >/dev/null; then
|
||||||
|
echo "Package file already exists: $(basename "$package_file")"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
curl --fail-with-body --silent --show-error \
|
curl --fail-with-body --silent --show-error \
|
||||||
--retry 5 --retry-all-errors --retry-delay 3 \
|
--retry 5 --retry-all-errors --retry-delay 3 \
|
||||||
--connect-timeout 20 --max-time 300 \
|
--connect-timeout 20 --max-time 300 \
|
||||||
@@ -119,9 +127,17 @@ jobs:
|
|||||||
--header "Authorization: token $GITEA_TOKEN" \
|
--header "Authorization: token $GITEA_TOKEN" \
|
||||||
--header "Host: $gitea_host" \
|
--header "Host: $gitea_host" \
|
||||||
--upload-file "$package_file" \
|
--upload-file "$package_file" \
|
||||||
"$package_url/$(basename "$package_file")"
|
"$package_file_url"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
linked_repository="$(
|
||||||
|
curl --fail --silent --show-error \
|
||||||
|
--header "Authorization: token $GITEA_TOKEN" \
|
||||||
|
--header "Host: $gitea_host" \
|
||||||
|
"$package_server/api/v1/packages/$GITEA_OWNER/generic/bdrclone/$package_version" \
|
||||||
|
| jq --raw-output '.repository.full_name // ""'
|
||||||
|
)"
|
||||||
|
if [[ "$linked_repository" != "$GITEA_REPOSITORY" ]]; then
|
||||||
curl --fail-with-body --silent --show-error \
|
curl --fail-with-body --silent --show-error \
|
||||||
--retry 5 --retry-all-errors --retry-delay 3 \
|
--retry 5 --retry-all-errors --retry-delay 3 \
|
||||||
--connect-timeout 20 --max-time 300 \
|
--connect-timeout 20 --max-time 300 \
|
||||||
@@ -129,6 +145,7 @@ jobs:
|
|||||||
--header "Authorization: token $GITEA_TOKEN" \
|
--header "Authorization: token $GITEA_TOKEN" \
|
||||||
--header "Host: $gitea_host" \
|
--header "Host: $gitea_host" \
|
||||||
"$package_server/api/v1/packages/$GITEA_OWNER/generic/bdrclone/-/link/$repository_name"
|
"$package_server/api/v1/packages/$GITEA_OWNER/generic/bdrclone/-/link/$repository_name"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Upload temporary build artifacts
|
- name: Upload temporary build artifacts
|
||||||
if: ${{ !startsWith(github.ref, 'refs/tags/v') && inputs.publish_version == '' }}
|
if: ${{ !startsWith(github.ref, 'refs/tags/v') && inputs.publish_version == '' }}
|
||||||
|
|||||||
Reference in New Issue
Block a user