From f662d525dc80a779655fe3b8095e261556d98e9b Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Tue, 29 Dec 2020 22:57:44 -0600
Subject: [PATCH] Create badge json

---
 .gitlab-ci.yml            | 15 +++++++++++++++
 get-updated-badge-info.sh |  9 +++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 get-updated-badge-info.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 213da88..7c82438 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,12 +8,27 @@ before_script:
   - mkdir -p ~/.bdbag
 
 stages:
+  - badges
   - unit
   - aggregation
   - reference
   - integration
   - consistency
 
+build_bages:
+  stage: badges
+  only:
+    - master
+  script:
+    - echo "Building badges"
+  after_script:
+    - ./get-updated-badge-info.sh
+  artifacts:
+    paths:
+      - badges.json
+    when: always
+    expire_in: 3 months
+
 getBag:
   stage: unit
   only:
diff --git a/get-updated-badge-info.sh b/get-updated-badge-info.sh
new file mode 100644
index 0000000..9dcd5e0
--- /dev/null
+++ b/get-updated-badge-info.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+echo "collecting stats for badges"
+
+commits=`git rev-list --all --count`
+latest_release_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
+current_pipeline_version=$(cat ./workflow/nextflow.config | grep -o version.* | grep -oP "(?<=').*(?=')")
+current_nextflow_version=$(cat ./workflow/nextflow.config | grep -o nextflowVersion.* | grep -oP "(?<=').*(?=')")
+echo "{\"commits\":\"$commits\", \"release_tag\":\"$latest_release_tag\", \"pipeline\":\"$current_pipeline_version\", \"nextflow\":\"$current_nextflow_version\"}" > badges.json
\ No newline at end of file
-- 
GitLab