From 0e034c3fc7392da7f262cbecc6ecec71247b87a5 Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Wed, 21 Sep 2022 10:13:03 +0200
Subject: [PATCH] [release] when beta, push the tag automatically

---
 doc/release/deploy.tex                | 11 ++++++-----
 nix/frama-c-public/publish-release.sh | 18 ++++++++++++------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/doc/release/deploy.tex b/doc/release/deploy.tex
index 3527628644e..dcf2d18db4e 100644
--- a/doc/release/deploy.tex
+++ b/doc/release/deploy.tex
@@ -112,11 +112,12 @@ page (\url{https://git.frama-c.com/pub/frama-c/-/wikis/home}).
 In the release pipeline, run the job \texttt{release - release-branch}. It will
 push the stable branch on the public repository.
 
-Then, either the release is beta, or not. If the release is a beta, just push
-the tag of the release on the public GitLab. Else, run the job
-\texttt{release - release-create}. After this, the release should
-be available in \url{https://git.frama-c.com/pub/frama-c/-/releases}. As well
-as the tag of the version in \url{https://git.frama-c.com/pub/frama-c/-/tags}.
+Then, run the job \texttt{release - release-create}. After this, either the
+tag indicates a beta release and then this tag is pushed on the public GitLab
+repository (\url{https://git.frama-c.com/pub/frama-c/-/tags}), or it is a final
+release and the release should be available in
+\url{https://git.frama-c.com/pub/frama-c/-/releases}, as well as the tag of the
+version in \url{https://git.frama-c.com/pub/frama-c/-/tags}.
 
 \section{Announcements}
 
diff --git a/nix/frama-c-public/publish-release.sh b/nix/frama-c-public/publish-release.sh
index 9278ebae543..de2d8dfee70 100755
--- a/nix/frama-c-public/publish-release.sh
+++ b/nix/frama-c-public/publish-release.sh
@@ -33,9 +33,15 @@
 
 ##########################################################################
 
-curl \
-  --header 'Content-Type: application/json' \
-  --header "PRIVATE-TOKEN:$FRAMA_CI_BOT_RELEASE_TOKEN" \
-  --data-binary "@release-data.json" \
-  --request POST \
-  "https://git.frama-c.com/api/v4/projects/1113/releases"
+TAG="$(git describe --tag)"
+
+if [[ $TAG =~ .*-beta$ ]] ; then
+  git push "git@git.frama-c.com:pub/frama-c.git" "$TAG"
+else
+  curl \
+    --header 'Content-Type: application/json' \
+    --header "PRIVATE-TOKEN:$FRAMA_CI_BOT_RELEASE_TOKEN" \
+    --data-binary "@release-data.json" \
+    --request POST \
+    "https://git.frama-c.com/api/v4/projects/780/releases"
+fi
-- 
GitLab