cicd: Fix R-Ubuntu2404 job on tags.

Signed-off-by: Simon Josefsson <simon@josefsson.org>
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7b61969..371c9cc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -497,13 +497,26 @@
   - git config user.email "pipeline@example.org"
   - git config user.name "Pipeline Builder"
   - git config user.signingkey pipeline@example.org
-  - sed -i '4i - WARNING This release was prepared automatically with no testing.' NEWS
-  - git commit -m "Warn about automatic release." NEWS
-  - time make release-commit RELEASE='17.42.23 stable'
-  - time make
-  - time make release RELEASE='17.42.23 stable' V=1 VERBOSE=t
-  - cat -n ~/announce-*-17.42.23
-  - !reference [.save-artifacts, script]
+  - |
+    if test -z "$CI_COMMIT_TAG"; then
+      sed -i '3i * Noteworthy changes in release ?.? (????-??-??) [?]\n\n** WARNING This release was prepared automatically with no testing.\n' NEWS
+      git commit -m "Warn about automatic release." NEWS
+      relver='23.42.17'
+      reltyp='alpha'
+    else # maintainer ran release-commit
+      relver=$(cat NEWS | sed -n -e 's/.*release \([0-9.]\+\) (....-..-..) \[\(.*\)\].*/\1/p' | head -1)
+      reltyp=$(cat NEWS | sed -n -e 's/.*release \([0-9.]\+\) (....-..-..) \[\(.*\)\].*/\2/p' | head -1)
+    fi
+  - test -n "$CI_COMMIT_TAG" || make release-commit RELEASE="$relver $reltyp"
+  - make release RELEASE="$relver $reltyp" V=1 VERBOSE=t AM_DISTCHECK_DVI_TARGET=
+  - cat -n ~/announce-*
+  - git diff --exit-code # nothing should change version controlled files
+  - sha256sum *.tar.*
+  - mkdir -pv out/$CI_JOB_NAME_SLUG/{src,rel,log}
+  - find config.h *.log tests/*.log -exec mv -v {} out/$CI_JOB_NAME_SLUG/log \;
+  - test -n "$CI_COMMIT_TAG" || mv -v *23.42.17* out/$CI_JOB_NAME_SLUG/rel/
+  - mv -v *-src.tar.* out/$CI_JOB_NAME_SLUG/src/
+  - mv -v *.tar.* ~/announce-* out/$CI_JOB_NAME_SLUG/
 
 S-Trisquel10:
   tags: [ saas-linux-medium-amd64 ]