From 710654308982fcda2321065fa419dc34bbcffd65 Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Wed, 23 Sep 2026 11:53:00 +0200 Subject: [PATCH] Release 0.3.41 publish: the iris step retries on a fresh clone when its push loses a race against a push to iris main. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01L4jrCgLiKKHAEFuZUJjckH --- .gitea/workflows/publish.yml | 44 ++++++++++++++++++++++++------------ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index a05f01f..14382ca 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -77,30 +77,46 @@ jobs: tag="${{ github.ref_name }}" ver="${tag#v}" host="${{ github.server_url }}" - rm -rf iris-src - git clone -q "$host/uhhm/iris.git" iris-src - cd iris-src - if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then - echo "iris $tag already exists, building it" - git checkout -q "$tag" - else + remote="https://${IRIS_PUSH_USER}:${IRIS_PUSH_TOKEN}@${host#https://}/uhhm/iris.git" + # Re-pin, version, changelog: idempotent, so a retry on a fresh + # clone redoes exactly the same edits. + match() { sed -i -E "s|^(portal = \{ git = \"[^\"]+\", tag = \")[^\"]+(\")|\1$tag\2|" Cargo.toml sed -i -E "0,/^version = \"[^\"]+\"/s//version = \"$ver\"/" Cargo.toml cargo update -q -p portal awk -v h="## $ver ($(date -u +%F)) - portal $tag" -v l="- Matches portal $tag (released by portal's publish job)." \ 'done==0 && /^## /{print h; print ""; print l; print ""; done=1} {print}' CHANGELOG.md > CHANGELOG.new mv CHANGELOG.new CHANGELOG.md - fi - cargo build --release - cargo test - if ! git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then git config user.name "portal release" git config user.email "portal@uhhm.no" git commit -qam "Match portal $tag" git tag "$tag" - git push -q "https://${IRIS_PUSH_USER}:${IRIS_PUSH_TOKEN}@${host#https://}/uhhm/iris.git" main "$tag" - echo "pushed iris $tag" - fi + } + # Someone may push to iris main while this job builds; a push + # then fails as non-fast-forward, and the answer is to start + # over on a fresh clone, once. + for attempt in 1 2; do + cd "$GITHUB_WORKSPACE" + rm -rf iris-src + git clone -q "$host/uhhm/iris.git" iris-src + cd iris-src + if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then + echo "iris $tag already exists, building it" + git checkout -q "$tag" + cargo build --release + cargo test + break + fi + match + cargo build --release + cargo test + if git push -q "$remote" main "$tag"; then + echo "pushed iris $tag" + break + fi + echo "push rejected on attempt $attempt (iris main moved), retrying on a fresh clone" + [ "$attempt" = 2 ] && exit 1 + done - name: Package run: | diff --git a/Cargo.lock b/Cargo.lock index a0126fe..1237624 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3265,7 +3265,7 @@ dependencies = [ [[package]] name = "portal" -version = "0.3.40" +version = "0.3.41" dependencies = [ "anyhow", "arc-swap", diff --git a/Cargo.toml b/Cargo.toml index 49a7382..2727c1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "portal" -version = "0.3.40" +version = "0.3.41" edition = "2021" [lib]