]> xenbits.xensource.com Git - xen-guest-agent.git/commitdiff
ci: use git-describe to set version for main branch builds
authorYann Dirson <yann.dirson@vates.fr>
Thu, 14 Dec 2023 10:37:47 +0000 (11:37 +0100)
committerYann Dirson <yann.dirson@vates.fr>
Thu, 14 Dec 2023 13:27:45 +0000 (14:27 +0100)
This will ensure not all builds share the same version string, and let
package update mechanism do their job.

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
.gitlab-ci.yml

index 934cbb5c113e19031cf86c1d28dec394c5821e88..dfb8eeb0c477f4a9ec76893108dcdf76630c9911 100644 (file)
@@ -91,9 +91,16 @@ env-setup:
   stage: setup
   image: alpine:latest
   script:
-    - 'UPSTREAMVERSION=$(grep "^version =" Cargo.toml | cut -d\" -f2)'
-    # both DEB and RPM use "~" to sort pre-releases before releases
-    - 'TILDEVERSION=$(echo $UPSTREAMVERSION | tr "-" "~")'
+    - |
+      case "$CI_COMMIT_BRANCH" in
+      main) UPSTREAMVERSION=$(git describe)
+            TILDEVERSION=$UPSTREAMVERSION
+            ;;
+      *)    UPSTREAMVERSION=$(grep "^version =" Cargo.toml | cut -d\" -f2)
+            # both DEB and RPM use "~" to sort pre-releases before releases
+            TILDEVERSION=$(echo $UPSTREAMVERSION | tr "-" "~")
+            ;;
+      esac
     # update channel must be the same for matching packaging and deploy
     # jobs, set it once globally
     - |