Ask for the scope creating a release actually needs, and say when it is refused
CI / test (push) Has been cancelled
CI / test (push) Has been cancelled
The first v0.6.0 run built every binary, including the NVML one, and then stopped at "could not find or create the release". Two things were wrong. `releases: write` is not enough to create one. Creating a release can create its tag, which is a code-unit operation; `contents` is the scope that covers code and releases together. And the step threw away the answer. It piped the response through sed looking for an id and, finding none, reported only that it had failed — so a refusal, a malformed request and an unreachable server all produced the same line. It now prints the status code and the body, which is how the above was diagnosed at all: by reading a log, not by knowing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a2b3f63a0d
commit
4815a50c94
1 file changed
+14
-5
@@ -16,10 +16,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
# The built-in token every job is given carries whatever the instance's
|
||||
# default mode allows, and under the restricted default that is read-only
|
||||
# on releases — so the build would succeed and the upload would 403. Asking
|
||||
# for the one scope this needs works under either default.
|
||||
# on releases — so the build would succeed and the publish would be
|
||||
# refused. `contents` covers code and releases together, which is what
|
||||
# creating a release needs: `releases: write` alone was refused, because
|
||||
# creating one can create its tag.
|
||||
permissions:
|
||||
releases: write
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -113,10 +115,17 @@ jobs:
|
||||
| sed -n 's/.*"id":\([0-9]*\).*/\1/p' | head -1)
|
||||
if [ -z "$id" ]; then
|
||||
echo "creating release $tag"
|
||||
id=$(curl -sS -X POST -H "Authorization: token $TOKEN" \
|
||||
body=$(curl -sS -w '\n%{http_code}' -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$tag\",\"name\":\"$tag\"}" \
|
||||
"$api/releases" | sed -n 's/.*"id":\([0-9]*\).*/\1/p' | head -1)
|
||||
"$api/releases")
|
||||
code=$(printf '%s' "$body" | tail -1)
|
||||
echo "create returned $code"
|
||||
id=$(printf '%s' "$body" | sed -n 's/.*"id":\([0-9]*\).*/\1/p' | head -1)
|
||||
# Whatever went wrong, the server said so, and the previous version
|
||||
# of this step threw that away and reported only that it had failed.
|
||||
[ -n "$id" ] || printf '%s\n' "$body" | head -5 >&2
|
||||
fi
|
||||
[ -n "$id" ] || { echo "could not find or create the release" >&2; exit 1; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user