Skip to content

Commit 2fa6716

Browse files
author
Fernando López
committed
Update the script to extract the version of the Generic Enablers
1 parent f98b058 commit 2fa6716

1 file changed

Lines changed: 126 additions & 14 deletions

File tree

get_releases.sh

Lines changed: 126 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,112 @@
11
#!/bin/bash
22

3+
function get_last_tag {
4+
REPO="$1"
5+
PER_PAGE=100
6+
PAGE=1
7+
GITHUB_API="https://api.github.com"
8+
TAGS=()
9+
10+
while :; do
11+
RESP=$(curl -s "$GITHUB_API/repos/$REPO/tags?per_page=$PER_PAGE&page=$PAGE")
12+
COUNT=$(echo "$RESP" | jq length)
13+
if [ "$COUNT" -eq 0 ]; then
14+
break
15+
fi
16+
17+
TAGS+=($(echo "$RESP" | jq -r '.[] | @base64'))
18+
PAGE=$((PAGE + 1))
19+
done
20+
21+
if [ "${#TAGS[@]}" -eq 0 ]; then
22+
echo "No tags found for $REPO."
23+
exit 1
24+
fi
25+
26+
LATEST_DATE=""
27+
LATEST_TAG=""
28+
29+
for encoded_tag in "${TAGS[@]}"; do
30+
TAG=$(echo "$encoded_tag" | base64 --decode)
31+
NAME=$(echo "$TAG" | jq -r '.name')
32+
SHA=$(echo "$TAG" | jq -r '.commit.sha')
33+
34+
COMMIT_DATA=$(curl -s "$GITHUB_API/repos/$REPO/commits/$SHA")
35+
DATE=$(echo "$COMMIT_DATA" | jq -r '.commit.committer.date')
36+
37+
if [ -z "$LATEST_DATE" ] || [[ "$DATE" > "$LATEST_DATE" ]]; then
38+
LATEST_DATE="$DATE"
39+
LATEST_TAG="$NAME"
40+
fi
41+
done
42+
43+
# Extract and clean the repo name
44+
RAW_NAME=$(echo "$REPO" | cut -d'/' -f2)
45+
CLEAN_NAME=$(echo "$RAW_NAME" | sed 's/-/ /g')
46+
47+
echo $CLEAN_NAME
48+
# Output JSON
49+
jq -n \
50+
--arg name "$LATEST_TAG" \
51+
--arg tag_name "$LATEST_TAG" \
52+
--arg published_at "$LATEST_DATE" \
53+
'{name: $name, tag_name: $tag_name, published_at: $published_at}'
54+
}
55+
56+
function get_latest_bitbucked {
57+
#!/bin/bash
58+
59+
BASE_URL="https://ec.europa.eu/digital-building-blocks/code"
60+
PROJECT="EDELIVERY"
61+
REPO="domibus"
62+
63+
TAGS_API="$BASE_URL/rest/api/1.0/projects/$PROJECT/repos/$REPO/tags"
64+
COMMITS_API="$BASE_URL/rest/api/1.0/projects/$PROJECT/repos/$REPO/commits"
65+
66+
# Accumulator for tag info
67+
declare -A TAG_DATES
68+
69+
# Pagination
70+
START=0
71+
IS_LAST_PAGE=false
72+
73+
while [ "$IS_LAST_PAGE" = false ]; do
74+
RESP=$(curl -s "$TAGS_API?limit=100&start=$START")
75+
76+
TAGS=$(echo "$RESP" | jq -c '.values[]')
77+
78+
while IFS= read -r tag; do
79+
NAME=$(echo "$tag" | jq -r '.displayId')
80+
COMMIT=$(echo "$tag" | jq -r '.latestCommit')
81+
82+
# Get commit date
83+
COMMIT_INFO=$(curl -s "$COMMITS_API/$COMMIT")
84+
DATE=$(echo "$COMMIT_INFO" | jq -r '.authorTimestamp')
85+
86+
# Store timestamp → tag mapping
87+
TAG_DATES["$DATE"]="$NAME"
88+
done <<< "$TAGS"
89+
90+
IS_LAST_PAGE=$(echo "$RESP" | jq -r '.isLastPage')
91+
START=$(echo "$RESP" | jq -r '.nextPageStart')
92+
done
93+
94+
# Find the latest date
95+
LATEST_TIMESTAMP=$(printf "%s\n" "${!TAG_DATES[@]}" | sort -nr | head -n1)
96+
LATEST_TAG=${TAG_DATES[$LATEST_TIMESTAMP]}
97+
98+
# Convert milliseconds to ISO date
99+
LATEST_DATE=$(date -u -d @"$((LATEST_TIMESTAMP / 1000))" --iso-8601=seconds)
100+
101+
# Print data
102+
CLEAN_NAME=$(echo "$REPO" | sed 's/-/ /g')
103+
jq -n \
104+
--arg name "$CLEAN_NAME" \
105+
--arg tag_name "$LATEST_TAG" \
106+
--arg published_at "$LATEST_DATE" \
107+
'{name: $name, tag_name: $tag_name, published_at: $published_at}'
108+
}
109+
3110
function core {
4111
echo "Orion"
5112
http https://api.github.com/repos/telefonicaid/fiware-orion/releases/latest | jq '{name, tag_name, published_at}'
@@ -23,10 +130,10 @@ function core {
23130
http https://api.github.com/repos/ging/fiware-draco/releases/latest | jq '{name, tag_name, published_at}'
24131

25132
echo "Cosmos Flink"
26-
http https://api.github.com/repos/ging/fiware-cosmos-orion-flink-connector/tree/374f83d80bbc276661718f66c3d1644f19ca1794/releases/latest | jq '{name, tag_name, published_at}'
133+
http https://api.github.com/repos/ging/fiware-cosmos-orion-flink-connector/releases/latest | jq '{name, tag_name, published_at}'
27134

28135
echo "Cosmos Spark"
29-
http https://api.github.com/repos/ging/fiware-cosmos-orion-spark-connector/tree/5e7cf97f4c6659e8da8af3d41e1bf10f64494046/releases/latest | jq '{name, tag_name, published_at}'
136+
http https://api.github.com/repos/ging/fiware-cosmos-orion-spark-connector/releases/latest | jq '{name, tag_name, published_at}'
30137

31138
echo "QuantumLeap"
32139
http https://api.github.com/repos/orchestracities/ngsi-timeseries-api/releases/latest | jq '{name, tag_name, published_at}'
@@ -87,8 +194,10 @@ function data {
87194
echo "keypass"
88195
http https://api.github.com/repos/telefonicaid/fiware-keypass/releases/latest | jq '{name, tag_name, published_at}'
89196

197+
# Keystone SCIM has no versions only tags
90198
echo "keystone SCIM"
91-
http https://api.github.com/repos/telefonicaid/fiware-keystone-scim/releases/latest | jq '{name, tag_name, published_at}'
199+
# http https://api.github.com/repos/telefonicaid/fiware-keystone-scim/releases/latest | jq '{name, tag_name, published_at}'
200+
get_last_tag "telefonicaid/fiware-keystone-scim"
92201

93202
echo "keystone spassword"
94203
http https://api.github.com/repos/telefonicaid/fiware-keystone-spassword/releases/latest | jq '{name, tag_name, published_at}'
@@ -117,9 +226,18 @@ function data {
117226
echo "CKAN extensions"
118227
http https://api.github.com/repos/conwetlab/FIWARE-CKAN-Extensions/releases/latest | jq '{name, tag_name, published_at}'
119228

120-
echo "BAE"
229+
echo "BAE Framework APIs"
121230
http https://api.github.com/repos/FIWARE-TMForum/Business-API-Ecosystem/releases/latest | jq '{name, tag_name, published_at}'
122231

232+
echo "BAE Charging Backend"
233+
http https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-charging-backend/releases/latest | jq '{name, tag_name, published_at}'
234+
235+
echo "BAE Logic Proxy"
236+
http https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/releases/latest | jq '{name, tag_name, published_at}'
237+
238+
echo "BAE Revenue Sharing"
239+
http https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-rss/releases/latest | jq '{name, tag_name, published_at}'
240+
123241
echo "Idra"
124242
http https://api.github.com/repos/OPSILab/Idra/releases/latest | jq '{name, tag_name, published_at}'
125243
}
@@ -158,7 +276,7 @@ function iot {
158276
http https://api.github.com/repos/OpenMTC/OpenMTC/releases/latest | jq '{name, tag_name, published_at}'
159277

160278
echo "Fast DDS"
161-
http https://api.github.com/repos/eProsima/Fast-RTPS/releases/latest | jq '{name, tag_name, published_at}'
279+
http https://api.github.com/repos/eProsima/Fast-DDS/releases/latest | jq '{name, tag_name, published_at}'
162280

163281
echo "Micro XRCE-DDS"
164282
http https://api.github.com/repos/eProsima/Micro-XRCE-DDS/releases/latest | jq '{name, tag_name, published_at}'
@@ -172,37 +290,31 @@ function iot {
172290
echo "FIROS"
173291
http https://api.github.com/repos/iml130/firos/releases/latest | jq '{name, tag_name, published_at}'
174292

293+
# Domibus is in Bitbucked
175294
echo "Domibus"
176-
#http https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/eDelivery/releases/latest | jq '{name, tag_name, published_at}'
295+
get_latest_bitbucked
177296

178297
echo "Oliot"
179298
http https://api.github.com/repos/yalewkidane/FIWARE_EPCIS_Mediation_Gateway/releases/latest | jq '{name, tag_name, published_at}'
180299
}
181300

182-
function all {
183-
echo "all"
184-
}
185-
186-
187301

188302
# print the different options
189303
echo "Select one option:"
190304
echo "1) Execute core analysis"
191305
echo "2) Execute context processing analysis"
192306
echo "3) Execute data/api management analysis"
193307
echo "4) Execute iot analysis"
194-
echo "5) Execute all tests"
195308
echo
196309

197310
# Read the number from the user
198-
read -p "Enter a number (1-5): " num
311+
read -p "Enter a number (1-4): " num
199312

200313
# Call the appropriate function based on the number
201314
case $num in
202315
1) time core ;;
203316
2) time context ;;
204317
3) time data ;;
205318
4) time iot ;;
206-
5) time all ;;
207319
*) echo "Invalid number entered" ;;
208320
esac

0 commit comments

Comments
 (0)