ci(release): delete dangling tags from the publish job
The sibling cleanup job ran after a successful v0.1.0 publish (run 135) because act leaves needs.publish.result unset, so != success is true. It Early-terminated before deleting, but that is not a guard. Fold fail-closed delete into publish as if: failure() and drop the extra job.
This commit is contained in:
parent
9b7e72b257
commit
30b0294c2b
1 changed files with 10 additions and 12 deletions
|
|
@ -292,12 +292,15 @@ jobs:
|
|||
|
||||
publish:
|
||||
needs: [version, aarch64, x86_64]
|
||||
# Always run after version so cleanup can need this job without Forgejo
|
||||
# act dying on "'runs-on' key not defined" for a skipped publish.
|
||||
# Always run after version so a failed build still hits the fail-closed
|
||||
# delete step (a skipped publish left act without a job result).
|
||||
# Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and
|
||||
# android-release sat in front of run 116's publish for ~1h; the Pi
|
||||
# already created the tag over the public API (version job), so publish
|
||||
# uses that same path. This job only curls the Forgejo API — no docker CLI.
|
||||
# Fail-closed tag delete lives as a step here: a sibling cleanup job ran
|
||||
# after a successful publish (act treats needs.publish.result as unset, so
|
||||
# != success) and Early-terminated on run 135. Do not restore that job.
|
||||
if: always() && needs.version.result == 'success'
|
||||
runs-on: docker
|
||||
timeout-minutes: 20
|
||||
|
|
@ -372,13 +375,8 @@ jobs:
|
|||
dist/onionwire-x86_64-unknown-linux-gnu \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
|
||||
cleanup:
|
||||
needs: [version, aarch64, x86_64, publish]
|
||||
if: ${{ always() && needs.version.result == 'success' && needs.version.outputs.created_tag == 'true' && needs.publish.result != 'success' }}
|
||||
runs-on: docker
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Delete tag and incomplete release we created
|
||||
- name: Delete tag we created if this job failed
|
||||
if: failure() && needs.version.outputs.created_tag == 'true' && needs.version.outputs.dry_run != 'true'
|
||||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
|
|
@ -388,19 +386,19 @@ jobs:
|
|||
FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n')
|
||||
echo "fail-closed: removing tag $TAG created by this run"
|
||||
code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||
"$REPO_API/releases/tags/$TAG")
|
||||
if [ "$code" = "200" ]; then
|
||||
rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])")
|
||||
echo "deleting incomplete release id $rid"
|
||||
curl -sS --http1.1 -X DELETE \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||
"$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n"
|
||||
else
|
||||
echo "no release for $TAG (HTTP $code)"
|
||||
fi
|
||||
del=$(curl -sS --http1.1 -o /tmp/tag-del.json -w '%{http_code}' -X DELETE \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||
"$REPO_API/tags/$TAG")
|
||||
echo "DELETE tag HTTP $del"
|
||||
if [ "$del" != "204" ] && [ "$del" != "404" ]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue