fix(release): unwrap teacup token inputs and correct failure summary
Normalize %touch docker-compose.yml(string=...) wrapped token values in publish composite before API calls. This prevents malformed Authorization headers under teacup. Also only print 'Release Published' summary when the publish step succeeds, and print a failure summary otherwise.
This commit is contained in:
@@ -298,16 +298,26 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TAG_NAME: ${{ steps.publish.outputs.tag }}
|
TAG_NAME: ${{ steps.publish.outputs.tag }}
|
||||||
RELEASE_VERSION: ${{ steps.publish.outputs.version }}
|
RELEASE_VERSION: ${{ steps.publish.outputs.version }}
|
||||||
|
PUBLISH_OUTCOME: ${{ steps.publish.outcome }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
{
|
if [[ "${PUBLISH_OUTCOME}" == "success" ]]; then
|
||||||
echo "## Release Published"
|
{
|
||||||
echo
|
echo "## Release Published"
|
||||||
echo "- Tag: ${TAG_NAME}"
|
echo
|
||||||
echo "- Release notes sourced from changelog entry ${RELEASE_VERSION}."
|
echo "- Tag: ${TAG_NAME}"
|
||||||
echo "- Published assets: vociferate_${RELEASE_VERSION}_linux_amd64, vociferate_${RELEASE_VERSION}_linux_arm64, checksums.txt"
|
echo "- Release notes sourced from changelog entry ${RELEASE_VERSION}."
|
||||||
} >> "$SUMMARY_FILE"
|
echo "- Published assets: vociferate_${RELEASE_VERSION}_linux_amd64, vociferate_${RELEASE_VERSION}_linux_arm64, checksums.txt"
|
||||||
|
} >> "$SUMMARY_FILE"
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "## Release Failed"
|
||||||
|
echo
|
||||||
|
echo "- Tag: ${TAG_NAME:-unknown}"
|
||||||
|
echo "- Create or update release step did not complete successfully."
|
||||||
|
} >> "$SUMMARY_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
echo 'Summary'
|
echo 'Summary'
|
||||||
echo
|
echo
|
||||||
|
|||||||
@@ -99,7 +99,13 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if [[ -z "${TOKEN:-}" ]]; then
|
raw_token="$(printf '%s' "${TOKEN:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||||
|
if [[ "$raw_token" =~ ^%\!t\(string=(.*)\)$ ]]; then
|
||||||
|
raw_token="${BASH_REMATCH[1]}"
|
||||||
|
fi
|
||||||
|
api_token="$(printf '%s' "$raw_token" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||||
|
|
||||||
|
if [[ -z "$api_token" ]]; then
|
||||||
echo "inputs.token is required (set to secrets.RELEASE_PAT)." >&2
|
echo "inputs.token is required (set to secrets.RELEASE_PAT)." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -110,7 +116,7 @@ runs:
|
|||||||
release_by_tag_api="${release_api}/tags/${TAG_NAME}"
|
release_by_tag_api="${release_api}/tags/${TAG_NAME}"
|
||||||
|
|
||||||
status_code="$(curl -sS -o release-existing.json -w '%{http_code}' \
|
status_code="$(curl -sS -o release-existing.json -w '%{http_code}' \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${api_token}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${release_by_tag_api}")"
|
"${release_by_tag_api}")"
|
||||||
|
|
||||||
@@ -122,13 +128,16 @@ runs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl --fail-with-body \
|
if ! curl --fail-with-body \
|
||||||
-X PATCH \
|
-X PATCH \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${api_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_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
--data "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
--output release.json
|
--output release.json; then
|
||||||
|
cat release.json >&2 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "id=$existing_release_id" >> "$GITHUB_OUTPUT"
|
echo "id=$existing_release_id" >> "$GITHUB_OUTPUT"
|
||||||
elif [[ "$status_code" != "404" ]]; then
|
elif [[ "$status_code" != "404" ]]; then
|
||||||
@@ -136,13 +145,16 @@ runs:
|
|||||||
cat release-existing.json >&2
|
cat release-existing.json >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
curl --fail-with-body \
|
if ! curl --fail-with-body \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${api_token}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${release_api}" \
|
"${release_api}" \
|
||||||
--data "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
--data "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
--output release.json
|
--output release.json; then
|
||||||
|
cat release.json >&2 || true
|
||||||
|
exit 1
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user