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:
|
publish:
|
||||||
needs: [version, aarch64, x86_64]
|
needs: [version, aarch64, x86_64]
|
||||||
# Always run after version so cleanup can need this job without Forgejo
|
# Always run after version so a failed build still hits the fail-closed
|
||||||
# act dying on "'runs-on' key not defined" for a skipped publish.
|
# delete step (a skipped publish left act without a job result).
|
||||||
# Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and
|
# 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
|
# 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
|
# 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.
|
# 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'
|
if: always() && needs.version.result == 'success'
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
@ -372,13 +375,8 @@ jobs:
|
||||||
dist/onionwire-x86_64-unknown-linux-gnu \
|
dist/onionwire-x86_64-unknown-linux-gnu \
|
||||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||||
|
|
||||||
cleanup:
|
- name: Delete tag we created if this job failed
|
||||||
needs: [version, aarch64, x86_64, publish]
|
if: failure() && needs.version.outputs.created_tag == 'true' && needs.version.outputs.dry_run != 'true'
|
||||||
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
|
|
||||||
env:
|
env:
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
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')
|
FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n')
|
||||||
echo "fail-closed: removing tag $TAG created by this run"
|
echo "fail-closed: removing tag $TAG created by this run"
|
||||||
code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \
|
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")
|
"$REPO_API/releases/tags/$TAG")
|
||||||
if [ "$code" = "200" ]; then
|
if [ "$code" = "200" ]; then
|
||||||
rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])")
|
rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])")
|
||||||
echo "deleting incomplete release id $rid"
|
echo "deleting incomplete release id $rid"
|
||||||
curl -sS --http1.1 -X DELETE \
|
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"
|
"$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n"
|
||||||
else
|
else
|
||||||
echo "no release for $TAG (HTTP $code)"
|
echo "no release for $TAG (HTTP $code)"
|
||||||
fi
|
fi
|
||||||
del=$(curl -sS --http1.1 -o /tmp/tag-del.json -w '%{http_code}' -X DELETE \
|
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")
|
"$REPO_API/tags/$TAG")
|
||||||
echo "DELETE tag HTTP $del"
|
echo "DELETE tag HTTP $del"
|
||||||
if [ "$del" != "204" ] && [ "$del" != "404" ]; then
|
if [ "$del" != "204" ] && [ "$del" != "404" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue