Browse Source

add scripts/get_module_version.sh

This script consumes a Prometheus version (or version tag) and prints
the appropriate module version.

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
pull/14666/head
Jan Fajerski 3 months ago
parent
commit
0f79e5e289
  1. 2
      .github/workflows/ci.yml
  2. 2
      RELEASE.md
  3. 24
      scripts/get_module_version.sh

2
.github/workflows/ci.yml

@ -253,7 +253,7 @@ jobs:
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.'))
||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.'))
run: ./scripts/ui_release.sh --check-package "$(echo ${{ github.ref_name }}|sed s/v2/v0/)"
run: ./scripts/ui_release.sh --check-package "$(./scripts/get_module_version.sh ${{ github.ref_name }})"
- name: build
run: make assets
- name: Copy files before publishing libs

2
RELEASE.md

@ -187,7 +187,7 @@ the Prometheus server, we use major version zero releases for the libraries.
Tag the new library release via the following commands:
```bash
tag="v$(sed s/2/0/ < VERSION)"
tag="v$(./scripts/get_module_version.sh)"
git tag -s "${tag}" -m "${tag}"
git push origin "${tag}"
```

24
scripts/get_module_version.sh

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# if no version string is passed as an argument, read VERSION file
if [ $# -eq 0 ]; then
VERSION="$(< VERSION)"
else
VERSION=$1
fi
# Remove leading 'v' if present
VERSION="${VERSION#v}"
# Extract MAJOR, MINOR, and REST
MAJOR="${VERSION%%.*}"
MINOR="${VERSION#*.}"; MINOR="${MINOR%%.*}"
REST="${VERSION#*.*.}"
# Format and output based on MAJOR version
if [[ "$MAJOR" == "2" ]]; then
echo "0.$MINOR.$REST"
elif [[ "$MAJOR" == "3" ]]; then
printf "0.3%02d.$REST\n" "$MINOR"
fi
Loading…
Cancel
Save