ci(release): upsert release and replace matching assets
All checks were successful
Push Validation / validate (push) Successful in 52s
All checks were successful
Push Validation / validate (push) Successful in 52s
This commit is contained in:
@@ -128,16 +128,17 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
curl --fail-with-body \
|
curl --fail-with-body \
|
||||||
-X DELETE \
|
-X PATCH \
|
||||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${release_api}/${existing_release_id}"
|
"${release_api}/${existing_release_id}" \
|
||||||
|
--data "{\"tag_name\":\"${tag}\",\"target\":\"${GITHUB_SHA}\",\"name\":\"${tag}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
--output release.json
|
||||||
elif [[ "$status_code" != "404" ]]; then
|
elif [[ "$status_code" != "404" ]]; then
|
||||||
echo "Unexpected response while checking release ${tag}: HTTP ${status_code}" >&2
|
echo "Unexpected response while checking release ${tag}: HTTP ${status_code}" >&2
|
||||||
cat release-existing.json >&2
|
cat release-existing.json >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
else
|
||||||
|
|
||||||
curl --fail-with-body \
|
curl --fail-with-body \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||||
@@ -145,6 +146,7 @@ jobs:
|
|||||||
"${release_api}" \
|
"${release_api}" \
|
||||||
--data "{\"tag_name\":\"${tag}\",\"target\":\"${GITHUB_SHA}\",\"name\":\"${tag}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
--data "{\"tag_name\":\"${tag}\",\"target\":\"${GITHUB_SHA}\",\"name\":\"${tag}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
--output release.json
|
--output release.json
|
||||||
|
fi
|
||||||
|
|
||||||
release_id="$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' release.json | head -n 1)"
|
release_id="$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' release.json | head -n 1)"
|
||||||
if [[ -z "$release_id" ]]; then
|
if [[ -z "$release_id" ]]; then
|
||||||
@@ -194,6 +196,23 @@ jobs:
|
|||||||
|
|
||||||
for asset in dist/*; do
|
for asset in dist/*; do
|
||||||
name="$(basename "$asset")"
|
name="$(basename "$asset")"
|
||||||
|
|
||||||
|
assets_json="$(curl -sS --fail-with-body \
|
||||||
|
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"${release_api}")"
|
||||||
|
|
||||||
|
escaped_name="$(printf '%s' "$name" | sed 's/[][(){}.^$*+?|\\/]/\\&/g')"
|
||||||
|
existing_asset_id="$(printf '%s' "$assets_json" | tr -d '\n' | sed -n "s/.*{\"id\":\([0-9][0-9]*\)[^}]*\"name\":\"${escaped_name}\".*/\1/p")"
|
||||||
|
|
||||||
|
if [[ -n "$existing_asset_id" ]]; then
|
||||||
|
curl --fail-with-body \
|
||||||
|
-X DELETE \
|
||||||
|
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"${release_api}/${existing_asset_id}"
|
||||||
|
fi
|
||||||
|
|
||||||
curl --fail-with-body \
|
curl --fail-with-body \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ The `Prepare Release` workflow creates a release and uploads prebuilt `vociferat
|
|||||||
- `windows/arm64`
|
- `windows/arm64`
|
||||||
|
|
||||||
It also uploads `checksums.txt` for integrity verification.
|
It also uploads `checksums.txt` for integrity verification.
|
||||||
If a release already exists for the same tag, the workflow replaces it so release notes and attached binaries stay in sync.
|
If a release already exists for the same tag, the workflow updates its release notes and replaces matching asset filenames so reruns stay in sync.
|
||||||
|
|
||||||
## Reuse In Other Repositories
|
## Reuse In Other Repositories
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user